#include <iniparser.h>
Public Types | |
typedef std::vector< IniSection * > | IniSectionVector |
Public Member Functions | |
DLLEXPORT | IniParser (void *userdata) |
DLLEXPORT bool | parse (const char *filename) |
Parse and process a .ini file. | |
DLLEXPORT bool | wparse (const wchar_t *filename) |
DLLEXPORT bool | parse (FILE *f) |
int | getChar () |
Lexical analyser : get a character, removing comments and counting lines. | |
bool | nextToken () |
Get a token. | |
DLLEXPORT void | addSection (IniSection *section) |
registers a section. | |
void | printError (const char *err) |
print an error, prefixing with the current .ini file name and line and column counters. | |
bool | readNextSection () |
DLLEXPORT bool | dumpExampleFile (const char *filename) |
write an example .ini file to disk. | |
Public Attributes | |
FILE * | in |
the .ini file. Should be accessed through nextToken() and buffer. | |
IniSectionVector | sections |
char | buffer [LOADER_BUFFER_LENGTH] |
Contains the last token parsed by nextToken(). | |
const char * | filename |
the .ini file name. | |
void * | userdata |
this pointer is here only to be passed to the IniSection objects. |
An IniParser object represents the grammar and lexical structure of a .ini file, in addition to instructions to handle parsed data.
The structure of an .ini file is separated into sections (IniSection) having their own structure.
Once a section is created, it is registered with addSection. After that, parse() will be able to parse the file according to described structure. The sections are responsible to make use of parsed data.
Definition at line 60 of file iniparser.h.
typedef std::vector<IniSection *> IniParser::IniSectionVector |
Definition at line 92 of file iniparser.h.
IniParser::IniParser | ( | void * | userdata | ) |
the | FptTracker object supposed to be initialized with the .ini file. |
Definition at line 39 of file iniparser.cpp.
DLLEXPORT void IniParser::addSection | ( | IniSection * | section | ) | [inline] |
registers a section.
Definition at line 87 of file iniparser.h.
References sections.
Referenced by VideoSourceFactory::registerParameters().
bool IniParser::dumpExampleFile | ( | const char * | filename | ) |
write an example .ini file to disk.
Definition at line 218 of file iniparser.cpp.
References sections.
Referenced by main().
int IniParser::getChar | ( | ) |
Lexical analyser : get a character, removing comments and counting lines.
Definition at line 53 of file iniparser.cpp.
References in.
Referenced by nextToken().
bool IniParser::nextToken | ( | ) |
Get a token.
Example: singlewordtoken, "a token with spaces" Special one character tokens: = [ ] The token is stored in IniParser::buffer.
Definition at line 66 of file iniparser.cpp.
References buffer, getChar(), in, and LOADER_BUFFER_LENGTH.
Referenced by ParamSection::parse(), parse(), and readNextSection().
bool IniParser::parse | ( | FILE * | f | ) |
Definition at line 145 of file iniparser.cpp.
References buffer, errorPrint(), filename, in, nextToken(), printError(), and readNextSection().
bool IniParser::parse | ( | const char * | filename | ) |
Parse and process a .ini file.
Definition at line 123 of file iniparser.cpp.
void IniParser::printError | ( | const char * | err | ) |
print an error, prefixing with the current .ini file name and line and column counters.
Definition at line 177 of file iniparser.cpp.
References buffer, errorPrint(), and filename.
Referenced by ParamSection::IntParam::parse(), ParamSection::BoolParam::parse(), ParamSection::DoubleParam::parse(), ParamSection::parse(), parse(), and readNextSection().
bool IniParser::readNextSection | ( | ) |
Definition at line 186 of file iniparser.cpp.
References buffer, nextToken(), printError(), and sections.
Referenced by parse().
bool IniParser::wparse | ( | const wchar_t * | filename | ) |
char IniParser::buffer[LOADER_BUFFER_LENGTH] |
Contains the last token parsed by nextToken().
Definition at line 97 of file iniparser.h.
Referenced by nextToken(), ParamSection::IntParam::parse(), ParamSection::StringParam::parse(), ParamSection::BoolParam::parse(), ParamSection::DoubleParam::parse(), ParamSection::parse(), parse(), printError(), and readNextSection().
const char* IniParser::filename |
the .ini file name.
Definition at line 100 of file iniparser.h.
Referenced by parse(), and printError().
FILE* IniParser::in |
the .ini file. Should be accessed through nextToken() and buffer.
Definition at line 90 of file iniparser.h.
Referenced by getChar(), nextToken(), and parse().
Definition at line 94 of file iniparser.h.
Referenced by addSection(), dumpExampleFile(), and readNextSection().
void* IniParser::userdata |
this pointer is here only to be passed to the IniSection objects.
The IniParser class does not touch it.
Definition at line 110 of file iniparser.h.