Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 1 (modified by landauf, 17 years ago) (diff)

IniParser

The ini-parser does what it is called, and more…

it is a very simple library, that allows two things, reading ini-files, and writing them. files:

Known functions

    bool readFile(const char* fileName);
    bool writeFile(const char* fileName);

    bool addSection(const char* sectionName);
    bool getSection(const char* sectionName);

    bool addVar(const char* entryName, const char* value, const char* sectionName = NULL);
    const char* getVar(const char* entryName, const char* sectionName, const char* defaultValue = "") const;

with those you can do almost everything. Althought, if you want to iterate through a File, and parsing all the good stuff, do something like:

  #include "ini_parser.h"

  .
  .
  .

  IniParser iniParser("someFile");
  if (!iniParser.isOpen())
    return;

  iniParser.getFirstSection();
  while (iniParser.getCurrentSection())
  {
     /// SECTION SPECIFIC STUFF
    iniParser.getFirstVar();
    while(iniParser.getCurrentName())
    {
     /// VARIABLE SPECIFI STUFF
     iniParser.nextVar();
    }

    iniParser.nextSection();
  }