lbm_reference
|
Data structure corresponding to one block in the hierarchical configuration file. More...
#include <confparser/ConfBlock.h>
Public Types | |
typedef std::multimap < std::string, ConfBlock > ::iterator | childIter |
Iterator type for the children of the block. More... | |
typedef std::pair< childIter, childIter > | childIterPair |
typedef std::map< std::string, std::string >::iterator | propIter |
Public Member Functions | |
ConfBlock & | addChild (std::string blockName) |
Add a child with given name to children of current block. More... | |
bool | addParam (std::string key, std::string value) |
Add a key value pair. More... | |
ConfBlock () | |
Default constructor to create a new (empty) block. More... | |
bool | empty () |
Check whether the block is empty. More... | |
ConfBlock * | find (std::string blockName) |
Find a block with given name among the children. More... | |
std::pair< childIter, childIter > | findAll (std::string blockName) |
Find all blocks with given name among the children. More... | |
template<typename T > | |
T | getParam (std::string key) throw ( std::invalid_argument ) |
Retrieve parameter as certain type. More... | |
template<typename T > | |
bool | getParam (std::string key, T &value) throw ( std::invalid_argument ) |
Retrieve parameter as certain type. More... | |
int | removeChildren (std::string blockName) |
Remove all children with given name. More... | |
bool | removeParam (std::string key) |
Remove parameter with a given key. More... | |
template<typename T > | |
bool | setParam (std::string key, T value) |
Set parameter. More... | |
void | writeConfigFile (std::string fileName) |
Write out a configuration file of this block's subtree. More... | |
virtual | ~ConfBlock () |
Destructor. More... | |
Protected Member Functions | |
void | writeConfigFileRec (std::ofstream &fileHandle, std::string indent) |
Recursive helper function to write the configuration of a subtree to a file. More... | |
Protected Attributes | |
std::multimap< std::string, ConfBlock > | children_ |
Multimap containing the children. More... | |
std::map< std::string, std::string > | props_ |
Map containing parameter key / value pairs defined in this block. More... | |
Friends | |
class | ConfParser |
Declare ConfParser as friend class to give it access to internals. More... | |
Data structure corresponding to one block in the hierarchical configuration file.
Definition at line 80 of file ConfBlock.h.
typedef std::multimap< std::string, ConfBlock >::iterator confparser::ConfBlock::childIter |
Iterator type for the children of the block.
Definition at line 90 of file ConfBlock.h.
typedef std::pair< childIter, childIter > confparser::ConfBlock::childIterPair |
Definition at line 92 of file ConfBlock.h.
typedef std::map< std::string, std::string >::iterator confparser::ConfBlock::propIter |
Definition at line 91 of file ConfBlock.h.
|
inline |
Default constructor to create a new (empty) block.
Parameters and children will be empty
Definition at line 102 of file ConfBlock.h.
Referenced by addChild().
|
inlinevirtual |
|
inline |
Add a child with given name to children of current block.
[in] | blockName | Block name of child to add |
Definition at line 192 of file ConfBlock.h.
References children_, and ConfBlock().
Referenced by confparser::ConfParser::parse_rec().
|
inline |
Add a key value pair.
[in] | key | Parameter name to add |
[in] | value | Parameter value to add |
Definition at line 213 of file ConfBlock.h.
References props_.
Referenced by confparser::ConfParser::parse_rec().
|
inline |
Check whether the block is empty.
Definition at line 119 of file ConfBlock.h.
|
inline |
Find a block with given name among the children.
[in] | blockName | Name of the block to retrieve |
Definition at line 128 of file ConfBlock.h.
References children_.
Referenced by particles::ParticleSystem::setup().
Find all blocks with given name among the children.
[in] | blockName | Name of the blocks to retrieve |
Definition at line 141 of file ConfBlock.h.
References children_.
Referenced by particles::ParticleSystem::setup().
|
inline |
Retrieve parameter as certain type.
[in] | key | Parameter name to retrieve |
T | Type to retrieve parameter in |
Definition at line 152 of file ConfBlock.h.
References props_, and lbm::T.
Referenced by particles::ParticleSystem::setup().
|
inline |
Retrieve parameter as certain type.
[in] | key | Parameter name to retrieve |
[out] | value | Variable to store value in |
T | Type to retrieve parameter in |
Definition at line 172 of file ConfBlock.h.
|
inline |
Remove all children with given name.
[in] | blockName | Block name of children to remove |
Definition at line 202 of file ConfBlock.h.
References children_.
|
inline |
Remove parameter with a given key.
[in] | key | Parameter key to remove |
Definition at line 240 of file ConfBlock.h.
References props_.
|
inline |
Set parameter.
[in] | key | Parameter name to set |
[in] | value | Parameter value to set |
T | Type of the parameter to set (will be converted to string) |
Definition at line 227 of file ConfBlock.h.
References props_.
void confparser::ConfBlock::writeConfigFile | ( | std::string | fileName | ) |
Write out a configuration file of this block's subtree.
[in] | fileName | Name of the configuration file to write out |
Definition at line 19 of file ConfBlock.cpp.
References writeConfigFileRec().
Referenced by main().
|
protected |
Recursive helper function to write the configuration of a subtree to a file.
[in] | fileHandle | Stream to write to |
[in] | indent | Level of indentation for the current block |
Definition at line 32 of file ConfBlock.cpp.
References children_, and props_.
Referenced by writeConfigFile().
|
friend |
Declare ConfParser as friend class to give it access to internals.
Definition at line 84 of file ConfBlock.h.
|
protected |
Multimap containing the children.
Definition at line 274 of file ConfBlock.h.
Referenced by addChild(), empty(), find(), findAll(), removeChildren(), and writeConfigFileRec().
|
protected |
Map containing parameter key / value pairs defined in this block.
Definition at line 270 of file ConfBlock.h.
Referenced by addParam(), empty(), getParam(), removeParam(), setParam(), and writeConfigFileRec().