ionflux.org | Impressum

Ionflux::Tools::ConfigMap Class Reference
[Configuration file I/O]

Configuration map. More...

#include <ConfigMap.hpp>

Inheritance diagram for Ionflux::Tools::ConfigMap:

Inheritance graph
[legend]
Collaboration diagram for Ionflux::Tools::ConfigMap:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ConfigMap ()
 Constructor.
virtual ~ConfigMap ()
 Destructor.
virtual void clear ()
 Clear all configuration data.
virtual void readConfig (const std::string &configFile)
 Read configuration from a file.
virtual void writeConfig (const std::string &configFile)
 Write configuration to a file.
virtual void writeConfig ()
 Write configuration to a file.
virtual std::string get (const std::string &key)
 Get a configuration value.
virtual void set (const std::string &key, const std::string &value)
 Set a configuration value.

Static Public Attributes

static const std::string CONFIG_PATTERN = "([a-zA-Z0-9_\\.]+)\\s*=\\s*(.*)"
 Pattern used to match configuration key/value pairs.
static const std::string COMMENT_PATTERN = "^#"
 Pattern used to match comments.

Protected Member Functions

virtual void init ()
 Initialize configuration object.
virtual ConfigOption parseConfigLine (const std::string &configLine)
 Parse a line of configuration.
virtual void updateInputData ()
 Update configuration input data.

Protected Attributes

std::vector< std::string > configInput
 Vector to store the input as read from a config file.
std::string inputFile
 Configuration source file.
std::map< std::string, std::string > config
 Configuration map where key/value pairs are stored.
std::vector< std::string > newKeys
 Vector to store option keys that were added at runtime.
pcre * configRE
 Configuration line regexp pattern.
pcre * commentRE
 Comment line regexp pattern.

Detailed Description

Configuration map.

Encapsulates configuration data as a set of key/value pairs.


Constructor & Destructor Documentation

Ionflux::Tools::ConfigMap::ConfigMap  ) 
 

Constructor.

Construct new ConfigMap object.

Ionflux::Tools::ConfigMap::~ConfigMap  )  [virtual]
 

Destructor.

Destruct ConfigMap object.


Member Function Documentation

void Ionflux::Tools::ConfigMap::clear  )  [virtual]
 

Clear all configuration data.

Effectively erases all configuration data from the ConfigMap object.

Implements Ionflux::Tools::Config.

string Ionflux::Tools::ConfigMap::get const std::string &  key  )  [virtual]
 

Get a configuration value.

Fetches the value of a configuration option from the configuration table.

Parameters:
key The key identifying the configuration value.
Returns:
Value of the specified configuration option, or an empty string if the option is not set.

Implements Ionflux::Tools::Config.

void Ionflux::Tools::ConfigMap::init  )  [protected, virtual]
 

Initialize configuration object.

Sets up the internals, such as patterns that should be compiled in advance.

ConfigOption Ionflux::Tools::ConfigMap::parseConfigLine const std::string &  configLine  )  [protected, virtual]
 

Parse a line of configuration.

Parses a line containing a key/value pair or a comment. Key/Value pairs are added to the configuration map, comments are simply ignored.

Parameters:
configLine Line of configuration data

void Ionflux::Tools::ConfigMap::readConfig const std::string &  configFile  )  [virtual]
 

Read configuration from a file.

Reads data from a configuration file and stores it in the configuration table.

Parameters:
configFile Name of the configuration file

Implements Ionflux::Tools::Config.

void Ionflux::Tools::ConfigMap::set const std::string &  key,
const std::string &  value
[virtual]
 

Set a configuration value.

Sets the configuration option denoted by key to value.

Parameters:
key The key of the configuration option to be set.
value The value the option should be set to.

Implements Ionflux::Tools::Config.

void Ionflux::Tools::ConfigMap::updateInputData  )  [protected, virtual]
 

Update configuration input data.

Changes the configuration input data so that it represents the actual current settings of the Config object. This may be used to update a configuration file.

void Ionflux::Tools::ConfigMap::writeConfig  )  [virtual]
 

Write configuration to a file.

Writes configuration data stored in the ConfigMap object to the same file it was read from.

Implements Ionflux::Tools::Config.

void Ionflux::Tools::ConfigMap::writeConfig const std::string &  configFile  )  [virtual]
 

Write configuration to a file.

Writes configuration data stored in the ConfigMap object to a file.

Parameters:
configFile Name of the configuration file

Implements Ionflux::Tools::Config.


Member Data Documentation

const string Ionflux::Tools::ConfigMap::COMMENT_PATTERN = "^#" [static]
 

Pattern used to match comments.

pcre* Ionflux::Tools::ConfigMap::commentRE [protected]
 

Comment line regexp pattern.

std::map<std::string, std::string> Ionflux::Tools::ConfigMap::config [protected]
 

Configuration map where key/value pairs are stored.

const string Ionflux::Tools::ConfigMap::CONFIG_PATTERN = "([a-zA-Z0-9_\\.]+)\\s*=\\s*(.*)" [static]
 

Pattern used to match configuration key/value pairs.

std::vector<std::string> Ionflux::Tools::ConfigMap::configInput [protected]
 

Vector to store the input as read from a config file.

pcre* Ionflux::Tools::ConfigMap::configRE [protected]
 

Configuration line regexp pattern.

std::string Ionflux::Tools::ConfigMap::inputFile [protected]
 

Configuration source file.

std::vector<std::string> Ionflux::Tools::ConfigMap::newKeys [protected]
 

Vector to store option keys that were added at runtime.


The documentation for this class was generated from the following files:
Generated on Tue Mar 14 21:07:45 2006 for Ionflux Tools Class Library (iftools) by  doxygen 1.4.6