IniParser Class Reference

Parser object for .ini file. More...

#include <iniparser.h>

List of all members.

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.


Detailed Description

Parser object for .ini file.

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.

Author:
julien.pilet@epfl.ch

Definition at line 60 of file iniparser.h.


Member Typedef Documentation

typedef std::vector<IniSection *> IniParser::IniSectionVector

Definition at line 92 of file iniparser.h.


Constructor & Destructor Documentation

IniParser::IniParser ( void *  userdata  ) 

Parameters:
the FptTracker object supposed to be initialized with the .ini file.

Definition at line 39 of file iniparser.cpp.


Member Function Documentation

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.

Returns:
true on success false on error.

Definition at line 123 of file iniparser.cpp.

Referenced by main(), and wparse().

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  ) 

Definition at line 128 of file iniparser.cpp.

References errorPrint(), and parse().


Member Data Documentation

char IniParser::buffer[LOADER_BUFFER_LENGTH]

const char* IniParser::filename

the .ini file name.

Definition at line 100 of file iniparser.h.

Referenced by parse(), and printError().

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().

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.


The documentation for this class was generated from the following files:

Generated on Tue Mar 30 15:53:25 2010 for Polyora by  doxygen 1.5.9