Reads and writes a configuration file. More...
#include <ConfigFile.hpp>
Public Member Functions | |
ConfigFile (string filename, string filepath="../config/", string delimiter="=", string comment="#", string sectionStartTag="[", string sectionEndTag="]", string sentry="EndConfigFile") | |
ConfigFile () | |
~ConfigFile () | |
template<class T > | |
T | read (const string &key, const T &value) const |
template<class T > | |
T | read (const string &key) const |
template<class T > | |
T | read (const string §ionKey, const string &key) |
template<class T > | |
bool | readInto (T &var, const string &key) const |
template<class T > | |
bool | readInto (T &var, const string §ionKey, const string &key) |
template<class T > | |
bool | readInto (T &var, const string &key, const T &value) const |
template<class T > | |
void | add (string key, const T &value) |
template<class T > | |
void | add (string sectionKey, string key, const T &value) |
void | remove (const string &key) |
void | remove (const string §ionKey, const string &key) |
void | save () |
bool | keyExists (const string &key) const |
bool | keyExists (const string §ionKey, const string &key) |
bool | sectionExists (const string §ionKey) |
string | getDelimiter () const |
string | getComment () const |
string | getSentry () const |
string | setDelimiter (const string &s) |
string | setComment (const string &s) |
Protected Types | |
typedef std::map< string, string >::iterator | mapi |
typedef std::map< string, string >::const_iterator | mapci |
typedef std::map< string, map < string, string > >::const_iterator | mapciSect |
Static Protected Member Functions | |
template<class T > | |
static string | T_as_string (const T &t) |
template<class T > | |
static T | string_as_T (const string &s) |
static void | trim (string &s) |
Protected Attributes | |
string | myDelimiter |
string | myComment |
string | mySectionStartTag |
string | mySectionEndTag |
string | mySentry |
string | myFilepath |
SortTreeVector * | mySortVectorObj |
std::map< string, string > | myContents |
std::map< string, std::map < string, string > > | mySectionRelatedContents |
std::vector< SortTreeVector > | mySortVector |
Friends | |
std::ostream & | operator<< (std::ostream &os, ConfigFile &cf) |
std::istream & | operator>> (std::istream &is, ConfigFile &cf) |
Reads and writes a configuration file.
Definition at line 126 of file ConfigFile.hpp.
typedef std::map<string, string>::const_iterator mapci [protected] |
Definition at line 143 of file ConfigFile.hpp.
typedef std::map<string, map<string, string> >::const_iterator mapciSect [protected] |
Definition at line 144 of file ConfigFile.hpp.
typedef std::map<string, string>::iterator mapi [protected] |
Definition at line 142 of file ConfigFile.hpp.
ConfigFile | ( | string | filename, | |
string | filepath = "../config/" , |
|||
string | delimiter = "=" , |
|||
string | comment = "#" , |
|||
string | sectionStartTag = "[" , |
|||
string | sectionEndTag = "]" , |
|||
string | sentry = "EndConfigFile" | |||
) |
Definition at line 9 of file ConfigFile.cpp.
ConfigFile | ( | ) |
Definition at line 34 of file ConfigFile.cpp.
~ConfigFile | ( | ) | [inline] |
Definition at line 158 of file ConfigFile.hpp.
void add | ( | string | sectionKey, | |
string | key, | |||
const T & | value | |||
) | [inline] |
void add | ( | string | key, | |
const T & | value | |||
) | [inline] |
string getComment | ( | ) | const [inline] |
Definition at line 212 of file ConfigFile.hpp.
string getDelimiter | ( | ) | const [inline] |
Definition at line 208 of file ConfigFile.hpp.
string getSentry | ( | ) | const [inline] |
Definition at line 216 of file ConfigFile.hpp.
bool keyExists | ( | const string & | sectionKey, | |
const string & | key | |||
) |
Definition at line 76 of file ConfigFile.cpp.
bool keyExists | ( | const string & | key | ) | const |
Definition at line 70 of file ConfigFile.cpp.
T read | ( | const string & | sectionKey, | |
const string & | key | |||
) | [inline] |
Definition at line 297 of file ConfigFile.hpp.
T read | ( | const string & | key | ) | const [inline] |
Definition at line 290 of file ConfigFile.hpp.
T read | ( | const string & | key, | |
const T & | value | |||
) | const [inline] |
Definition at line 309 of file ConfigFile.hpp.
bool readInto | ( | T & | var, | |
const string & | key, | |||
const T & | value | |||
) | const [inline] |
bool readInto | ( | T & | var, | |
const string & | sectionKey, | |||
const string & | key | |||
) | [inline] |
Definition at line 334 of file ConfigFile.hpp.
bool readInto | ( | T & | var, | |
const string & | key | |||
) | const [inline] |
Definition at line 318 of file ConfigFile.hpp.
void remove | ( | const string & | sectionKey, | |
const string & | key | |||
) |
Definition at line 45 of file ConfigFile.cpp.
void remove | ( | const string & | key | ) |
Definition at line 39 of file ConfigFile.cpp.
void save | ( | ) |
Definition at line 62 of file ConfigFile.cpp.
bool sectionExists | ( | const string & | sectionKey | ) |
Definition at line 87 of file ConfigFile.cpp.
string setComment | ( | const string & | s | ) | [inline] |
Definition at line 226 of file ConfigFile.hpp.
string setDelimiter | ( | const string & | s | ) | [inline] |
Definition at line 220 of file ConfigFile.hpp.
bool string_as_T< bool > | ( | const string & | s | ) | [inline, static, protected] |
Definition at line 255 of file ConfigFile.hpp.
string T_as_string | ( | const T & | t | ) | [inline, static, protected] |
void trim | ( | string & | s | ) | [static, protected] |
std::ostream& operator<< | ( | std::ostream & | os, | |
ConfigFile & | cf | |||
) | [friend] |
Definition at line 104 of file ConfigFile.cpp.
std::istream& operator>> | ( | std::istream & | is, | |
ConfigFile & | cf | |||
) | [friend] |
Definition at line 138 of file ConfigFile.cpp.
string myComment [protected] |
Definition at line 130 of file ConfigFile.hpp.
std::map<string, string> myContents [protected] |
Definition at line 137 of file ConfigFile.hpp.
string myDelimiter [protected] |
Definition at line 129 of file ConfigFile.hpp.
string myFilepath [protected] |
Definition at line 134 of file ConfigFile.hpp.
string mySectionEndTag [protected] |
Definition at line 132 of file ConfigFile.hpp.
std::map<string, std::map<string, string> > mySectionRelatedContents [protected] |
Definition at line 138 of file ConfigFile.hpp.
string mySectionStartTag [protected] |
Definition at line 131 of file ConfigFile.hpp.
string mySentry [protected] |
Definition at line 133 of file ConfigFile.hpp.
std::vector<SortTreeVector> mySortVector [protected] |
Definition at line 140 of file ConfigFile.hpp.
SortTreeVector* mySortVectorObj [protected] |
Definition at line 135 of file ConfigFile.hpp.