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>

Public Member Functions

bool_t 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_t 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_t getKeyValue (const std::string &key, double &value, double minValue=-std::numeric_limits< double >::infinity(), double maxValue=std::numeric_limits< double >::infinity())
 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_t getKeyValue (const std::string &key, std::vector< double > &values, double minValue=-std::numeric_limits< double >::infinity(), double maxValue=std::numeric_limits< double >::infinity())
 Interprets the value for the specified key as a list of double precision floating point numbers, checking that each lies withing the bounds if specified. More...
 
bool_t 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...
 
bool_t getKeyValue (const std::string &key, int64_t &value, int64_t minValue=std::numeric_limits< int64_t >::min(), int64_t maxValue=std::numeric_limits< int64_t >::max())
 Interprets the value for the specified key as an integer number, checking that it lies withing the bounds if specified. More...
 
bool_t getKeyValue (const std::string &key, bool &value)
 Interprets the value for the specified key as a boolean, possible values can be 'yes' or 'no'. More...
 
bool_t getStringKeyValue (const std::string &key, std::string &value, bool &used) const
 Obtains the value for the specified key, not marking the key as used, but instead storing information about the key's prior usage in the used parameter. 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...
 

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_t 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_t ConfigSettings::getKeyValue ( const std::string &  key,
double &  value,
double  minValue = -std::numeric_limits<double>::infinity(),
double  maxValue = std::numeric_limits<double>::infinity() 
)

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

bool_t ConfigSettings::getKeyValue ( const std::string &  key,
std::vector< double > &  values,
double  minValue = -std::numeric_limits< double >::infinity(),
double  maxValue = std::numeric_limits< double >::infinity() 
)

Interprets the value for the specified key as a list of double precision floating point numbers, checking that each lies withing the bounds if specified.

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

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

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

bool_t ConfigSettings::getKeyValue ( const std::string &  key,
bool &  value 
)

Interprets the value for the specified key as a boolean, possible values can be 'yes' or 'no'.

bool_t ConfigSettings::getStringKeyValue ( const std::string &  key,
std::string &  value,
bool &  used 
) const

Obtains the value for the specified key, not marking the key as used, but instead storing information about the key's prior usage in the used parameter.

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_t 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: