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

Helper class to read configuration settings, more advanced than ConfigReader. More...

#include <configsettings.h>

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

Public Member Functions

bool load (const std::string &fileName)
 Loads the key/value pairs from the config file specified by fileName. More...
 
void clear ()
 Clears the loaded key/value pairs. More...
 
void getKeys (std::vector< std::string > &keys) const
 Returns a list of all the keys in the read config file. More...
 
bool getKeyValue (const std::string &key, std::string &value, const std::vector< std::string > &allowedValues=std::vector< std::string >())
 Stores the string value for key parameter key into argument value, checking if the value is one of the allowed values in the list allowedValues, if specified. More...
 
bool getKeyValue (const std::string &key, double &value, double minValue=-std::numeric_limits< double >::max(), double maxValue=std::numeric_limits< double >::max())
 Interprets the value for the specified key as a double precision floating point number, checking that it lies withing the bounds if specified. More...
 
bool getKeyValue (const std::string &key, int &value, int minValue=std::numeric_limits< int >::min(), int maxValue=std::numeric_limits< int >::max())
 Interprets the value for the specified key as an integer number, checking that it lies withing the bounds if specified. More...
 
void getUnusedKeys (std::vector< std::string > &keys) const
 Stores a list of keys that have not been read by any of the getKeyValue functions into keys (allows you to check if the config file contains more lines than necessary). More...
 
void clearUsageFlags ()
 Resets the markers that keep track of wether or not a key has been read. More...
 
void merge (const ConfigSettings &src)
 Merges the specified config settings object into the current one. 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

Helper class to read configuration settings, more advanced than ConfigReader.

This class works in a similar way as the ConfigReader class and the config files should have the same format. Extra features of this class are the ability to interpret specific keys as integer or floating point values for example, and to check which keys have actually been read.

Member Function Documentation

void ConfigSettings::clear ( )

Clears the loaded key/value pairs.

void ConfigSettings::clearUsageFlags ( )

Resets the markers that keep track of wether or not a key has been read.

void ConfigSettings::getKeys ( std::vector< std::string > &  keys) const

Returns a list of all the keys in the read config file.

bool ConfigSettings::getKeyValue ( const std::string &  key,
std::string &  value,
const std::vector< std::string > &  allowedValues = std::vector< std::string >() 
)

Stores the string value for key parameter key into argument value, checking if the value is one of the allowed values in the list allowedValues, if specified.

bool ConfigSettings::getKeyValue ( const std::string &  key,
double &  value,
double  minValue = -std::numeric_limits<double>::max(),
double  maxValue = std::numeric_limits<double>::max() 
)

Interprets the value for the specified key as a double precision floating point number, checking that it lies withing the bounds if specified.

bool ConfigSettings::getKeyValue ( const std::string &  key,
int &  value,
int  minValue = std::numeric_limits<int>::min(),
int  maxValue = std::numeric_limits<int>::max() 
)

Interprets the value for the specified key as an integer number, checking that it lies withing the bounds if specified.

void ConfigSettings::getUnusedKeys ( std::vector< std::string > &  keys) const

Stores a list of keys that have not been read by any of the getKeyValue functions into keys (allows you to check if the config file contains more lines than necessary).

bool ConfigSettings::load ( const std::string &  fileName)

Loads the key/value pairs from the config file specified by fileName.

void ConfigSettings::merge ( const ConfigSettings src)

Merges the specified config settings object into the current one.


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