lbm_reference
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
confparser::ConfParser Class Reference

Parser for hierarchical configuration files. More...

#include <confparser/ConfParser.h>

+ Collaboration diagram for confparser::ConfParser:

Public Member Functions

 ConfParser ()
 Constructor. More...
 
ConfBlockparse (std::string configFileName) throw ( BadSyntax )
 Parse a given configuration file. More...
 
virtual ~ConfParser ()
 Destructor. More...
 

Protected Member Functions

int parse_rec (ConfBlock *currBlock, int level, int nLine, std::ifstream &configFile, const std::string &configFileName)
 Recursively parse a specific block. More...
 

Protected Attributes

ConfBlock outermost_
 Root block of the parse tree that is built, will be returned by parse. More...
 

Detailed Description

Parser for hierarchical configuration files.

Parses hierarchical configuration files of the following structure:

key0 value0;
...
block0 {
key1 value1;
...
subblock0 {
key2 value2;
...
}
subblock1 {
key3 value3;
...
}
...
}
block1 {
...
}
...

The parsing result is a tree structure of ConfBlock objects and the actual key-value pairs are stored in a std::map.

Definition at line 128 of file ConfParser.h.

Constructor & Destructor Documentation

confparser::ConfParser::ConfParser ( )
inline

Constructor.

Initializes root as empty block.

Definition at line 140 of file ConfParser.h.

virtual confparser::ConfParser::~ConfParser ( )
inlinevirtual

Destructor.

Does nothing

Definition at line 146 of file ConfParser.h.

Member Function Documentation

ConfBlock & confparser::ConfParser::parse ( std::string  configFileName) throw ( BadSyntax )

Parse a given configuration file.

Parameters
[in]configFileNamePath to the configuration file to parse
Exceptions
BadSyntax

Definition at line 19 of file ConfParser.cpp.

Referenced by main(), and particles::ParticleSystem::ParticleSystem().

int confparser::ConfParser::parse_rec ( ConfBlock currBlock,
int  level,
int  nLine,
std::ifstream &  configFile,
const std::string &  configFileName 
)
protected

Recursively parse a specific block.

Parameters
[in]currBlockPointer to current block
[in]levelNesting depth of current block
[in]nLineCurrent line in the configuration file
[in]configFileStream to write out to
[in]configFileNameName of the configuration file parsed

Definition at line 36 of file ConfParser.cpp.

References confparser::ConfBlock::addChild(), and confparser::ConfBlock::addParam().

Member Data Documentation

ConfBlock confparser::ConfParser::outermost_
protected

Root block of the parse tree that is built, will be returned by parse.

Definition at line 181 of file ConfParser.h.


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