Simpact Cyan
Population based event driven simulation using mNRM
Public Member Functions | List of all members
ConfigReader Class Reference

A helper class to read config files. More...

#include <configreader.h>

Inheritance diagram for ConfigReader:
Inheritance graph
[legend]
Collaboration diagram for ConfigReader:
Collaboration graph
[legend]

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

Detailed Description

A helper class to read config files.

The config files should contain lines like this:

# Lines starting with a hash sign are ignored, can be used for comments
# Other lines should be of the form
key = value

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.

Member Function Documentation

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.


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