ionflux.org | Impressum

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

Configuration tree. More...

#include <ConfigTree.hpp>

Inheritance diagram for Ionflux::Tools::ConfigTree:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ConfigTree ()
 Constructor.
virtual ~ConfigTree ()
 Destructor.
virtual void clear ()
 Clear all configuration data.
virtual void parseConfig (const std::string &configData)
 Parse 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.
virtual void dump (Node *node)
 Process a tree node.

Static Public Member Functions

static std::string escapeValue (const std::string &value)
 Escape configuration value.

Static Public Attributes

static const TokenType TT_COMMENT
 Token type: Comment.
static const TokenType TT_ASSIGN
 Token type: Assignment operator.
static const TokenType TT_MULTILINE
 Token type: Multi-line option marker.
static const TokenType TT_TREEPATH
 Token type: Tree path elements.
static const TokenType TT_NESTED_OPEN
 Token type: Nested configuration (open).
static const TokenType TT_NESTED_CLOSE
 Token type: Nested configuration (close).
static const std::string AUTO_INSERT_MARKER
 Auto-insertion marker.
static const std::string SPECIAL_VALUE_CHARS = "{}\n"
 Special characters in configuration values.

Protected Member Functions

virtual int findFirstLine (Node *searchNode)
 Find a configuration line.
virtual int findLastLine (Node *searchNode)
 Find a configuration line.
virtual int getAutoInsertPos ()
 Get auto-insert position.

Protected Attributes

std::string inputFile
 Configuration source file.
Tokenizer tok
 Configuration line tokenizer.
std::vector< ConfigTreeEntryentries
 Vector of configuration tree entries.

Detailed Description

Configuration tree.

A tree containing configuration data. (See Configuration file I/O for details)


Constructor & Destructor Documentation

Ionflux::Tools::ConfigTree::ConfigTree  ) 
 

Constructor.

Construct new ConfigTree object.

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

Destructor.

Destruct ConfigTree object.


Member Function Documentation

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

Clear all configuration data.

Effectively erases all configuration data from the ConfigTree object.

Implements Ionflux::Tools::Config.

void Ionflux::Tools::ConfigTree::dump Node node  )  [virtual]
 

Process a tree node.

Tree traversal callback, used for updating the configuration file. The data of the node will be added to or updated in the configuration file entry table

Parameters:
node Node to be processed.

Implements Ionflux::Tools::NodeDump.

std::string Ionflux::Tools::ConfigTree::escapeValue const std::string &  value  )  [static]
 

Escape configuration value.

Escapes special characters in a configuration value, making the value suitable for a configuration file.

Parameters:
value Configuration value.
Returns:
Escaped configuration value.

int Ionflux::Tools::ConfigTree::findFirstLine Node searchNode  )  [protected, virtual]
 

Find a configuration line.

Searches for the first line in the configuration file that defines the specified node. Returns -1 if the node is not found.

Parameters:
searchNode The node to search for.
Returns:
Line number where the specified node is first defined, or -1, if the node is not found.

int Ionflux::Tools::ConfigTree::findLastLine Node searchNode  )  [protected, virtual]
 

Find a configuration line.

Searches for the last line in the configuration file that defines the specified node. Returns -1 if the node is not found.

Parameters:
searchNode The node to search for.
Returns:
Line number where the specified node is last defined, or -1, if the node is not found.

std::string Ionflux::Tools::ConfigTree::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.

int Ionflux::Tools::ConfigTree::getAutoInsertPos  )  [protected, virtual]
 

Get auto-insert position.

Fetch the correct line for auto-insertion of values.

Returns:
Line number where new values should be auto-inserted.

void Ionflux::Tools::ConfigTree::parseConfig const std::string &  configData  )  [virtual]
 

Parse configuration data.

Parses configuration data, with syntax as specified for ConfigTree.

Parameters:
configData Configuration data.

void Ionflux::Tools::ConfigTree::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::ConfigTree::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::ConfigTree::writeConfig  )  [virtual]
 

Write configuration to a file.

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

Implements Ionflux::Tools::Config.

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

Write configuration to a file.

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

Parameters:
configFile Name of the configuration file

Implements Ionflux::Tools::Config.


Member Data Documentation

const std::string Ionflux::Tools::ConfigTree::AUTO_INSERT_MARKER [static]
 

Initial value:

 
    "# ------- Values inserted automatically by the configuration system "
    "--------"
Auto-insertion marker.

std::vector<ConfigTreeEntry> Ionflux::Tools::ConfigTree::entries [protected]
 

Vector of configuration tree entries.

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

Configuration source file.

const std::string Ionflux::Tools::ConfigTree::SPECIAL_VALUE_CHARS = "{}\n" [static]
 

Special characters in configuration values.

Tokenizer Ionflux::Tools::ConfigTree::tok [protected]
 

Configuration line tokenizer.

const TokenType Ionflux::Tools::ConfigTree::TT_ASSIGN [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 2, "=", false, 1}
Token type: Assignment operator.

const TokenType Ionflux::Tools::ConfigTree::TT_COMMENT [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 1, "#", false, 1}
Token type: Comment.

const TokenType Ionflux::Tools::ConfigTree::TT_MULTILINE [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 3, "\\", false, 1}
Token type: Multi-line option marker.

const TokenType Ionflux::Tools::ConfigTree::TT_NESTED_CLOSE [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 6, "}", false, 1}
Token type: Nested configuration (close).

const TokenType Ionflux::Tools::ConfigTree::TT_NESTED_OPEN [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 5, "{", false, 1}
Token type: Nested configuration (open).

const TokenType Ionflux::Tools::ConfigTree::TT_TREEPATH [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 4, ".[]()", false, 0}
Token type: Tree path elements.


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