ConfigurationFile Class Reference

Configuration file class. More...

#include <configurationfile.h>

List of all members.

Public Member Functions

 ConfigurationFile (string)
 Class constructor.
 ~ConfigurationFile ()
 Class destructor.
bool load ()
 Parse and load the configuration file.
bool flush ()
 Flush the settings in the file.
map< string, string > getConfig ()
 Return the configuration (keys and values, in a MAP container).
void addProtectedKey (string)
 Add a key to protected list.
string getValue (string, bool displayProtected=true)
 Return a value associated to a key.
void setValue (string, string)
 Set a value to a key.
bool delKey (string)
 Delete a key.
string getFilePath ()
 Returns file path.

Private Attributes

map< string, string > config
 Configuration container.
string file
 Configuration file path (and name).
vector< string > protectedKeys
 Stores protected keys.


Detailed Description

Configuration file class.

Class that manage a configuration file. It uses a MAP containing values associated to keys

Definition at line 44 of file configurationfile.h.


Constructor & Destructor Documentation

ConfigurationFile::ConfigurationFile ( string  fname  ) 

Class constructor.

The class constructor. Initialize private attributes

Parameters:
fname Configuration file path (including name)
Postcondition:
An object is contructed

Definition at line 35 of file configurationfile.cpp.

References config, file, and protectedKeys.

ConfigurationFile::~ConfigurationFile (  ) 

Class destructor.

The class destructor

Definition at line 45 of file configurationfile.cpp.


Member Function Documentation

void ConfigurationFile::addProtectedKey ( string  key  ) 

Add a key to protected list.

Add a key to the protected list

Parameters:
key Key to protect

Definition at line 135 of file configurationfile.cpp.

References protectedKeys.

Referenced by BotKernel::BotKernel().

bool ConfigurationFile::delKey ( string  key  ) 

Delete a key.

Delete a key from the configuration file

Parameters:
key The key you want delete

Definition at line 176 of file configurationfile.cpp.

References config.

Referenced by deletekey().

bool ConfigurationFile::flush (  ) 

Flush the settings in the file.

Flush all the configuration keys (with values) in the configuration file File format : key=value

Precondition:
The file must exist and be writeable
Postcondition:
All the configuration values are saved into the configuration file
Returns:
true if the configuration file could be open, else erturn false

Definition at line 104 of file configurationfile.cpp.

References config, and file.

Referenced by flushconffile().

map< string, string > ConfigurationFile::getConfig (  ) 

Return the configuration (keys and values, in a MAP container).

Returns the MAP containing the configuration

Precondition:
The file must have been parsed
Returns:
a map container, containing the configuration value (with keys)

Definition at line 126 of file configurationfile.cpp.

References config.

string ConfigurationFile::getFilePath (  ) 

Returns file path.

Get file path

Returns:
file path

Definition at line 193 of file configurationfile.cpp.

References file.

Referenced by BotKernel::initDirs().

string ConfigurationFile::getValue ( string  key,
bool  displayProtected = true 
)

bool ConfigurationFile::load (  ) 

Parse and load the configuration file.

Read the configuration file and load it in a MAP containe File format : key=value # is the comment char

Precondition:
The file must exist and be readable
Postcondition:
The file is parsed, and closed. The MAP contains keys and values
Returns:
true if no errors appears, else false

Definition at line 58 of file configurationfile.cpp.

References config, file, getValue(), and Tools::stringToVector().

Referenced by BotKernel::BotKernel(), and loadconffile().

void ConfigurationFile::setValue ( string  key,
string  value 
)

Set a value to a key.

Set a value to a given key. If the key exists, the value is replaced. If the key does'nt exists, it's added to the map

Postcondition:
The value associated to the given key i saved in the configuration. To save it in the file, use flush() method
Parameters:
key The key for with you want to set a value
value The value that you want to give to the given key

Definition at line 168 of file configurationfile.cpp.

References config.

Referenced by autoop(), autovoice(), protectmodes(), protecttopic(), setconfvalue(), setlogkeepfiles(), setloglevel(), setlogperiod(), setNick(), setSuperAdminPass(), unautoop(), unautovoice(), unprotectmodes(), and unprotecttopic().


Member Data Documentation

map<string,string> ConfigurationFile::config [private]

Configuration container.

Definition at line 69 of file configurationfile.h.

Referenced by ConfigurationFile(), delKey(), flush(), getConfig(), getValue(), load(), and setValue().

string ConfigurationFile::file [private]

Configuration file path (and name).

Definition at line 71 of file configurationfile.h.

Referenced by ConfigurationFile(), flush(), getFilePath(), and load().

vector<string> ConfigurationFile::protectedKeys [private]

Stores protected keys.

Definition at line 73 of file configurationfile.h.

Referenced by addProtectedKey(), ConfigurationFile(), and getValue().


The documentation for this class was generated from the following files:

Generated on Sun Aug 16 15:28:36 2009 for trustyRC by  doxygen 1.5.8