#include <Configuration.h>
Public Member Functions | |
Configuration (string cfile, Debug *dbg, vector< string > sections, vector< string > vars) | |
Configuration class default constructor. | |
virtual | ~Configuration () |
Configuration class default destructor. | |
string | GetValue (string key) |
Get a variable value by it's key name. | |
string | GetHostname () |
Get hostname of the computer voiphoney is running. | |
void | LoadSysVars () |
Load all necessary system variables. | |
Protected Member Functions | |
void | ReadFile (string cfile) |
Read configuration file Read configuration file and store it's content in raw format data. | |
void | Parseconf () |
Parse and map configuration data. | |
void | AddConf (string key, string value) |
Add a configuration key => value pair. | |
bool | CheckSyntax (string key, string value) |
Check configuration file syntax Checks configuration file syntax by checking all paired values. | |
Protected Attributes | |
int | content_len |
Configuration file content length. | |
char * | content |
String containing all content. | |
map< string, string > | config |
Mapped configuration content. | |
map< string, string >::iterator | config_it |
Iterator for mapped configuration content. | |
Private Attributes | |
char | hostname [128] |
String containing hostname of the computer. | |
Debug * | dbg |
Debug instance passed to configuration parser. | |
string | ipaddr |
Ip address of the computer. | |
vector< string > | sections |
vector containing all valid configuration sections | |
vector< string > | vars |
vector containing all valid configuration variables |
This class takes care of loading and parsing configuration files from the filesystem
Definition at line 21 of file Configuration.h.
Configuration::Configuration | ( | string | cfile, | |
Debug * | dbg, | |||
vector< string > | sections, | |||
vector< string > | vars | |||
) |
Configuration class default constructor.
cfile | Configuration file path | |
dbg | Debug instance | |
sections | Sections to parse in configuration file | |
vars | Vaiables to parse in configuration file |
Configuration::~Configuration | ( | ) | [virtual] |
void Configuration::AddConf | ( | string | key, | |
string | value | |||
) | [protected] |
Add a configuration key => value pair.
key | Key identifier (name) of the variable | |
value | Value of this variable |
Definition at line 194 of file Configuration.cc.
References CheckSyntax(), config, and dbg.
Referenced by Parseconf().
bool Configuration::CheckSyntax | ( | string | key, | |
string | value | |||
) | [protected] |
Check configuration file syntax Checks configuration file syntax by checking all paired values.
key | Key identifier (name) of the variable | |
value | Value of this variable |
Definition at line 202 of file Configuration.cc.
References sections, and vars.
Referenced by AddConf().
string Configuration::GetHostname | ( | ) |
Get hostname of the computer voiphoney is running.
string | hostname of this computer |
Definition at line 78 of file Configuration.cc.
References hostname.
string Configuration::GetValue | ( | string | key | ) |
Get a variable value by it's key name.
key | Key name of this variable |
string | variable value |
Definition at line 224 of file Configuration.cc.
References config.
Referenced by plugins::AsteriskPlugin::LoadConf(), and main().
void Configuration::LoadSysVars | ( | ) |
void Configuration::Parseconf | ( | ) | [protected] |
void Configuration::ReadFile | ( | string | cfile | ) | [protected] |
Read configuration file Read configuration file and store it's content in raw format data.
cfile | Full path to configuration file |
Definition at line 84 of file Configuration.cc.
References content, content_len, and dbg.
map<string, string> Configuration::config [protected] |
Mapped configuration content.
Definition at line 53 of file Configuration.h.
Referenced by AddConf(), and GetValue().
map<string, string>::iterator Configuration::config_it [protected] |
char* Configuration::content [protected] |
String containing all content.
Definition at line 51 of file Configuration.h.
Referenced by Parseconf(), and ReadFile().
int Configuration::content_len [protected] |
Configuration file content length.
Definition at line 49 of file Configuration.h.
Referenced by ReadFile().
Debug* Configuration::dbg [private] |
Debug instance passed to configuration parser.
Definition at line 83 of file Configuration.h.
Referenced by AddConf(), LoadSysVars(), and ReadFile().
char Configuration::hostname[128] [private] |
String containing hostname of the computer.
Definition at line 81 of file Configuration.h.
Referenced by GetHostname(), and LoadSysVars().
string Configuration::ipaddr [private] |
Ip address of the computer.
Definition at line 85 of file Configuration.h.
Referenced by LoadSysVars().
vector<string> Configuration::sections [private] |
vector containing all valid configuration sections
Definition at line 87 of file Configuration.h.
Referenced by CheckSyntax().
vector<string> Configuration::vars [private] |
vector containing all valid configuration variables
Definition at line 89 of file Configuration.h.
Referenced by CheckSyntax().