Index: trunk/src/lib/util/ini_parser.cc
===================================================================
--- trunk/src/lib/util/ini_parser.cc	(revision 5933)
+++ trunk/src/lib/util/ini_parser.cc	(revision 5934)
@@ -33,5 +33,5 @@
 
 /**
- *  constructs an IniParser using a file
+ * @brief constructs an IniParser using a file
  * @param fileName: the path and name of the file to parse
  */
@@ -39,4 +39,5 @@
 {
   this->fileName = NULL;
+
 
   if (fileName != NULL)
@@ -46,5 +47,5 @@
 
 /**
- *  removes the IniParser from memory
+ * @brief removes the IniParser from memory
  */
 IniParser::~IniParser ()
@@ -55,14 +56,18 @@
 
 /**
- * removes all the sections. This is like delete, but even cooler :)
+ * @brief removes all the sections. This is like delete, but even cooler :)
  */
 void IniParser::deleteSections()
 {
+  // in all sections
   while(!this->sections.empty())
   {
+    
     IniSection section = this->sections.front();
-
+    
+    // in all entries of the sections
     while(!section.entries.empty())
     {
+      // delete all strings of entries.
       IniEntry entry = section.entries.front();
       delete []entry.name;
@@ -70,11 +75,8 @@
       section.entries.pop_front();
     }
-
+    // delete all Sections
     delete []section.name;
     this->sections.pop_front();
   }
-
-//  this->currentEntry = NULL;
-//  this->currentSection = NULL;
   this->setFileName(NULL);
 }
@@ -82,16 +84,38 @@
 
 /**
- * opens another file to parse
+ * @brief sets the Name of the input-file
+ * @param fileName The new FileName to set to the IniParser
+ * IF fileName is NULL the new Name will be set to NULL too.
+ */
+void IniParser::setFileName(const char* fileName)
+{
+  if (this->fileName)
+    delete []this->fileName;
+  if (fileName)
+  {
+    this->fileName = new char[strlen(fileName)+1];
+    strcpy(this->fileName, fileName);
+  }
+  else
+    this->fileName = NULL;
+}
+
+
+/**
+ * @brief opens a file to parse 
  * @param fileName: path and name of the new file to parse
  * @return true on success false otherwise;
+ *
+ * If there was already an opened file, the file will be closed,
+ * and the new one will be opened.
  */
 bool IniParser::readFile(const char* fileName)
 {
-  FILE*    stream;           //!< The stream we use to read the file.
-  if (!sections.empty())
-    deleteSections();
+  FILE*    stream;           //< The stream we use to read the file.
+
+  if (this->fileName != NULL)
+    this->deleteSections();
   if( fileName == NULL)
     return false;
-  this->setFileName(fileName);
 
   if( (stream = fopen (fileName, "r")) == NULL)
@@ -102,6 +126,5 @@
   else
   {
-    this->currentEntry = 0;//this->sections.begin();
-    this->currentSection = this->sections.begin();
+    this->setFileName(fileName);
 
     /////////////////////////////
@@ -159,4 +182,8 @@
     }
   }
+  this->currentSection = this->sections.begin();
+  if (!this->sections.empty())
+    this->currentEntry = (*this->currentSection).entries.begin();
+
   fclose(stream);
   return true;
@@ -165,5 +192,5 @@
 
 /**
- * opens a file and writes to it
+ * @brief opens a file and writes to it
  * @param fileName: path and name of the new file to write to
  * @return true on success false otherwise
@@ -182,18 +209,13 @@
   else
   {
-    if (!this->sections.empty())
-    {
-      std::list<IniSection>::iterator section;
-      for (section = this->sections.begin(); section != this->sections.end(); section++)
+    std::list<IniSection>::iterator section;
+    for (section = this->sections.begin(); section != this->sections.end(); section++)
       {
         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);
       }
-    }
-    else
-      PRINTF(1)("%s no sections defined yet\n", fileName);
   }
   fclose(stream);
@@ -202,5 +224,5 @@
 
 /**
- * adds a section to the list of Sections,
+ * @brief adds a section to the list of Sections,
  * if no Section list is availiable, it will create it
  * @param sectionName the Name of the section to add
@@ -215,4 +237,6 @@
 
   this->currentSection = --this->sections.end();
+  if (!this->sections.empty())
+    this->currentEntry = (*this->currentSection).entries.begin();
   PRINTF(5)("Added Section %s\n", sectionName);
   return true;
@@ -221,5 +245,5 @@
 
 /**
- *  set the parsing cursor to the specified section
+ * @brief Set the parsing cursor to the specified section
  * @param sectionName: the name of the section to set the cursor to
  * @return true on success or false if the section could not be found
@@ -229,12 +253,11 @@
   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;
-    }
-  }
+      {
+	this->currentSection = section;
+	this->currentEntry = (*this->currentSection).entries.begin();
+	return true;
+      }
+
   return false;
 }
@@ -242,15 +265,16 @@
 
 /**
- * moves to the first section
+ * @brief moves to the first section
  */
 void IniParser::getFirstSection()
 {
   this->currentSection = this->sections.begin();
-  this->currentEntry = (*this->currentSection).entries.begin();
-}
-
-
-/**
- * searches the next section
+  if (!this->sections.empty())
+    this->currentEntry = (*this->currentSection).entries.begin();
+}
+
+
+/**
+ * @brief searches the next section
  * @returns the name of the section if found, NULL otherwise
  */
@@ -261,12 +285,14 @@
   else
   {
+    this->currentSection++;
+  }
     if (this->currentSection == this->sections.end())
       return NULL;
-    else
-      this->currentSection++;
-  }
-
-  if (this->currentSection != NULL)
-    return this->currentSection->name;
+
+  if (this->currentSection != this->sections.end())
+    {
+      this->currentEntry = (*this->currentSection).entries.begin();
+      return this->currentSection->name;
+    }
   else
     return NULL;
