Index: /trunk/src/lib/event/key_mapper.cc
===================================================================
--- /trunk/src/lib/event/key_mapper.cc	(revision 9879)
+++ /trunk/src/lib/event/key_mapper.cc	(revision 9880)
@@ -74,38 +74,38 @@
  */
 KeyMapper::KeyMapping KeyMapper::map[] = {
-  {&KeyMapper::PEV_FORWARD,              CONFIG_NAME_PLAYER_FORWARD,         SDLK_w},
-  {&KeyMapper::PEV_BACKWARD,             CONFIG_NAME_PLAYER_BACKWARD,        SDLK_s},
-  {&KeyMapper::PEV_UP,                   CONFIG_NAME_PLAYER_UP,              SDLK_r},
-  {&KeyMapper::PEV_DOWN,                 CONFIG_NAME_PLAYER_DOWN,            SDLK_f},
-  {&KeyMapper::PEV_LEFT,                 CONFIG_NAME_PLAYER_LEFT,            SDLK_a},
-  {&KeyMapper::PEV_RIGHT,                CONFIG_NAME_PLAYER_RIGHT,           SDLK_d},
-  {&KeyMapper::PEV_ROLL_RIGHT,           CONFIG_NAME_PLAYER_ROLL_LEFT,       SDLK_z},
-  {&KeyMapper::PEV_ROLL_LEFT,            CONFIG_NAME_PLAYER_ROLL_RIGHT,      SDLK_c},
-  {&KeyMapper::PEV_STRAFE_LEFT,          "StrafeLeft",                       SDLK_q},
-  {&KeyMapper::PEV_STRAFE_RIGHT,         "StrafeRight",                      SDLK_e},
-  {&KeyMapper::PEV_JUMP,                 "Jump",                             SDLK_SPACE},
-
-  {&KeyMapper::PEV_FIRE1,                CONFIG_NAME_PLAYER_FIRE,            EV_MOUSE_BUTTON_LEFT},
-  {&KeyMapper::PEV_FIRE2,                "Fire2",                            EV_MOUSE_BUTTON_RIGHT},
-  {&KeyMapper::PEV_NEXT_WEAPON,          CONFIG_NAME_PLAYER_NEXT_WEAPON,     EV_MOUSE_BUTTON_WHEELUP},
-  {&KeyMapper::PEV_PREVIOUS_WEAPON,      CONFIG_NAME_PLAYER_PREV_WEAPON,     EV_MOUSE_BUTTON_WHEELDOWN},
-
-  {&KeyMapper::PEV_CHANGE_SHIP,          CONFIG_NAME_PLAYER_CHANGE_SHIP,     SDLK_g},
-
-
-  {&KeyMapper::PEV_VIEW0,                CONFIG_NAME_VIEW0,                  SDLK_1},
-  {&KeyMapper::PEV_VIEW1,                CONFIG_NAME_VIEW1,                  SDLK_2},
-  {&KeyMapper::PEV_VIEW2,                CONFIG_NAME_VIEW2,                  SDLK_3},
-  {&KeyMapper::PEV_VIEW3,                CONFIG_NAME_VIEW3,                  SDLK_4},
-  {&KeyMapper::PEV_VIEW4,                CONFIG_NAME_VIEW4,                  SDLK_5},
-  {&KeyMapper::PEV_VIEW5,                CONFIG_NAME_VIEW5,                  SDLK_6},
-
-  {&KeyMapper::PEV_NEXT_WORLD,           CONFIG_NAME_NEXT_WORLD,             SDLK_x},
-  {&KeyMapper::PEV_PREVIOUS_WORLD,       CONFIG_NAME_PREV_WORLD,             SDLK_z},
-
-  {&KeyMapper::PEV_PAUSE,                CONFIG_NAME_PAUSE,                  SDLK_p},
-  {&KeyMapper::PEV_QUIT,                 CONFIG_NAME_QUIT,                   SDLK_ESCAPE},
-  {NULL, "", 0}
-};
+      {&KeyMapper::PEV_FORWARD,              CONFIG_NAME_PLAYER_FORWARD,         SDLK_w},
+      {&KeyMapper::PEV_BACKWARD,             CONFIG_NAME_PLAYER_BACKWARD,        SDLK_s},
+      {&KeyMapper::PEV_UP,                   CONFIG_NAME_PLAYER_UP,              SDLK_r},
+      {&KeyMapper::PEV_DOWN,                 CONFIG_NAME_PLAYER_DOWN,            SDLK_f},
+      {&KeyMapper::PEV_LEFT,                 CONFIG_NAME_PLAYER_LEFT,            SDLK_a},
+      {&KeyMapper::PEV_RIGHT,                CONFIG_NAME_PLAYER_RIGHT,           SDLK_d},
+      {&KeyMapper::PEV_ROLL_RIGHT,           CONFIG_NAME_PLAYER_ROLL_LEFT,       SDLK_z},
+      {&KeyMapper::PEV_ROLL_LEFT,            CONFIG_NAME_PLAYER_ROLL_RIGHT,      SDLK_c},
+      {&KeyMapper::PEV_STRAFE_LEFT,          "StrafeLeft",                       SDLK_q},
+      {&KeyMapper::PEV_STRAFE_RIGHT,         "StrafeRight",                      SDLK_e},
+      {&KeyMapper::PEV_JUMP,                 "Jump",                             SDLK_SPACE},
+
+      {&KeyMapper::PEV_FIRE1,                CONFIG_NAME_PLAYER_FIRE,            EV_MOUSE_BUTTON_LEFT},
+      {&KeyMapper::PEV_FIRE2,                "Fire2",                            EV_MOUSE_BUTTON_RIGHT},
+      {&KeyMapper::PEV_NEXT_WEAPON,          CONFIG_NAME_PLAYER_NEXT_WEAPON,     EV_MOUSE_BUTTON_WHEELUP},
+      {&KeyMapper::PEV_PREVIOUS_WEAPON,      CONFIG_NAME_PLAYER_PREV_WEAPON,     EV_MOUSE_BUTTON_WHEELDOWN},
+
+      {&KeyMapper::PEV_CHANGE_SHIP,          CONFIG_NAME_PLAYER_CHANGE_SHIP,     SDLK_g},
+
+
+      {&KeyMapper::PEV_VIEW0,                CONFIG_NAME_VIEW0,                  SDLK_1},
+      {&KeyMapper::PEV_VIEW1,                CONFIG_NAME_VIEW1,                  SDLK_2},
+      {&KeyMapper::PEV_VIEW2,                CONFIG_NAME_VIEW2,                  SDLK_3},
+      {&KeyMapper::PEV_VIEW3,                CONFIG_NAME_VIEW3,                  SDLK_4},
+      {&KeyMapper::PEV_VIEW4,                CONFIG_NAME_VIEW4,                  SDLK_5},
+      {&KeyMapper::PEV_VIEW5,                CONFIG_NAME_VIEW5,                  SDLK_6},
+
+      {&KeyMapper::PEV_NEXT_WORLD,           CONFIG_NAME_NEXT_WORLD,             SDLK_x},
+      {&KeyMapper::PEV_PREVIOUS_WORLD,       CONFIG_NAME_PREV_WORLD,             SDLK_z},
+
+      {&KeyMapper::PEV_PAUSE,                CONFIG_NAME_PAUSE,                  SDLK_p},
+      {&KeyMapper::PEV_QUIT,                 CONFIG_NAME_QUIT,                   SDLK_ESCAPE},
+      {NULL, "", 0}
+    };
 
 
@@ -124,6 +124,5 @@
 */
 KeyMapper::~KeyMapper ()
