#include <configurationfile.h>
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. |
Class that manage a configuration file. It uses a MAP containing values associated to keys
Definition at line 44 of file configurationfile.h.
ConfigurationFile::ConfigurationFile | ( | string | fname | ) |
Class constructor.
The class constructor. Initialize private attributes
fname | Configuration file path (including name) |
Definition at line 35 of file configurationfile.cpp.
References config, file, and protectedKeys.
ConfigurationFile::~ConfigurationFile | ( | ) |
void ConfigurationFile::addProtectedKey | ( | string | key | ) |
Add a key to protected list.
Add a key to the protected list
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
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
Definition at line 104 of file configurationfile.cpp.
Referenced by flushconffile().
map< string, string > ConfigurationFile::getConfig | ( | ) |
Return the configuration (keys and values, in a MAP container).
Returns the MAP containing the configuration
Definition at line 126 of file configurationfile.cpp.
References config.
string ConfigurationFile::getFilePath | ( | ) |
Returns file path.
Get file path
Definition at line 193 of file configurationfile.cpp.
References file.
Referenced by BotKernel::initDirs().
string ConfigurationFile::getValue | ( | string | key, | |
bool | displayProtected = true | |||
) |
Return a value associated to a key.
Return the value associated to a given key
key | The key from with you want to get the value | |
displayProtected | If true, protected key/values will be displayed |
Definition at line 147 of file configurationfile.cpp.
References config, Tools::isInVector(), and protectedKeys.
Referenced by BotKernel::addCountDown(), addsuperadmin(), addtempsuperadmin(), allowedCommandCheck(), autoop(), autovoice(), ban(), banmask(), bannedHandler(), BotKernel::BotKernel(), bzsearch(), checkBug(), BotKernel::connect(), danstonchat(), delsuperadmin(), getconfvalue(), LogFactory::getLoggedChannels(), getMyFirstNick(), LogFactory::hasToBeLogged(), help(), joinHandler(), kickHandler(), lamoule(), launchSurvey(), load(), BotKernel::loadPlugins(), modeHandler(), modeHandlerProtect(), BotKernel::msgTreatment(), onEndOfMOTD(), planet(), player(), prefix(), protectmodes(), protecttopic(), purifyFile(), randomKick(), rejoinChan(), RemoteControl::RemoteControl(), secondaryNick(), BotKernel::send(), setSuperAdminPass(), testMsgTimestamp(), top5(), topicHandler(), toptotal(), unautoop(), unautovoice(), unprotectmodes(), unprotecttopic(), vote(), and wiki().
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
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
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().
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().