Index: trunk/src/lib/parser/ini_parser/ini_parser.cc
===================================================================
--- trunk/src/lib/parser/ini_parser/ini_parser.cc	(revision 9880)
+++ trunk/src/lib/parser/ini_parser/ini_parser.cc	(revision 9881)
@@ -21,17 +21,8 @@
 #include "ini_parser.h"
 
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #include <cassert>
 #include <algorithm>
 
-#ifdef DEBUG_LEVEL
- #include "../../../lib/util/debug.h"
-#else
- #define PRINTF(x) printf
- #define PRINT(x) printf
-#endif
+#define PARSELINELENGHT     1024       //!< how many chars to read at once
 
 
@@ -39,4 +30,9 @@
 /// INI-PARSER NODE ///
 /// /// /// /// /// ///
+/**
+ * @brief Constructs a Node
+ * @param name The name of the Node
+ * @param comment The comment of the Node.
+ */
 IniParser::Node::Node(const std::string& name, const std::string& comment)
 {
@@ -48,8 +44,17 @@
 /// INI-PARSER ENTRY ///
 /// /// /// /// /// ////
+/**
+ * @brief Constructs a new Entry
+ * @param name the Name of the Entry
+ * @param value The name of the Value
+ * @param comment The Comment used for the Entry
+ */
 IniParser::Entry::Entry(const std::string& name, const std::string& value, const std::string& comment)
     : IniParser::Node(name, comment), _value(value)
 {}
 
+/**
+ * @brief Displays some nice debug info.
+ */
 void IniParser::Entry::debug() const
 {
@@ -61,8 +66,21 @@
 /// INI-PARSER SECTION  ///
 /// /// /// /// /// /// ///
+/**
+ * @brief constructs a new Section
+ * @param sectionName The name of the Section
+ * @param comment The Comment for this section
+ */
 IniParser::Section::Section(const std::string& sectionName, const std::string& comment)
     : IniParser::Node(sectionName, comment)
 {}
 
+/**
+ * @brief Adds a new Entry to this Section
+ * @param entryName The name of the Entry
+ * @param value The Value of the Section
+ * @param comment The Comment
+ * @returns Reference to the Entry added.
+ * @see IniParser::Entry::Entry
+ */
 IniParser::Entry& IniParser::Section::addEntry(const std::string& entryName, const std::string& value, const std::string& comment)
 {
@@ -76,4 +94,11 @@
 }
 
+/**
+ * @brief edits an Entry's Value
+ * @param entryName The Entry to edit
+ * @param value The Value to change
+ * @param createMissing If the Entry is missing it is created if true.
+ * @return true on success.
+ */
 bool IniParser::Section::editEntry(const std::string& entryName, const std::string& value, bool createMissing)
 {
@@ -93,4 +118,9 @@
 }
 
+/**
+ * @param entryName The name of the entry to search for
+ * @param defaultValue The returned value, if the entry is not found
+ * @return The Value of the Entry, or defaultValue, if not found.
+ */
 const std::string& IniParser::Section::getValue(const std::string& entryName, const std::string& defaultValue) const
 {
@@ -102,4 +132,10 @@
 }
 
+/**
+ * @brief sets a Comment to an Entry
+ * @param entryName The Name of the Entry to set the comment to.
+ * @param comment the Comment.
+ * @return true on success (entry found and setup).
+ */
 bool IniParser::Section::setEntryComment(const std::string& entryName, const std::string& comment)
 {
@@ -113,4 +149,9 @@
 }
 
+/**
+ * @brief retrieves a Comment of an Entry
+ * @param entryName The Entry to get the comment of.
+ * @return The Comment, or "" if the Entry was not found.
+ */
 const std::string& IniParser::Section::getEntryComment(const std::string& entryName) const
 {
@@ -124,4 +165,10 @@
 
 
+/**
+ * @brief retrieves a pointer to an Entry
+ * @param entryName The Name of the Entry.
+ * @return the located Entry or NULL!
+ * @note beware of NULL!
+ */
 IniParser::Entry* IniParser::Section::getEntry(const std::string& entryName)
 {
@@ -133,4 +180,10 @@
 }
 
+/**
+ * @brief retrieves an Iterator to an Entry called entryName within this section
+ * @param entryName the name of the Entry
+ * @return The iterator to the position, or end();
+ * @see Section::end();
+ */
 IniParser::Entry::const_iterator IniParser::Section::getEntryIt(const std::string& entryName) const
 {
@@ -138,4 +191,7 @@
 }
 
+/**
+ * @brief clears the Section's entries (flushes them)
+ */
 void IniParser::Section::clear()
 {
@@ -143,4 +199,7 @@
 }
 
+/**
+ * @brief print out some debug info
+ */
 void IniParser::Section::debug() const
 {
@@ -155,8 +214,19 @@
 /// INI-PARSER DOCUMENT ///
 /// /// /// /// /// /// ///
+/**
+ * @brief Constructs a new Document
+ * @param fileName The Name of the Document.
+ * @param comment Some Comment
+ */
 IniParser::Document::Document(const std::string& fileName, const std::string& comment)
     : IniParser::Node(fileName, comment)
 {}
 
+/**
+ * @brief Adds a new Section to the Document
+ * @param sectionName The Name of the Section to add
+ * @param comment A comment for the section.
+ * @return A Reference to the newly added section.
+ */
 IniParser::Section& IniParser::Document::addSection(const std::string& sectionName, const std::string& comment)
 {
@@ -171,4 +241,9 @@
 }
 
+/**
+ * @brief removes a Section from the Document.
+ * @param sectionName The section to remove
+ * @return true on success (section was found).
+ */
 bool IniParser::Document::removeSection(const std::string& sectionName)
 {
@@ -183,4 +258,10 @@
 }
 
+/**
+ * @brief Sets a comment to a section
+ * @param sectionName The name of the section
+ * @param comment The Comment.
+ * @return True on success (section was found).
+ */
 bool IniParser::Document::setSectionComment(const std::string& sectionName, const std::string& comment)
 {
@@ -197,4 +278,10 @@
 
 
+/**
+ * @brief Queries for a Section within the document returning a Pointer to it
+ * @param sectionName The Section to search for.
+ * @return A pointer to the section, of NULL if not found.
+ * @brief beware of the NULL-pointer!
+ */
 IniParser::Section* IniParser::Document::getSection(const std::string& sectionName)
 {
@@ -208,4 +295,10 @@
 }
 
+/**
+ * @brief Queries for a Section within the document returning a Pointer to it
+ * @param sectionName The Section to search for.
+ * @return An iterator to the Section, or end()
+ * @see Section::end().
+ */
 IniParser::Section::const_iterator IniParser::Document::getSectionIt(const std::string& sectionName) const
 {
@@ -214,4 +307,14 @@
 }
 
+/**
+ * @brief adds a new Entry to a designated section.
+ * @param sectionName The name of the Section
+ * @param entryName The Name of the Entry to add
+ * @param value The Value to set for the entry
+ * @param comment optionally a comment.
+ * @return true on success (always true)
+ *
+ * @note the section will also be created on the go, if it did not exists so far!
+ */
 bool IniParser::Document::addEntry(const std::string& sectionName, const std::string& entryName, const std::string& value, const std::string& comment)
 {
@@ -229,4 +332,12 @@
 }
 
+/**
+ * @brief edits an Entry, and possibly creating it.
+ * @param sectionName The Section's name to edit the entry in.
+ * @param entryName The Name of the Entry to edit the value from
+ * @param value The new value for the Entry.
+ * @param createMissing if true, the Entry, (and the section) will be created.
+ * @return true on success, false otherwise.
+ */
 bool IniParser::Document::editEntry(const std::string& sectionName, const std::string& entryName, const std::string& value, bool createMissing)
 {
@@ -248,4 +359,11 @@
 }
 
+/**
+ * @brief Retrieve a value from an Entry.
+ * @param sectionName The Name of the Section the enrty is in
+ * @param entryName The Name of the entry
+ * @param defaultValue A default value, if the entry is not found
+ * @return A string containing the value, or defaultValue, if the Section->Entry was not found.
+ */
 const std::string& IniParser::Document::getValue(const std::string& sectionName, const std::string& entryName, const std::string& defaultValue) const
 {
@@ -257,4 +375,11 @@
 }
 
+/**
+ * @brief Sets a Comment to an Entry.
+ * @param sectionName The name of the Section.
+ * @param entryName The name of the Entry.
+ * @param comment The comment to set to this Entry
+ * @return true on success (Section->Entry found).
+ */
 bool IniParser::Document::setEntryComment(const std::string& sectionName, const std::string& entryName, const std::string& comment)
 {
@@ -267,4 +392,10 @@
 }
 
+/**
+ * @brief retrieved the comment of an Entry.
+ * @param sectionName The section.
+ * @param entryName The Entry to get the comment from
+ * @return the Comment of the Entry.
+ */
 const std::string& IniParser::Document::getEntryComment(const std::string& sectionName, const std::string& entryName) const
 {
@@ -276,4 +407,7 @@
 }
 
+/**
+ * @brief clears all sections.
+ */
 void IniParser::Document::clear()
 {
@@ -281,4 +415,7 @@
 }
 
+/**
+ * @brief Print some nice debug output.
+ */
 void IniParser::Document::debug() const
 {
@@ -334,5 +471,5 @@
   if( (stream = fopen (fileName.c_str(), "r")) == NULL)
   {
-    PRINTF(1)("IniParser could not open %s for reading\n", fileName.c_str());
+    printf("ERROR:: IniParser could not open %s for reading\n", fileName.c_str());
     return false;
   }
@@ -393,5 +530,5 @@
         if (currentSection == NULL)
         {
-          PRINTF(2)("Not in a Section yet for %s\n", lineBegin);
+	  printf("WARNING:: Not in a Section yet for %s\n", lineBegin);
           lineCount++;
           continue;
@@ -427,17 +564,20 @@
 
 /**
- * @brief opens a file and writes to it
- * @param fileName: path and name of the new file to write to
+ * @brief opens a file and writes to it.
+ * @param fileName: path and name of the new file to write to. If empty the internal value is used.
  * @return true on success false otherwise
  */
 bool IniParser::writeFile(const std::string& fileName) const
 {
+  std::string parseFile;
   FILE*    stream;           //!< The stream we use to read the file.
   if( fileName.empty())
-    return false;
-
-  if( (stream = fopen (fileName.c_str(), "w")) == NULL)
-  {
-    PRINTF(1)("IniParser could not open %s for writing\n", fileName.c_str());
+    parseFile = _fileName;
+  else
+    parseFile = fileName;
+
+  if( (stream = fopen (parseFile.c_str(), "w")) == NULL)
+  {
+    printf("ERROR:: IniParser could not open %s for writing\n", parseFile.c_str());
     return false;
   }
@@ -551,17 +691,19 @@
 void IniParser::debug() const
 {
-  PRINT(0)("Iniparser '%s' - debug\n", this->_fileName.c_str());
+  printf("Iniparser '%s' - debug\n", this->_fileName.c_str());
   if (!this->_document.comment().empty())
-    PRINT(0)("FileComment:\n '%s'\n\n", this->_document.comment().c_str());
+    printf("FileComment:\n '%s'\n\n", this->_document.comment().c_str());
 
   if (!this->_document.sections().empty())
     this->_document.debug();
   else
-    PRINTF(0)("no Sections Defined in this ini-file (%s).\n", _fileName.c_str());
-}
-
-
-/**
- * takes lines together to form one NodeComment, ereasing the commentList
+    printf("no Sections Defined in this ini-file (%s).\n", _fileName.c_str());
+}
+
+
+/**
+ * @brief takes lines together to form one NodeComment, ereasing the commentList
+ * @param node the Node to apply the Comment to.
+ * @param comments the CommentList to append.
  */
 void IniParser::setNodeComment(Node* node, std::list<std::string>* comments)