@@ -275,5 +301,5 @@
 
 /**
- * moves to the first Variable of the current Section
+ * @brief moves to the first Variable of the current Section
  */
 void IniParser::getFirstVar()
@@ -281,25 +307,21 @@
   if (this->currentSection != this->sections.end())
     this->currentEntry = (*this->currentSection).entries.begin();
-//  else
-//    this->currentEntry = NULL;
-}
-
-
-/**
- *  gets the next VarName=VarValue pair from the parsing stream
+}
+
+
+/**
+ * @brief gets the next VarName = VarValue pair from the parsing stream
  * @return true on success, false otherwise (in the latter case name and value will be NULL)
  */
 bool IniParser::nextVar()
 {
-  if (this->currentSection == NULL
-      || this->currentEntry == NULL
-      || this->currentEntry == (*this->currentSection).entries.end())
-  {
-    this->currentEntry = NULL;
-    return false;
-  }
+  if ( this->sections.empty() 
+       || this->currentSection == this->sections.end()
+       || this->currentEntry == (*this->currentSection).entries.end())
+    return false;
+
   this->currentEntry++;
 
-  if (this->currentEntry == NULL)
+  if (this->currentEntry == (*this->currentSection).entries.end())
     return false;
   else
@@ -309,5 +331,5 @@
 
 /**
- * adds a new Entry to either the currentSection or the section called by sectionName
+ * @brief adds a new Entry to either the currentSection or the section called by sectionName
  * @param entryName the Name of the Entry to add
  * @param value the value to assign to this entry
@@ -319,5 +341,5 @@
 bool IniParser::addVar(const char* entryName, const char* value, const char* sectionName)
 {
-  std::list<IniSection>::iterator section = this->sections.end();
+  std::list<IniSection>::iterator section;
 
   if (sectionName != NULL)
@@ -332,5 +354,5 @@
   if (section == this->sections.end())
   {
-    PRINTF(2)("section not found for value %s\n", entryName);
+    PRINTF(2)("section '%s' not found for value '%s'\n", sectionName, entryName);
     return false;
   }
@@ -349,5 +371,5 @@
 
 /**
- *  directly acesses an entry in a section
+ * @brief directly acesses an entry in a section
  * @param entryName: the name of the entry to find
  * @param sectionName: the section where the entry is to be found
@@ -363,20 +385,28 @@
   {
     std::list<IniSection>::const_iterator section;
-    for (section = this->sections.begin(); section != this->sections.end(); section++)
-    {
-      if (!strcmp((*section).name, sectionName))
+    if (sectionName != NULL)
       {
-        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;
+
+	for (section = this->sections.begin(); section != this->sections.end(); section++)
+	  {
+	    if (!strcmp((*section).name, sectionName))
+	      {
+		break;
+	      }
+	  }
+	PRINTF(2)("Section %s that should be containing %s not found.\n", sectionName, entryName);
       }
-    }
-    PRINTF(2)("Section %s that should be containing %s not found.\n", sectionName, entryName);
-  }
-  else
-    PRINTF(1)("%s not opened\n", fileName);
+    else
+      section = this->currentSection;
+
+    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);
+   
+  }
+  else
+    PRINTF(2)("%s not opened\n", fileName);
 
   return defaultValue;
@@ -384,21 +414,6 @@
 }
 
-
-void IniParser::setFileName(const char* fileName)
-{
-  if (this->fileName)
-    delete []this->fileName;
-  if (fileName)
-  {
-    this->fileName = new char[strlen(fileName)+1];
-    strcpy(this->fileName, fileName);
-  }
-  else
-    this->fileName = NULL;
-}
-
-
-/**
- * output the whole tree in a nice and easy way.
+/**
+ * @brief output the whole tree in a nice and easy way.
  */
 void IniParser::debug() const
Index: trunk/src/lib/util/ini_parser.h
===================================================================
--- trunk/src/lib/util/ini_parser.h	(revision 5933)
+++ trunk/src/lib/util/ini_parser.h	(revision 5934)
@@ -48,9 +48,10 @@
     bool getSection(const char* sectionName);
 
+    /** @returns true if the file is opened, false otherwise*/
+    bool isOpen() const { return (this->fileName != NULL)? true : false; };
+
     void getFirstSection();
     const char* nextSection();
 
-    /** @returns true if the file is opened, false otherwise*/
-    bool isOpen() const { return (this->fileName != NULL)? true : false; };
     /** @returns the fileName we have opened. */
     const char* getFileName() const { return this->fileName; };
@@ -71,4 +72,5 @@
     void debug() const;
 
+
   private:
     void deleteSections();
