Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 4 (modified by landauf, 7 years ago) (diff)

IniParser

This is an archived page!
This page is very old and the content is not up to date.
Not everything (if any) which is written here will be in the final game!

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();
  }