-{
-}
+{}
 
 
@@ -140,5 +139,6 @@
 void KeyMapper::loadKeyBindings(IniParser* iniParser)
 {
-  if( !iniParser->getSection (CONFIG_SECTION_CONTROL))
+  IniParser::Section* section = iniParser->getSection (CONFIG_SECTION_CONTROL);
+  if( section == NULL)
   {
     PRINTF(1)("Could not find key bindings " CONFIG_SECTION_CONTROL "\n");
@@ -147,31 +147,32 @@
   int* index;
 
-  iniParser->firstVar();
-  while( iniParser->getCurrentName() != "" )
-  {
-    PRINTF(3)("Keys: Parsing %s, %s now.\n", iniParser->getCurrentName().c_str(), iniParser->getCurrentValue().c_str());
+
+  for(IniParser::Entry::iterator entry = section->begin();
+      entry != section->end();
+      ++entry)
+  {
+    PRINTF(3)("Keys: Parsing %s, %s now.\n", (*entry).name().c_str(), (*entry).value().c_str());
     // map the name to an sdl index
-    index = nameToIndex (iniParser->getCurrentValue());
+    index = nameToIndex ((*entry).value());
     // map the index to a internal name
-    this->mapKeys(iniParser->getCurrentName(), index);
-    iniParser->nextVar();
+    this->mapKeys((*entry).name(), index);
   }
 
 
   // PARSE MISC SECTION
-//   if( !iniParser->getSection (CONFIG_SECTION_MISC_KEYS))
-//   {
-//     PRINTF(1)("Could not find key bindings" CONFIG_SECTION_MISC_KEYS "\n");
-//     return;
-//   }
-//
-//   iniParser->firstVar();
-//   while( iniParser->getCurrentName() != "" )
-//   {
-//     PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
-//     index = nameToIndex (iniParser->getCurrentValue());
-//     this->mapKeys(iniParser->getCurrentName(), index);
-//     iniParser->nextVar();
-//   }
+  //   if( !iniParser->getSection (CONFIG_SECTION_MISC_KEYS))
+  //   {
+  //     PRINTF(1)("Could not find key bindings" CONFIG_SECTION_MISC_KEYS "\n");
+  //     return;
+  //   }
+  //
+  //   iniParser->firstVar();
+  //   while( iniParser->getCurrentName() != "" )
+  //   {
+  //     PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
+  //     index = nameToIndex (iniParser->getCurrentValue());
+  //     this->mapKeys(iniParser->getCurrentName(), index);
+  //     iniParser->nextVar();
+  //   }
 }
 
@@ -205,12 +206,14 @@
   coord[1] = -1;
   int c;
-  if( (c = keynameToSDLK (name)) != -1) {
-      coord[1] = c;
-      coord[0] = 0;
-    }
-  if( (c = buttonnameToSDLB (name)) != -1) {
-      coord[1] = c;
-      coord[0] = 1;
-    }
+  if( (c = keynameToSDLK (name)) != -1)
+  {
+    coord[1] = c;
+    coord[0] = 0;
+  }
+  if( (c = buttonnameToSDLB (name)) != -1)
+  {
+    coord[1] = c;
+    coord[0] = 1;
+  }
   return coord;
 }
@@ -225,20 +228,21 @@
 {
   for( int i = 0; map[i].pValue != NULL; ++i )
+  {
+    if( name == map[i].pName)
     {
-      if( name == map[i].pName)
+      if( index[0] == 0)
       {
-        if( index[0] == 0)
-        {
-          *map[i].pValue = index[1];
-          PRINTF(4)("Mapping %s to '%s' (id %i)\n", name.c_str(), SDLKToKeyname(index[1]).c_str(), index[1]);
-          break;
-        }
-        else {
-          *map[i].pValue = index[1];
-          PRINTF(4)("Mapping %s to '%s' (id %i)\n", name.c_str(), SDLBToButtonname(index[1]).c_str(), index[1]);
-          break;
-        }
+        *map[i].pValue = index[1];
+        PRINTF(4)("Mapping %s to '%s' (id %i)\n", name.c_str(), SDLKToKeyname(index[1]).c_str(), index[1]);
+        break;
+      }
+      else
+      {
+        *map[i].pValue = index[1];
+        PRINTF(4)("Mapping %s to '%s' (id %i)\n", name.c_str(), SDLBToButtonname(index[1]).c_str(), index[1]);
+        break;
       }
     }
+  }
 }
 
@@ -251,7 +255,7 @@
   PRINT(0)("\n==========================| KeyMapper::debug() |===\n");
   for(int i = 0; map[i].pValue != NULL; ++i)
-    {
-      PRINT(0)("%s = %i\n",map[i].pName.c_str(), *map[i].pValue);
-    }
+  {
+    PRINT(0)("%s = %i\n",map[i].pName.c_str(), *map[i].pValue);
+  }
   PRINT(0)("=======================================================\n");
 }
Index: /trunk/src/lib/parser/ini_parser/ini_parser.cc
===================================================================
--- /trunk/src/lib/parser/ini_parser/ini_parser.cc	(revision 9879)
+++ /trunk/src/lib/parser/ini_parser/ini_parser.cc	(revision 9880)
@@ -21,10 +21,10 @@
 #include "ini_parser.h"
 
-#include <stdlib.h>
-#include <string.h>
-
 #if HAVE_CONFIG_H
 #include <config.h>
 #endif
+
+#include <cassert>
+#include <algorithm>
 
 #ifdef DEBUG_LEVEL
