Index: trunk/src/lib/util/ini_parser.cc
===================================================================
--- trunk/src/lib/util/ini_parser.cc	(revision 5930)
+++ trunk/src/lib/util/ini_parser.cc	(revision 5933)
@@ -21,8 +21,12 @@
 #include "ini_parser.h"
 
-#include "list.h"
 #include <stdlib.h>
 #include <string.h>
-#include "debug.h"
+
+#ifdef DEBUG
+ #include "debug.h"
+#else
+ #define PRINTF(x) printf
+#endif
 
 using namespace std;
@@ -31,22 +35,22 @@
  *  constructs an IniParser using a file
  * @param fileName: the path and name of the file to parse
-*/
+ */
 IniParser::IniParser (const char* fileName)
 {
-  this->currentEntry = NULL;
-  this->currentSection = NULL;
-  this->sections = NULL;
   this->fileName = NULL;
+
   if (fileName != NULL)
     this->readFile(fileName);
 }
 
+
 /**
  *  removes the IniParser from memory
-*/
+ */
 IniParser::~IniParser ()
 {
-  deleteSections();
-}
+  this->deleteSections();
+}
+
 
 /**
@@ -55,34 +59,25 @@
 void IniParser::deleteSections()
 {
-  if (this->sections)
-  {
-    tIterator<IniSection>* sectionIt = this->sections->getIterator();
-    IniSection* sectionEnum = sectionIt->firstElement();
-    while (sectionEnum)
-    {
-      tIterator<IniEntry>* entryIt = sectionEnum->entries->getIterator();
-      IniEntry* entryEnum = entryIt->firstElement();
-      while (entryEnum)
-      {
-        delete []entryEnum->name;
-        delete []entryEnum->value;
-        delete entryEnum;
-        entryEnum = entryIt->nextElement();
-      }
-      delete entryIt;
-
-      delete []sectionEnum->name;
-      delete sectionEnum->entries;
-      delete sectionEnum;
-      sectionEnum = sectionIt->nextElement();
-    }
-    delete sectionIt;
-  }
-  delete this->sections;
-  this->currentEntry = NULL;
-  this->currentSection = NULL;
-  this->sections = NULL;
+  while(!this->sections.empty())
+  {
+    IniSection section = this->sections.front();
+
+    while(!section.entries.empty())
+    {
+      IniEntry entry = section.entries.front();
+      delete []entry.name;
+      delete []entry.value;
+      section.entries.pop_front();
+    }
+
+    delete []section.name;
+    this->sections.pop_front();
+  }
+
+//  this->currentEntry = NULL;
+//  this->currentSection = NULL;
   this->setFileName(NULL);
 }
+
 
 /**
@@ -90,9 +85,9 @@
  * @param fileName: path and name of the new file to parse
  * @return true on success false otherwise;
-*/
+ */
 bool IniParser::readFile(const char* fileName)
 {
   FILE*    stream;           //!< The stream we use to read the file.
-  if (sections != NULL)
+  if (!sections.empty())
     deleteSections();
   if( fileName == NULL)
@@ -107,7 +102,6 @@
   else
   {
-    this->currentEntry = NULL;
-    this->currentSection = NULL;
-    this->sections = new tList<IniSection>;
+    this->currentEntry = 0;//this->sections.begin();
+    this->currentSection = this->sections.begin();
 
     /////////////////////////////
@@ -169,4 +163,5 @@
 }
 
+
 /**
  * opens a file and writes to it
@@ -187,25 +182,15 @@
   else
   {
-    if (this->sections)
-    {
-      tIterator<IniSection>* sectionIt = this->sections->getIterator();
-      IniSection* sectionEnum = sectionIt->firstElement();
-      while (sectionEnum)
+    if (!this->sections.empty())
+    {
+      std::list<IniSection>::iterator section;
+      for (section = this->sections.begin(); section != this->sections.end(); section++)
       {
-        fprintf(stream, "\n [%s]\n", sectionEnum->name);
-
-        tIterator<IniEntry>* entryIt = sectionEnum->entries->getIterator();
-        IniEntry* entryEnum = entryIt->firstElement();
-        while (entryEnum)
-        {
-          fprintf(stream, "   %s = %s\n", entryEnum->name, entryEnum->value);
-
-          entryEnum = entryIt->nextElement();
-        }
-        delete entryIt;
-
-        sectionEnum = sectionIt->nextElement();
+        fprintf(stream, "\n [%s]\n", (*section).name);
+
+        std::list<IniEntry>::iterator entry;
+        for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
+          fprintf(stream, "   %s = %s\n", (*entry).name, (*entry).value);
       }
-      delete sectionIt;
     }
     else
@@ -214,4 +199,5 @@
   fclose(stream);
 }
+
 
 /**
@@ -223,16 +209,14 @@
 bool IniParser::addSection(const char* sectionName)
 {
-  if (this->sections == NULL)
-    this->sections = new tList<IniSection>;
-
-  IniSection* newSection = new IniSection;
-  newSection->name = new char[strlen(sectionName)+1];
-  strcpy(newSection->name, sectionName);
-  newSection->entries = new tList<IniEntry>;
-  this->currentSection = newSection;
-  this->sections->add(newSection);
+  this->sections.push_back(IniSection());
+
+  this->sections.back().name = new char[strlen(sectionName)+1];
+  strcpy(this->sections.back().name, sectionName);
+
+  this->currentSection = --this->sections.end();
   PRINTF(5)("Added Section %s\n", sectionName);
   return true;
 }
+
 
 /**
@@ -243,22 +227,18 @@
 bool IniParser::getSection( const char* sectionName)
 {
-  tIterator<IniSection>* sectionIt = this->sections->getIterator();
-  IniSection* sectionEnum = sectionIt->firstElement();
-  while (sectionEnum)
-  {
-    if (!strcmp(sectionEnum->name, sectionName))
-    {
-      this->currentSection = sectionEnum;
-      this->currentEntry = NULL;
-      delete sectionIt;
+  std::list<IniSection>::iterator section;
+  for (section = this->sections.begin(); section != this->sections.end(); section++)
+  {
+    if (!strcmp((*section).name, sectionName))
+    {
+      this->currentSection = section;
+      this->currentEntry = (*section).entries.begin();
       return true;
     }
-
-    sectionEnum = sectionIt->nextElement();
-  }
-  delete sectionIt;
+  }
   return false;
 }
 
+
 /**
  * moves to the first section
@@ -266,10 +246,8 @@
 void IniParser::getFirstSection()
 {
-  if (this->sections)
-    this->currentSection = this->sections->firstElement();
-  else
-    this->currentSection = NULL;
-  this->currentEntry = NULL;
-}
+  this->currentSection = this->sections.begin();
+  this->currentEntry = (*this->currentSection).entries.begin();
+}
+
 
 /**
@@ -279,15 +257,12 @@
 const char* IniParser::nextSection()
 {
-  if (this->currentSection == NULL)
+  if (this->currentSection == this->sections.end())
     return NULL;
   else
   {
-    if (this->sections)
-    {
-      if (this->currentSection == this->sections->lastElement())
-        this->currentSection = NULL;
-      else
-        this->currentSection = this->sections->nextElement(this->currentSection);
-    }
+    if (this->currentSection == this->sections.end())
+      return NULL;
+    else
+      this->currentSection++;
   }
 
@@ -298,4 +273,5 @@
 }
 
+
 /**
  * moves to the first Variable of the current Section
@@ -303,9 +279,10 @@
 void IniParser::getFirstVar()
 {
-  if (this->currentSection)
-    this->currentEntry = this->currentSection->entries->firstElement();
-  else
-    this->currentEntry = NULL;
-}
+  if (this->currentSection != this->sections.end())
+    this->currentEntry = (*this->currentSection).entries.begin();
+//  else
+//    this->currentEntry = NULL;
+}
+
 
 /**
@@ -317,10 +294,10 @@
   if (this->currentSection == NULL
       || this->currentEntry == NULL
-      || this->currentEntry == this->currentSection->entries->lastElement())
+      || this->currentEntry == (*this->currentSection).entries.end())
   {
     this->currentEntry = NULL;
     return false;
   }
-  this->currentEntry = this->currentSection->entries->nextElement(this->currentEntry);
+  this->currentEntry++;
 
   if (this->currentEntry == NULL)
@@ -329,4 +306,5 @@
     return true;
 }
+
 
 /**
@@ -341,24 +319,16 @@
 bool IniParser::addVar(const char* entryName, const char* value, const char* sectionName)
 {
-  IniSection* addSection = NULL;
+  std::list<IniSection>::iterator section = this->sections.end();
+
   if (sectionName != NULL)
   {
-    tIterator<IniSection>* sectionIt = this->sections->getIterator();
-    IniSection* sectionEnum = sectionIt->firstElement();
-    while (sectionEnum)
-    {
-      if (!strcmp(sectionEnum->name, sectionName))
-      {
-        addSection = sectionEnum;
+    for (section = this->sections.begin(); section != this->sections.end(); section++)
+      if (!strcmp((*section).name, sectionName))
         break;
-      }
-      sectionEnum = sectionIt->nextElement();
-    }
-    delete sectionIt;
-  }
-  else
-    addSection = this->currentSection;
-
-  if (addSection == NULL)
+  }
+  else
+    section = this->currentSection;
+
+  if (section == this->sections.end())
   {
     PRINTF(2)("section not found for value %s\n", entryName);
@@ -367,14 +337,14 @@
   else
   {
-    IniEntry* newEntry = new IniEntry;
-    newEntry->name = new char[strlen (entryName)+1];
-    strcpy(newEntry->name, entryName);
-    newEntry->value = new char[strlen(value)+1];
-    strcpy(newEntry->value, value);
-    this->currentSection->entries->add(newEntry);
-    PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n", newEntry->name, newEntry->name, addSection->name);
+    (*section).entries.push_back(IniEntry());
+    (*section).entries.back().name = new char[strlen (entryName)+1];
+    strcpy((*section).entries.back().name, entryName);
+    (*section).entries.back().value = new char[strlen(value)+1];
+    strcpy((*section).entries.back().value, value);
+    PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n", entryName, value, (*section).name);
     return true;
   }
 }
+
 
 /**
@@ -390,31 +360,19 @@
 const char* IniParser::getVar(const char* entryName, const char* sectionName, const char* defaultValue) const
 {
-  if (this->sections)
-  {
-    tIterator<IniSection>* sectionIt = this->sections->getIterator();
-    IniSection* sectionEnum = sectionIt->firstElement();
-    while (sectionEnum)
-    {
-      if (!strcmp(sectionEnum->name, sectionName))
+  if (fileName != NULL)
+  {
+    std::list<IniSection>::const_iterator section;
+    for (section = this->sections.begin(); section != this->sections.end(); section++)
+    {
+      if (!strcmp((*section).name, sectionName))
       {
-        tIterator<IniEntry>* entryIt = sectionEnum->entries->getIterator();
-        IniEntry* entryEnum = entryIt->firstElement();
-        while (entryEnum)
-        {
-          if (!strcmp(entryEnum->name, entryName))
-          {
-            delete entryIt;
-            delete sectionIt;
-            return entryEnum->value;
-          }
-          entryEnum = entryIt->nextElement();
-        }
-         delete entryIt;
-         PRINTF(2)("Entry %s in section %s not found.\n", entryName, sectionName);
-         break;
+        std::list<IniEntry>::const_iterator entry;
+        for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
+          if (!strcmp((*entry).name, entryName))
+            return (*entry).value;
+        PRINTF(2)("Entry %s in section %s not found.\n", entryName, sectionName);
+        break;
       }
-      sectionEnum = sectionIt->nextElement();
-    }
-    delete sectionIt;
+    }
     PRINTF(2)("Section %s that should be containing %s not found.\n", sectionName, entryName);
   }
@@ -447,27 +405,17 @@
 {
   PRINTF(0)("Iniparser %s - debug\n", this->fileName);
-  if (this->sections)
-  {
-    tIterator<IniSection>* sectionIt = this->sections->getIterator();
-    IniSection* sectionEnum = sectionIt->firstElement();
-    while (sectionEnum)
-    {
-      PRINTF(0)(" [%s]\n", sectionEnum->name);
-
-      tIterator<IniEntry>* entryIt = sectionEnum->entries->getIterator();
-      IniEntry* entryEnum = entryIt->firstElement();
-      while (entryEnum)
-      {
-        PRINTF(0)("   :%s: -> '%s'\n", entryEnum->name, entryEnum->value);
-
-        entryEnum = entryIt->nextElement();
-      }
-      delete entryIt;
-
-      sectionEnum = sectionIt->nextElement();
-    }
-    delete sectionIt;
-  }
-  else
-    PRINTF(1)("%s not opened\n", fileName);
-}
+  if (this->fileName != NULL)
+  {
+    std::list<IniSection>::const_iterator section;
+    for (section = this->sections.begin(); section != this->sections.end(); section++)
+    {
+      PRINTF(0)(" [%s]\n", (*section).name);
+
+      std::list<IniEntry>::const_iterator entry;
+      for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
+        PRINTF(0)("   '%s' -> '%s'\n", (*entry).name, (*entry).value);
+    }
+  }
+  else
+    PRINTF(1)("no opened ini-file.\n");
+}
Index: trunk/src/lib/util/ini_parser.h
===================================================================
--- trunk/src/lib/util/ini_parser.h	(revision 5930)
+++ trunk/src/lib/util/ini_parser.h	(revision 5933)
@@ -11,9 +11,8 @@
 #define PARSELINELENGHT     512       //!< how many chars to read at once
 #ifndef NULL
-#define NULL 0x0                      //!< NULL
+ #define NULL 0x0                     //!< NULL
 #endif
 
-// FORWARD DECLARATION //
-template<class T> class tList;
+#include <list>
 
 //! ini-file parser
@@ -35,5 +34,5 @@
     {
       char*               name;    //!< name of a given section
-      tList<IniEntry>*    entries; //!< a list of entries for this section
+      std::list<IniEntry> entries; //!< a list of entries for this section
     };
     ////////////////////////////////////
@@ -53,5 +52,5 @@
 
     /** @returns true if the file is opened, false otherwise*/
-    bool isOpen() const { return (sections != NULL)?true:false; };
+    bool isOpen() const { return (this->fileName != NULL)? true : false; };
     /** @returns the fileName we have opened. */
     const char* getFileName() const { return this->fileName; };
@@ -77,8 +76,8 @@
 
   private:
-    char*                 fileName;        //!< The name of the File that was parsed.
-    tList<IniSection>*    sections;        //!< a list of all stored Sections of the Parser
-    IniSection*           currentSection;  //!< the current selected Section
-    IniEntry*             currentEntry;    //!< the current selected entry (in currentSection)
+    char*                            fileName;        //!< The name of the File that was parsed.
+    std::list<IniSection>            sections;        //!< a list of all stored Sections of the Parser
+    std::list<IniSection>::iterator  currentSection;  //!< the current selected Section
+    std::list<IniEntry>::iterator    currentEntry;    //!< the current selected entry (in currentSection)
 };
 
