A configuration object which is populated from a configuration file and allows to query and modify configuration values.
More...
#include <configuration.h>
|
void | readFile (std::string configFile) |
| parses configuration file configFile and loads the data into object. The configuration file needs to written in the libconfig++ format, see libconfig++. More...
|
|
bool | exists (std::string path) |
| determines whether a given configuration value exists. More...
|
|
double | getDouble (std::string path) |
| retrieves the configuration value found at a given configuration path. More...
|
|
bool | getBool (std::string path) |
| retrieves the configuration value found at a given configuration path. More...
|
|
int | getInteger (std::string path) |
| retrieves the configuration value found at a given configuration path. More...
|
|
std::string | getString (std::string path) |
| retrieves the configuration value found at a given configuration path. More...
|
|
void | addSetting (std::string path, std::string name, std::string value) |
| adds the string setting named name to the configuration tree at path with the value value More...
|
|
void | editSetting (std::string path, std::string name, double value) |
| modifies the string setting named name to the configuration tree at path with the value value More...
|
|
libconfig::Setting & | lookup (const std::string path) const |
| retrieves the configuration value found at a given configuration path as a reference to a libconfig::Setting object. libconfig::Setting objects support automatic conversion to most common data types. More...
|
|
std::string | getName () const |
|
|
class | std::auto_ptr< Configuration > |
|
A configuration object which is populated from a configuration file and allows to query and modify configuration values.
Essentially this class is just a front-end for the libconfig++ library. For convenience the configuration is a singleton object.
void Configuration::addSetting |
( |
std::string |
path, |
|
|
std::string |
name, |
|
|
std::string |
value |
|
) |
| |
adds the string setting named name to the configuration tree at path with the value value
- Parameters
-
[in] | path | path to the configuration value |
[in] | name | name of the setting |
[in] | value | value of the setting |
void Configuration::editSetting |
( |
std::string |
path, |
|
|
std::string |
name, |
|
|
double |
value |
|
) |
| |
modifies the string setting named name to the configuration tree at path with the value value
- Parameters
-
[in] | path | path to the configuration value |
[in] | name | name of the setting |
[in] | value | value of the setting |
bool Configuration::exists |
( |
std::string |
path | ) |
|
determines whether a given configuration value exists.
Libconfig++ configuration files have the structure of a tree, as they support groups of configuration values which themselves can be elements. A path to a configuration value within this tree uses a . as the separator.
example: "group1.nestedgroupA.value"
- Parameters
-
[in] | path | path to the configuration value |
- Returns
- true if the value is defined otherwise false.
bool Configuration::getBool |
( |
std::string |
path | ) |
|
retrieves the configuration value found at a given configuration path.
If the lookup fails the function throws a SettingNotFoundException exception.
- Parameters
-
[in] | path | path to the configuration value |
- Returns
- bool configuration value
double Configuration::getDouble |
( |
std::string |
path | ) |
|
retrieves the configuration value found at a given configuration path.
If the lookup fails the function throws a SettingNotFoundException exception.
- Parameters
-
[in] | path | path to the configuration value |
- Returns
- double configuration value
returns a reference to the only configuration instance
If the configuration has not been accessed previously an instance is created. The auto_ptr ensures that the object is properly destructed when the the application closes.
- Returns
- reference to the only configuration instance
int Configuration::getInteger |
( |
std::string |
path | ) |
|
retrieves the configuration value found at a given configuration path.
If the lookup fails the function throws a SettingNotFoundException exception.
- Parameters
-
[in] | path | path to the configuration value |
- Returns
- integer configuration value
std::string Configuration::getString |
( |
std::string |
path | ) |
|
retrieves the configuration value found at a given configuration path.
If the lookup fails the function throws a SettingNotFoundException exception.
- Parameters
-
[in] | path | path to the configuration value |
- Returns
- string configuration value
libconfig::Setting& config::Configuration::lookup |
( |
const std::string |
path | ) |
const |
|
inline |
retrieves the configuration value found at a given configuration path as a reference to a libconfig::Setting object. libconfig::Setting objects support automatic conversion to most common data types.
- Parameters
-
[in] | path | path to the configuration value |
- Returns
- reference to a Setting object
void Configuration::readFile |
( |
std::string |
configFile | ) |
|
parses configuration file configFile and loads the data into object. The configuration file needs to written in the libconfig++ format, see libconfig++.
- Parameters
-
[in] | configFile | path to the configuration file |
The documentation for this class was generated from the following files:
- /home/chris/Development/Release/NanoStructures/config/configuration.h
- /home/chris/Development/Release/NanoStructures/config/configuration.cpp