@@ -36,5 +36,262 @@
 
 
-
+/// /// /// /// /// ///
+/// INI-PARSER NODE ///
+/// /// /// /// /// ///
+IniParser::Node::Node(const std::string& name, const std::string& comment)
+{
+  this->_name = name;
+  this->_comment = comment;
+}
+
+/// /// /// /// /// ////
+/// INI-PARSER ENTRY ///
+/// /// /// /// /// ////
+IniParser::Entry::Entry(const std::string& name, const std::string& value, const std::string& comment)
+    : IniParser::Node(name, comment), _value(value)
+{}
+
+void IniParser::Entry::debug() const
+{
+  printf("   %s = %s\n", this->name().c_str(), this->_value.c_str());
+}
+
+
+/// /// /// /// /// /// ///
+/// INI-PARSER SECTION  ///
+/// /// /// /// /// /// ///
+IniParser::Section::Section(const std::string& sectionName, const std::string& comment)
+    : IniParser::Node(sectionName, comment)
+{}
+
+IniParser::Entry& IniParser::Section::addEntry(const std::string& entryName, const std::string& value, const std::string& comment)
+{
+  Entry::iterator entry = std::find(this->_entries.begin(), this->_entries.end(), entryName);
+  if (entry == this->_entries.end())
+  {
+    this->_entries.push_back(Entry(entryName, value, comment));
+    entry = --this->_entries.end();
+  }
+  return *entry;
+}
+
+bool IniParser::Section::editEntry(const std::string& entryName, const std::string& value, bool createMissing)
+{
+  Entry::iterator entry = std::find(this->_entries.begin(), this->_entries.end(), entryName);
+  if (entry == this->_entries.end())
+  {
+    if (createMissing)
+    {
+      this->addEntry(entryName, value);
+      return true;
+    }
+    else
+      return false;
+  }
+  (*entry).setValue(value);
+  return true;
+}
+
+const std::string& IniParser::Section::getValue(const std::string& entryName, const std::string& defaultValue) const
+{
+  Entry::const_iterator entry = std::find(this->_entries.begin(), this->_entries.end(), entryName);
+  if (entry != this->_entries.end())
+    return (*entry).value();
+  else
+    return defaultValue;
+}
+
+bool IniParser::Section::setEntryComment(const std::string& entryName, const std::string& comment)
+{
+  Entry::iterator entry = std::find(this->_entries.begin(), this->_entries.end(), entryName);
+  if (entry != this->_entries.end())
+  {
+    (*entry).setComment(comment);
+    return true;
+  }
+  return false;
+}
+
+const std::string& IniParser::Section::getEntryComment(const std::string& entryName) const
+{
+  Entry::const_iterator entry = std::find(this->_entries.begin(), this->_entries.end(), entryName);
+  if (entry != this->_entries.end())
+  {
+    return (*entry).comment();
+  }
+  return IniParser::_emptyString;
+}
+
+
+IniParser::Entry* IniParser::Section::getEntry(const std::string& entryName)
+{
+  Entry::iterator entry = std::find(this->_entries.begin(), this->_entries.end(), entryName);
+  if (entry != this->_entries.end())
+    return &(*entry);
+  else
+    return NULL;
+}
+
+IniParser::Entry::const_iterator IniParser::Section::getEntryIt(const std::string& entryName) const
+{
+  return std::find(this->_entries.begin(), this->_entries.end(), entryName);
+}
+
+void IniParser::Section::clear()
+{
+  this->_entries.clear();
+}
+
+void IniParser::Section::debug() const
+{
+  printf(" [%s]\n", this->name().c_str());
+  for(Entry::const_iterator entry = this->_entries.begin(); entry != this->_entries.end(); ++entry)
+    (*entry).debug();
+}
+
+
+
+/// /// /// /// /// /// ///
+/// INI-PARSER DOCUMENT ///
+/// /// /// /// /// /// ///
+IniParser::Document::Document(const std::string& fileName, const std::string& comment)
+    : IniParser::Node(fileName, comment)
+{}
+
+IniParser::Section& IniParser::Document::addSection(const std::string& sectionName, const std::string& comment)
+{
+  Section::iterator section = std::find(this->_sections.begin(), this->_sections.end(), sectionName);
+  if (section == this->_sections.end())
+  {
+    this->_sections.push_back(Section(sectionName, comment));
+    return *(--_sections.end());
+  }
+  else
+    return *section;
+}
+
+bool IniParser::Document::removeSection(const std::string& sectionName)
+{
+  Section::iterator section = std::find(this->_sections.begin(), this->_sections.end(), sectionName);
+  if (section != this->_sections.end())
+  {
+    this->_sections.erase(section);
+    return true;
+  }
+  else
+    return false;
+}
+
+bool IniParser::Document::setSectionComment(const std::string& sectionName, const std::string& comment)
+{
+  Section::iterator section = std::find(this->_sections.begin(), this->_sections.end(), sectionName);
+  if (section != this->_sections.end())
+  {
+    (*section).setComment(comment);
+    return true;
+  }
+  else
+    return false;
+}
+
+
+
+IniParser::Section* IniParser::Document::getSection(const std::string& sectionName)
+{
+  Section::iterator section = std::find(this->_sections.begin(), this->_sections.end(), sectionName);
+  if (section != this->_sections.end())
+  {
+    return &(*section);
+  }
+  else
+    return NULL;
+}
+
+IniParser::Section::const_iterator IniParser::Document::getSectionIt(const std::string& sectionName) const
+{
+  Section::const_iterator section = std::find(this->_sections.begin(), this->_sections.end(), sectionName);
+  return section;
+}
+
+bool IniParser::Document::addEntry(const std::string& sectionName, const std::string& entryName, const std::string& value, const std::string& comment)
+{
+  // locating section
+  Section::iterator section = std::find(this->_sections.begin(), this->_sections.end(), sectionName);
+  if (section == this->_sections.end())
+  {
+    // creating section if not found!!
+    this->_sections.push_back(Section(sectionName));
+    section = --_sections.end();
+  }
+
+  (*section).addEntry(entryName, value, comment);
+  return true;
+}
+
+bool IniParser::Document::editEntry(const std::string& sectionName, const std::string& entryName, const std::string& value, bool createMissing)
+{
+  // locating section
+  Section::iterator section = std::find(this->_sections.begin(), this->_sections.end(), sectionName);
+  if (section == this->_sections.end())
+  {
+    // creating section if not found!!
+    if (createMissing)
+    {
+      this->_sections.push_back(Section(sectionName));
+      section = --_sections.end();
+    }
+    else
+      return false;
+  }
+
+  return (*section).editEntry(entryName, value, createMissing);
+}
+
+const std::string& IniParser::Document::getValue(const std::string& sectionName, const std::string& entryName, const std::string& defaultValue) const
+{
+  // locating section
+  Section::const_iterator section = std::find(this->_sections.begin(), this->_sections.end(), sectionName);
+  if (section != this->_sections.end())
+    return (*section).getValue(entryName, defaultValue);
+  return defaultValue;
+}
+
+bool IniParser::Document::setEntryComment(const std::string& sectionName, const std::string& entryName, const std::string& comment)
+{
+  // locating section
+  Section::iterator section = std::find(this->_sections.begin(), this->_sections.end(), sectionName);
+  if (section != this->_sections.end())
+    return (*section).setEntryComment(entryName, comment);
+  else
+    return false;
+}
+
+const std::string& IniParser::Document::getEntryComment(const std::string& sectionName, const std::string& entryName) const
+{
+  Section::const_iterator section = std::find(this->_sections.begin(), this->_sections.end(), sectionName);
+  if (section != this->_sections.end())
+    return (*section).getEntryComment(entryName);
+  else
+    return IniParser::_emptyString;
+}
+
+void IniParser::Document::clear()
+{
+  this->_sections.clear();
+}
+
+void IniParser::Document::debug() const
+{
+  for(Section::const_iterator section = this->_sections.begin(); section != this->_sections.end(); ++section)
+    (*section).debug();
+}
+
+
+
+
+/// /// /// /// /// /// //
+/// INI-PARSER ITSELF ////
+/// /// /// /// /// /// //
+const std::string IniParser::_emptyString = "";
 /**
  * @brief constructs an IniParser using a file
@@ -42,8 +299,7 @@
  */
 IniParser::IniParser (const std::string& fileName)
-{
-  this->fileName = "";
-  this->comment = "";
-
+    : _document(fileName)
+{
+  this->_fileName = fileName;
   if (!fileName.empty())
     this->readFile(fileName);
@@ -55,40 +311,10 @@
  */
 IniParser::~IniParser ()
-{
-  this->deleteSections();
-  this->setFileName("");
-}
-
-const std::string IniParser::emptyString = "";
-
-
-/**
- * @brief removes all the sections. This is like delete, but even cooler :)
- */
-void IniParser::deleteSections()
-{
-  // in all sections
-  this->sections.clear();
-
-  this->currentSection = this->sections.end();
-  this->setFileName("");
-}
-
-
-/**
- * @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 std::string& fileName)
-{
-  this->comment = "";
-  this->fileName = fileName;
-}
-
+{}
 
 /**
  * @brief opens a file to parse
  * @param fileName: path and name of the new file to parse
+ * @param keepSettings if the Settings (if already some are set) should be kept (false by default)
  * @return true on success false otherwise;
  *
@@ -96,14 +322,13 @@
  * and the new one will be opened.
  */
-bool IniParser::readFile(const std::string& fileName)
+bool IniParser::readFile(const std::string& fileName, bool keepSettings)
 {
   FILE*    stream;           //< The stream we use to read the file.
-  int      lineCount = 0;    //< The Count of lines.
-
-  if (!this->fileName.empty())
-    this->deleteSections();
-
-  if( fileName.empty())
-    return false;
+  int      lineCount = 0;    //< The Count of lines read.
+  std::list<std::string>  commentList;     //< A list of Comments.
+  Section* currentSection = NULL;
+
+  if (!keepSettings)
+    this->_document.clear();
 
   if( (stream = fopen (fileName.c_str(), "r")) == NULL)
@@ -114,5 +339,5 @@
   else
   {
-    this->setFileName(fileName);
+    this->_fileName = fileName;
 
     /////////////////////////////
@@ -143,10 +368,10 @@
       {
         std::string newCommenLine = lineBegin;
-        this->commentList.push_back(newCommenLine);
+        commentList.push_back(newCommenLine);
         continue;
       }
-      if (lineCount == 0 && !this->commentList.empty())
+      if (lineCount == 0 && !commentList.empty())
       {
-        this->setFileComment();
+        this->setNodeComment(&this->_document, &commentList);
         lineCount++;
       }
@@ -158,6 +383,7 @@
         {
           *ptr = 0;
-          this->addSection(buffer);
-          this->setSectionComment();
+          Section& node = this->_document.addSection(buffer);
+          setNodeComment(&node, &commentList);
+          currentSection = &node;
         }
       }
@@ -165,5 +391,5 @@
       else if( (ptr = strchr( lineBegin, '=')) != NULL)
       {
-        if (currentSection == this->sections.end())
+        if (currentSection == NULL)
         {
           PRINTF(2)("Not in a Section yet for %s\n", lineBegin);
@@ -188,6 +414,6 @@
         nameEnd[1] = '\0';
 
-        this->addVar(lineBegin, valueBegin);
-        this->setEntryComment();
+        Entry& node = currentSection->addEntry(lineBegin, valueBegin);
+        this->setNodeComment(&node, &commentList);
 
         lineCount++;
@@ -195,8 +421,4 @@
     }
   }
-  this->currentSection = this->sections.begin();
-  if (!this->sections.empty())
-    this->currentEntry = (*this->currentSection).entries.begin();
-
   fclose(stream);
   return true;
@@ -222,20 +444,20 @@
   else
   {
-    if (!this->comment.empty())
-      fprintf(stream, "%s\n\n", this->comment.c_str());
-
-    std::list<IniSection>::const_iterator section;
-    for (section = this->sections.begin(); section != this->sections.end(); section++)
+    if (!this->_document.comment().empty())
+      fprintf(stream, "%s\n\n", this->_document.comment().c_str());
+
+    Section::const_iterator section;
+    for (section = this->_document.sections().begin(); section != this->_document.sections().end(); ++section)
     {
-      if (!(*section).comment.empty())
-        fprintf(stream, "%s", (*section).comment.c_str());
-      fprintf(stream, "\n [%s]\n", (*section).name.c_str());
-
-      std::list<IniEntry>::const_iterator entry;
-      for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
+      if (!(*section).comment().empty())
+        fprintf(stream, "%s", (*section).comment().c_str());
+      fprintf(stream, "\n [%s]\n", (*section).name().c_str());
+
+      Entry::const_iterator entry;
+      for (entry = (*section).entries().begin(); entry != (*section).entries().end(); ++entry)
       {
-        if (!(*entry).comment.empty())
-          fprintf(stream, "%s", (*entry).comment.c_str());
-        fprintf(stream, "   %s = %s\n", (*entry).name.c_str(), (*entry).value.c_str());
+        if (!(*entry).comment().empty())
+          fprintf(stream, "%s", (*entry).comment().c_str());
+        fprintf(stream, "   %s = %s\n", (*entry).name().c_str(), (*entry).value().c_str());
       }
     }
@@ -247,5 +469,5 @@
 void IniParser::setFileComment(const std::string& fileComment)
 {
-  this->comment = fileComment;
+  this->_document.setComment(fileComment);
 }
 
@@ -256,94 +478,7 @@
  * @return true on success... there is only success or segfault :)
  */
-bool IniParser::addSection(const std::string& sectionName)
-{
-  if (sectionName.empty())
-    return false;
-  IniSection newSection;
-  newSection.name = sectionName;
-  newSection.comment = "";
-
-  this->sections.push_back(newSection);
-
-  this->currentSection = --this->sections.end();
-  if (!this->sections.empty())
-    this->currentEntry = (*this->currentSection).entries.begin();
-  PRINTF(5)("Added Section %s\n", sectionName.c_str());
-  return true;
-}
-
-
-/**
- * @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
- */
-bool IniParser::getSection(const std::string& sectionName)
-{
-  this->currentSection = this->getSectionIT(sectionName);
-  if (this->currentSection != this->sections.end())
-  {
-    this->currentEntry = (*this->currentSection).entries.begin();
-    return true;
-  }
-  else
-    return false;
-}
-
-/**
- *
- */
-void IniParser::setSectionComment(const std::string& comment, const std::string& sectionName)
-{
-  std::list<IniSection>::iterator section = this->getSectionIT(sectionName);
-  if (section == this->sections.end())
-    return;
-
-  (*section).comment = comment;
-}
-
-/**
- * @param sectionName the Section to query for
- * @returns the Comment, or NULL on error.
- */
-const std::string& IniParser::getSectionComment(const std::string& sectionName) const
-{
-  std::list<IniSection>::const_iterator section = this->getSectionIT(sectionName);
-  if (section != this->sections.end())
-    return (*section).comment;
-  else
-    return IniParser::emptyString;
-}
-
-
-/**
- * @brief moves to the first section
- */
-void IniParser::firstSection()
-{
-  this->currentSection = this->sections.begin();
-  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
- */
-const std::string& IniParser::nextSection()
-{
-  if (this->currentSection == this->sections.end())
-    return IniParser::emptyString;
-
-  this->currentSection++;
-
-  if (this->currentSection != this->sections.end())
-  {
-    this->currentEntry = (*this->currentSection).entries.begin();
-    return this->currentSection->name;
-  }
-  else
-    return IniParser::emptyString;
+IniParser::Section& IniParser::addSection(const std::string& sectionName)
+{
+  return this->_document.addSection(sectionName);
 }
 
@@ -356,40 +491,9 @@
  * otherwise to the section refered to by sectionName.
  * If both are NULL no entry will be added
- * @return true if everything is ok false on error
- */
-bool IniParser::addVar(const std::string& entryName, const std::string& value, const std::string& sectionName)
-{
-  std::list<IniSection>::iterator section;
-
-  if (!sectionName.empty())
-  {
-    for (section = this->sections.begin(); section != this->sections.end(); section++)
-      if ((*section).name == sectionName)
-        break;
-  }
-  else
-    section = this->currentSection;
-
-  if (section == this->sections.end())
-    return false;
-
-  if (section == this->sections.end())
-  {
-    PRINTF(2)("section '%s' not found for value '%s'\n", sectionName.c_str(), entryName.c_str());
-    return false;
-  }
-  else
-  {
-    (*section).entries.push_back(IniEntry());
-    (*section).entries.back().comment = "";
-    (*section).entries.back().name = entryName;
-    (*section).entries.back().value = value;
-    PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n",
-              (*section).entries.back().name.c_str(),
-              (*section).entries.back().value.c_str(),
-              (*section).name.c_str());
-    this->currentEntry = --(*section).entries.end();
-    return true;
-  }
+ * @return The Entry, that was added.
+ */
+bool IniParser::addEntry(const std::string& sectionName, const std::string& entryName, const std::string& value, const std::string& comment)
+{
+  return this->_document.addEntry(sectionName, entryName, value, comment);
 }
 
@@ -403,53 +507,7 @@
  * @return true if everything is ok false on error
  */
-bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName, bool createMissing)
-{
-  std::list<IniSection>::iterator section;
-
-  if (!sectionName.empty())
-  {
-    for (section = this->sections.begin(); section != this->sections.end(); section++)
-      if ((*section).name == sectionName)
-        break;
-  }
-  else
-    section = this->currentSection;
-
-  if (section == this->sections.end())
-  {
-    this->addSection(sectionName);
-    for (section = this->sections.begin(); section != this->sections.end(); section++)
-      if ((*section).name == sectionName)
-        break;
-  }
-
-  //try find item
-  std::list<IniEntry>::iterator entry;
-  for (entry = section->entries.begin(); entry!=section->entries.end(); entry++)
-    if (entry->name == entryName )
-      break;
-
-  //found it?
-  if ( entry != section->entries.end() )
-  {
-    entry->value = value;
-
-    return true;
-  }
-  else
-  {
-    //not found -> create it
-    (*section).entries.push_back(IniEntry());
-    (*section).entries.back().comment = "";
-    (*section).entries.back().name = entryName;
-    (*section).entries.back().value = value;
-    PRINTF(5)("Added Entry '%s' with Value '%s' to Section '%s'\n",
-              (*section).entries.back().name.c_str(),
-              (*section).entries.back().value.c_str(),
-              (*section).name.c_str());
-    this->currentEntry = --(*section).entries.end();
-    return true;
-  }
-  return false;
+bool IniParser::editEntry(const std::string& sectionName, const std::string& entryName, const std::string& value, bool createMissing)
+{
+  return this->_document.editEntry(sectionName, entryName, value, createMissing);
 }
 
@@ -457,25 +515,12 @@
 /**
  * @brief directly acesses an entry in a section
+ * @param sectionName: the section where the entry is to be found
  * @param entryName: the name of the entry to find
- * @param sectionName: the section where the entry is to be found
  * @param defaultValue: what should be returned in case the entry cannot be found
- * @return a pointer to a buffer conatining the value of the specified entry. This buffer will contain the data specified in defvalue in case the entry wasn't found
- *
- *  The returned pointer points to an internal buffer, so do not free it on your own. Do not give a NULL pointer to defvalue, this will certainly
- * lead to unwanted behaviour.
-*/
-const std::string& IniParser::getVar(const std::string& entryName, const std::string& sectionName, const std::string& defaultValue) const
-{
-  if (!this->fileName.empty())
-  {
-    std::list<IniEntry>::const_iterator entry = this->getEntryIT(entryName, sectionName);
-    if (/** FIXME entry != NULL && */  (*entry).name == entryName)
-      return (*entry).value;
-    PRINTF(2)("Entry '%s' in section '%s' not found.\n", entryName.c_str(), sectionName.c_str());
-  }
-  else
-    PRINTF(2)("no File opened\n");
-
-  return defaultValue;
+ * @return The Value of the Entry.
+ */
+const std::string& IniParser::getValue(const std::string& sectionName, const std::string& entryName, const std::string& defaultValue) const
+{
+  return this->_document.getValue(sectionName, entryName, defaultValue);
 }
 
@@ -486,8 +531,7 @@
  * @param sectionName the Name of the Section
  */
-void IniParser::setEntryComment(const std::string& comment, const std::string& entryName, const std::string& sectionName)
-{
-  std::list<IniEntry>::iterator entry = this->getEntryIT(entryName, sectionName);
-  (*entry).comment = comment;
+void IniParser::setEntryComment(const std::string& sectionName, const std::string& entryName, const std::string& comment)
+{
+  this->_document.setEntryComment(sectionName, entryName, comment);
 }
 
@@ -497,217 +541,8 @@
  * @returns the queried Comment.
  */
-const std::string& IniParser::getEntryComment(const std::string& entryName, const std::string& sectionName) const
-{
-  std::list<IniEntry>::const_iterator entry = this->getEntryIT(entryName, sectionName);
-
-  return (*entry).comment;
-}
-
-
-/**
- * @brief moves to the first Variable of the current Section
- */
-void IniParser::firstVar()
-{
-  if (!this->sections.empty() &&
-      this->currentSection != this->sections.end())
-    this->currentEntry = (*this->currentSection).entries.begin();
-}
-
-
-/**
- * @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->sections.empty()
-       || this->currentSection == this->sections.end()
-       || this->currentEntry == (*this->currentSection).entries.end())
-    return false;
-
-  this->currentEntry++;
-
-  if (this->currentEntry == (*this->currentSection).entries.end())
-    return false;
-  else
-    return true;
-}
-
-
-
-/**
- * @returns the name of the Current selected Section
- */
-const std::string& IniParser::getCurrentSection() const
-{
-  if (!this->sections.empty() &&
-      this->currentSection != this->sections.end())
-    return this->currentSection->name;
-  else
-    return IniParser::emptyString ;
-}
-
-
-/**
- * @returns the current entries Name, or NULL if we havn't selected a Entry
- */
-const std::string& IniParser::getCurrentName() const
-{
-  if (!this->sections.empty() &&
-      this->currentSection != this->sections.end() &&
-      this->currentEntry != (*this->currentSection).entries.end())
-    return (*this->currentEntry).name;
-  else
-    return emptyString;
-}
-
-/**
- * @returns the current entries Value, or NULL if we havn't selected a Entry
- */
-const std::string& IniParser::getCurrentValue() const
-{
-  if (!this->sections.empty() &&
-      this->currentSection != this->sections.end() &&
-      this->currentEntry != (*this->currentSection).entries.end())
-    return (*this->currentEntry).value;
-  else
-    return IniParser::emptyString;
-}
-
-
-/**
- * Finds the Section Iterator of the Section Called sectionName
- * @param sectionName the Name of the Section to get the Iterator from
- */
-std::list<IniParser::IniSection>::const_iterator IniParser::getSectionIT(const std::string& sectionName) const
-{
-  std::list<IniSection>::const_iterator section = this->currentSection;
-  if (sectionName.empty())
-    return this->currentSection;
-  else
-    for (section = this->sections.begin(); section != this->sections.end(); section++)
-      if ((*section).name == sectionName)
-        break;
-  return section;
-}
-
-
-/**
- * Finds the Section Iterator of the Section Called sectionName
- * @param sectionName the Name of the Section to get the Iterator from
- */
-std::list<IniParser::IniSection>::iterator IniParser::getSectionIT(const std::string& sectionName)
-{
-  std::list<IniSection>::iterator section = this->currentSection;
-  if (sectionName.empty())
-    return this->currentSection;
-  else
-    for (section = this->sections.begin(); section != this->sections.end(); section++)
-      if ((*section).name == sectionName)
-        break;
-  return section;
-}
-
-
-/**
- * Finds the Entry Iterator of the Section Called sectionName and entry called EntryName
- * @param entryName the Name of the Entry to get the Iterator from
- * @param sectionName the Name of the Section to get the Iterator from
- */
-std::list<IniParser::IniEntry>::const_iterator IniParser::getEntryIT(const std::string& entryName, const std::string& sectionName) const
-{
-  if (entryName.empty())
-    return this->currentEntry;
-  std::list<IniSection>::const_iterator section = this->getSectionIT(sectionName);
-  std::list<IniEntry>::const_iterator entry = this->currentEntry;
-
-  if (section != this->sections.end())
-    for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
-      if ((*entry).name == entryName)
-        break;
-  return entry;
-}
-
-
-/**
- * Finds the Entry Iterator of the Section Called sectionName and entry called EntryName
- * @param entryName the Name of the Entry to get the Iterator from
- * @param sectionName the Name of the Section to get the Iterator from
- */
-std::list<IniParser::IniEntry>::iterator IniParser::getEntryIT(const std::string& entryName, const std::string& sectionName)
-{
-  if (entryName.empty())
-    return this->currentEntry;
-  std::list<IniSection>::iterator section = this->getSectionIT(sectionName);
-  std::list<IniEntry>::iterator entry = this->currentEntry;
-
-  if (section != this->sections.end())
-    for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
-      if ((*entry).name == entryName)
-        break;
-  return entry;
-}
-
-
-/**
- * takes lines together to form one FileComment, ereasing the commentList
- */
-void IniParser::setFileComment()
-{
-  if (this->commentList.empty())
-  {
-    this->comment = "";
-    return;
-  }
-
-  std::list<char*>::iterator comment;
-
-  while (!this->commentList.empty())
-  {
-    if (this->comment[0] != '\0')
-      this->comment += "\n";
-    this->comment += this->commentList.front();
-    this->commentList.pop_front();
-  }
-}
-
-/**
- * takes lines together to form one SectionComment, ereasing the commentList
- */
-void IniParser::setSectionComment()
-{
-  (*this->currentSection).comment = "";
-
-  if (this->commentList.empty())
-    return;
-
-  while (!this->commentList.empty())
-  {
-    if ((*this->currentSection).comment[0] != '\0')
-      (*this->currentSection).comment += "\n";
-    (*this->currentSection).comment += this->commentList.front();
-    this->commentList.pop_front();
-  }
-}
-
-/**
- * takes lines together to form one EntryComment, ereasing the commentList
- */
-void IniParser::setEntryComment()
-{
-  (*this->currentEntry).comment = "";
-  if (this->commentList.empty())
-    return;
-
-  while (!this->commentList.empty())
-  {
-    if ((*this->currentEntry).comment[0] != '\0')
-      (*this->currentEntry).comment += "\n";
-    (*this->currentEntry).comment += this->commentList.front();
-    this->commentList.pop_front();
-  }
-}
-
+const std::string& IniParser::getEntryComment(const std::string& sectionName, const std::string& entryName) const
+{
+  return this->_document.getEntryComment(sectionName, entryName);
+}
 
 /**
@@ -716,33 +551,40 @@
 void IniParser::debug() const
 {
-  PRINT(0)("Iniparser '%s' - debug\n", this->fileName.c_str());
-  if (!this->comment.empty())
-    PRINT(0)("FileComment:\n '%s'\n\n", this->comment.c_str());
-
-  if (!this->fileName.empty())
-  {
-    if (sections.empty())
-      PRINT(0)("No Sections defined\n");
-    std::list<IniSection>::const_iterator section;
-    for (section = this->sections.begin(); section != this->sections.end(); section++)
+  PRINT(0)("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());
+
+  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
+ */
+void IniParser::setNodeComment(Node* node, std::list<std::string>* comments)
+{
+  assert(node != NULL);
+  assert(comments != NULL);
+
+  std::string comment;
+  if (comments->empty())
+  {
+    comment = "";
+  }
+  else
+  {
+    while (!comments->empty())
     {
-      if (!(*section).comment.empty())
-        PRINTF(0)(" %s\n", (*section).comment.c_str());
-      PRINTF(0)(" [%s]\n", (*section).name.c_str());
-
-      if ((*section).entries.empty())
-        PRINT(0)("No Entries defined within Section '%s'\n", (*section).name.c_str());
-
-      std::list<IniEntry>::const_iterator entry;
-      for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
-      {
-        if (!(*entry).comment.empty())
-          PRINTF(0)(" %s\n", (*entry).comment.c_str());
-        PRINTF(0)("   '%s' -> '%s'\n", (*entry).name.c_str(), (*entry).value.c_str());
-      }
+      if (!comment.empty())
+        comment += "\n";
+      comment += comments->front();
+      comments->pop_front();
     }
   }
-  else
-    PRINTF(0)("no opened ini-file.\n");
-}
-
+  node->setComment(comment);
+}
+
+
Index: /trunk/src/lib/parser/ini_parser/ini_parser.h
===================================================================
--- /trunk/src/lib/parser/ini_parser/ini_parser.h	(revision 9879)
+++ /trunk/src/lib/parser/ini_parser/ini_parser.h	(revision 9880)
@@ -11,5 +11,5 @@
 #define PARSELINELENGHT     512       //!< how many chars to read at once
 
-#include "lib/util/filesys/file.h"
+#include <string>
 #include <list>
 
@@ -18,96 +18,165 @@
  * This class can be used to load an initializer file and parse it's contents for variablename=value pairs.
  */
-class IniParser : public File
+class IniParser
 {
+public:
+  ////////////////////////////////////
+  /// A Node for a Ini-Node. The base of all INI-elements.
+  class Node
+  {
+  public:
+    Node(const std::string& name, const std::string& comment = "");
+    virtual ~Node() {};
+    const std::string& name() const  { return _name; };
+    const std::string& comment() const  { return _comment; };
+    void setName(const std::string& name) { this->_name = name; };
+    void setComment(const std::string& comment) { this->_comment = comment; };
+
+    bool operator==(const std::string& name) const { return _name == name; };
+    bool operator==(const Node& node) const { return this->_name == node._name; };
+
+    virtual void debug() const = 0;
+
   private:
-    ////////////////////////////////////
-    //! a struct for Entries in the Parser's File's Sections
-    struct IniEntry
-    {
-      std::string         comment;  //!< A Comment that is appendet to the Top of this Entry.
-      std::string         name;     //!< name of a given Entry
-      std::string         value;    //!< value of a given Entry
-    };
+    std::string         _comment;  //!< A Comment that is appendet to the Top of this Node
+    std::string         _name;     //!< name of a given Node
+  };
 
-    //! a struct for Sections in the Parser's file
-    struct IniSection
-    {
-      std::string         comment;  //!< A Comment that is appendet to the Top of this Section.
-      std::string         name;     //!< name of a given section
-      std::list<IniEntry> entries;  //!< a list of entries for this section
-    };
-    ////////////////////////////////////
+  //! a class for Entries in the Parser's File's Sections
+class Entry : public Node
+  {
+  public:
+    Entry(const std::string& name, const std::string& value = "", const std::string& comment = "");
+    const std::string& value() const { return _value; };
+    void setValue (const std::string& value) { _value = value; };
+
+    virtual void debug() const;
 
   public:
-    IniParser (const std::string& filename = "");
-    virtual ~IniParser ();
-
-    /** @returns true if the file is opened, false otherwise*/
-    bool isOpen() const { return true; } ///HACK //(this->fileName.empty()) ? false : true; };
-    /** @returns the fileName we have opened. */
-    const std::string& getFileName() const { return this->fileName; };
-
-    bool readFile(const std::string& fileName);
-    bool writeFile(const std::string& fileName) const;
-
-    void setFileComment(const std::string& fileComment);
-    const std::string& getFileComment() const { return this->comment; };
-
-    bool addSection(const std::string& sectionName);
-    bool getSection(const std::string& sectionName);
-    void setSectionComment(const std::string& comment, const std::string& sectionName);
-    const std::string& getSectionComment(const std::string& sectionNane) const;
-
-    // iterate through sections with these Functions
-    void firstSection();
-    const std::string& nextSection();
-
-
-    bool addVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "" );
-    const std::string& getVar(const std::string& entryName, const std::string& sectionName, const std::string& defaultValue = "") const;
-    bool editVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "", bool createMissing = true);
-    void setEntryComment(const std::string& comment, const std::string& entryName, const std::string& sectionName);
-    const std::string& getEntryComment(const std::string& entryName, const std::string& sectionName) const;
-
-    // iterate Through Variables with these Functions.
-    void firstVar();
-    bool nextVar();
-
-
-    // retrieving functions when iterating.
-    const std::string& getCurrentSection() const;
-    const std::string& getCurrentName() const;
-    const std::string& getCurrentValue() const;
-
-
-    // maintenance.
-    void debug() const;
-
+    typedef std::list<Entry>                    list;
+    typedef list::iterator                      iterator;
+    typedef list::const_iterator                const_iterator;
 
   private:
-    void deleteSections();
-    void setFileName(const std::string& fileName);
+    std::string         _value;    //!< value of a given Entry
+  };
 
-    void setFileComment();
-    void setSectionComment();
-    void setEntryComment();
+  //! a clas for Sections in the Parser's file
+class Section : public Node
+  {
+  public:
+    Section(const std::string& sectionName, const std::string& comment = "");
 
-    std::list<IniSection>::const_iterator getSectionIT(const std::string& sectionName) const;
-    std::list<IniSection>::iterator getSectionIT(const std::string& sectionName);
+    Entry& addEntry(const std::string& entryName, const std::string& value = "", const std::string& comment = "");
+    bool editEntry(const std::string& entryName, const std::string& value, bool createMissing = true);
+    const std::string& getValue(const std::string& entryName, const std::string& defaultValue = "") const;
 
-    std::list<IniEntry>::const_iterator getEntryIT(const std::string& entryName, const std::string& sectionName = "") const;
-    std::list<IniEntry>::iterator getEntryIT(const std::string& entryName, const std::string& sectionName = "");
+    bool setEntryComment(const std::string& entryName, const std::string& comment);
+    const std::string& getEntryComment(const std::string& entryName) const;
+
+    const Entry::list& entries() const { return _entries; }
+    Entry* getEntry(const std::string& entryName);
+
+    Entry::const_iterator getEntryIt(const std::string& entryName) const;
+    Entry::iterator begin() { return _entries.begin(); };
+    Entry::const_iterator begin() const { return _entries.begin(); };
+    Entry::iterator end() { return _entries.end(); };
+    Entry::const_iterator end() const { return _entries.end(); };
+
+    void clear();
+
+    virtual void debug() const;
+
+  public:
+    typedef std::list<Section>                  list;
+    typedef list::iterator                      iterator;
+    typedef list::const_iterator                const_iterator;
 
   private:
-    std::string                      fileName;        //!< The name of the File that was parsed.
-    std::string                      comment;         //!< A Comment for the header of this File.
-    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)
+    Entry::list     _entries;  //!< a list of entries for this section
+  };
 
-    std::list<std::string>           commentList;     //!< A list of Comments. (this is for temporary saving of Comments, that are inserted in front of Sections/Entries.)
+  //! A class for a INI-file.
+class Document : public Node
+  {
+  public:
+    Document(const std::string& fileName, const std::string& comment = "");
 
+    Section& addSection(const std::string& sectionName, const std::string& comment = "");
+    bool removeSection(const std::string& sectionName);
+    bool setSectionComment(const std::string& sectionName, const std::string& comment);
 
-    static const std::string         emptyString;
+    const Section::list& sections() const { return _sections; }
+    Section* getSection(const std::string& sectionName);
+
+    Section::const_iterator getSectionIt(const std::string& sectionName) const;
+    Section::iterator begin() { return _sections.begin(); };
+    Section::const_iterator begin() const { return _sections.begin(); };
+    Section::iterator end() { return _sections.end(); };
+    Section::const_iterator end() const { return _sections.end(); };
+
+    bool addEntry(const std::string& sectionName, const std::string& entryName, const std::string& value = "", const std::string& comment = "");
+    bool editEntry(const std::string& sectionName, const std::string& entryName, const std::string& value, bool createMissing = true);
+    const std::string& getValue(const std::string& sectionName, const std::string& entryName, const std::string& defaultValue = "") const;
+
+    bool setEntryComment(const std::string& sectionName, const std::string& entryName, const std::string& comment);
+    const std::string& getEntryComment(const std::string& sectionName, const std::string& entryName) const;
+
+    void clear();
+
+    virtual void debug() const;
+
+  private:
+    Section::list            _sections;        //!< a list of all stored Sections of the Parser.
+  };
+
+public:
+  IniParser (const std::string& filename = "");
+  virtual ~IniParser ();
+
+  /** @returns true if the file is opened, false otherwise */
+  bool isOpen() const { return !this->_document.sections().empty(); };
+  /** @returns the fileName we have opened. */
+  const std::string& getFileName() const { return this->_document.name(); };
+
+  /// Read and Write the File
+  bool readFile(const std::string& fileName, bool keepSettings = false);
+  bool writeFile(const std::string& fileName) const;
+
+  void setFileComment(const std::string& fileComment);
+  const std::string& getFileComment() const { return this->_document.comment(); };
+
+  /// Woring with Sections.
+  Section& addSection(const std::string& sectionName);
+  // iterate through sections with these Functions
+  Section* getSection(const std::string& sectionName) { return this->_document.getSection(sectionName); };
+  Section::const_iterator getSectionIt(const std::string& sectionName) const;
+
+  Section::iterator begin() { return this->_document.begin(); };
+  Section::const_iterator begin() const { return this->_document.begin(); };
+  Section::iterator end() { return this->_document.end(); };
+  Section::const_iterator end() const { return this->_document.end(); };
+
+  void setSectionComment(const std::string& sectionName, const std::string& comment);
+  const std::string& getSectionsComment(const std::string& sectionNane) const;
+
+  /// Working on Entries. (globally)
+  bool addEntry(const std::string& sectionName, const std::string& entryName, const std::string& value, const std::string& comment);
+  const std::string& getValue(const std::string& sectionNmae, const std::string& entryName, const std::string& defaultValue = "") const;
+  bool editEntry(const std::string& sectionName, const std::string& entryName, const std::string& value, bool createMissing = true);
+
+  void setEntryComment(const std::string& sectionName, const std::string& entryName, const std::string& comment);
+  const std::string& getEntryComment(const std::string& sectionName, const std::string& entryName) const;
+
+  // maintenance.
+  void debug() const;
+
+private:
+  void setNodeComment(Node* node, std::list<std::string>* comments);
+private:
+  std::string                      _fileName;
+  Document                         _document;
+
+  static const std::string         _emptyString;     //!< Just an Empty String that will be returned if nothing else is found.
 };
 
Index: /trunk/src/lib/parser/preferences/ini_file_prefs_reader.cc
===================================================================
--- /trunk/src/lib/parser/preferences/ini_file_prefs_reader.cc	(revision 9879)
+++ /trunk/src/lib/parser/preferences/ini_file_prefs_reader.cc	(revision 9880)
@@ -28,21 +28,19 @@
   IniParser iniParser;
 
-  
+
   Preferences* prefs = Preferences::getInstance();
-  
+
   prefs->setUserIni( fileName );
-  
+
   if ( !iniParser.readFile( fileName ) )
     return;
 
-  iniParser.firstSection();
-
-  do
-  {
-    do
-    {
-      prefs->setString( iniParser.getCurrentSection(), iniParser.getCurrentName(), iniParser.getCurrentValue(), true );
-    } while (iniParser.nextVar());
-  } while ( iniParser.nextSection() != "" );
+  for(IniParser::Section::iterator section = iniParser.begin();
+      section != iniParser.end();
+      ++section)
+    for (IniParser::Entry::iterator entry = (*section).begin();
+         entry != (*section).end();
+         ++entry)
+      prefs->setString( (*section).name(), (*entry).name(), (*entry).value(), true );
 
   /*iniParser.firstVar();
@@ -53,5 +51,5 @@
   {
     prefs->setString( iniParser.getCurrentSection(), iniParser.getCurrentName(), iniParser.getCurrentValue(), true );
-}*/
+  }*/
 }
 
@@ -61,6 +59,5 @@
 */
 IniFilePrefsReader::~IniFilePrefsReader ()
-{
-}
+{}
 
 
Index: /trunk/src/lib/parser/preferences/ini_file_prefs_reader.h
===================================================================
--- /trunk/src/lib/parser/preferences/ini_file_prefs_reader.h	(revision 9879)
+++ /trunk/src/lib/parser/preferences/ini_file_prefs_reader.h	(revision 9880)
@@ -8,5 +8,5 @@
 
 #include "lib/parser/ini_parser/ini_parser.h"
-#include "lib/parser/preferences/preferences.h"
+#include "preferences.h"
 
 
Index: /trunk/src/lib/parser/preferences/preferences.cc
===================================================================
--- /trunk/src/lib/parser/preferences/preferences.cc	(revision 9879)
+++ /trunk/src/lib/parser/preferences/preferences.cc	(revision 9880)
@@ -271,5 +271,5 @@
       if ( it2->modified )
       {
-        iniParser.editVar(it2->name, it2->value.getString(), it->sectionName);
+	iniParser.editEntry(it->sectionName, it2->name, it2->value.getString());
         didChanges = true;
       }
Index: /trunk/src/orxonox.cc
===================================================================
--- /trunk/src/orxonox.cc	(revision 9879)
+++ /trunk/src/orxonox.cc	(revision 9880)
@@ -337,6 +337,6 @@
 
   // init the resource manager
-  std::string dataPath;
-  if ((dataPath = Preferences::getInstance()->getString(CONFIG_SECTION_GENERAL, CONFIG_NAME_DATADIR, ""))!= "")
+  std::string dataPath = Preferences::getInstance()->getString(CONFIG_SECTION_GENERAL, CONFIG_NAME_DATADIR, "");
+  if (dataPath!= "")
   {
     Resources::ResourceManager::getInstance()->setMainGlobalPath(dataPath) ;
