Simpact Cyan
Population based event driven simulation using mNRM
|
A helper class to read config files. More...
#include <configreader.h>
Public Member Functions | |
bool | read (const std::string &fileName) |
Reads the config file specified by fileName . More... | |
void | getKeys (std::vector< std::string > &keys) const |
Stores all keys found in the config file in keys . More... | |
bool | getKeyValue (const std::string &key, std::string &value) const |
For the key specified by the key parameter, the corresponding value will be stored in value . More... | |
void | printAll () const |
Prints all key/value pairs to the standard output. More... | |
void | clear () |
Clears the stored key/value pairs. More... | |
Public Member Functions inherited from errut::ErrorBase | |
ErrorBase () | |
Creates an instance without an explicit object name. More... | |
ErrorBase (const std::string &objName) | |
Creates an instance with the object name set to objName . More... | |
std::string | getObjectName () const |
Returns the stored object name. More... | |
std::string | getErrorString () const |
Returns the currently stored error message. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from errut::ErrorBase | |
void | setErrorString (const std::string &str) const |
Derived classes can use this member function to store an error message. More... | |
A helper class to read config files.
The config files should contain lines like this:
Everything to the left of the first '=' sign is considered to be the key and everything to the right of the same '=' sign is considered to be the value. Leading and trailing spaces/tabs are ignored for both key and value.
This class just stores the key/value pairs as strings, it does not attempt to interpret values in any way.
void ConfigReader::clear | ( | ) |
Clears the stored key/value pairs.
void ConfigReader::getKeys | ( | std::vector< std::string > & | keys | ) | const |
Stores all keys found in the config file in keys
.
bool ConfigReader::getKeyValue | ( | const std::string & | key, |
std::string & | value | ||
) | const |
For the key specified by the key
parameter, the corresponding value will be stored in value
.
void ConfigReader::printAll | ( | ) | const |
Prints all key/value pairs to the standard output.
bool ConfigReader::read | ( | const std::string & | fileName | ) |
Reads the config file specified by fileName
.