#include <ParseDBConfig.hxx>
Public Member Functions | |
ConfigFile (string filename, string delimiter=":", string comment="#") | |
Construct a ConfigFile, getting keys and values from given file. | |
ConfigFile () | |
template<class T> | |
T | read (const string &key) const |
Read the value corresponding to key. | |
template<class T> | |
T | read (const string &key, const T &value) const |
Return the value corresponding to key or a given default value as specified by 'value' if key is not found. | |
template<class T> | |
bool | readInto (T &var, const string &key) const |
Get the value corresponding to key and store in var, Return true if key is found. | |
template<class T> | |
bool | readInto (T &var, const string &key, const T &value) const |
Get the value corresponding to key and store in var. | |
template<class T> | |
void | add (string key, const T &value) |
Add keys and values. | |
void | remove (const string &key) |
Delete key and value. | |
bool | keyExists (const string &key) const |
Check whether a key exists in configuration. | |
string | getDelimiter () |
Grab separator between key and value. | |
string | getComment () |
Grab insicator of comment. | |
void | setDelimiter (const string &s) |
Set separator between key and value. | |
void | setComment (const string &s) |
Set indicator of comment. | |
Protected Types | |
typedef map< string, string > ::iterator | mapi |
typedef map< string, string > ::const_iterator | mapci |
Protected Attributes | |
string | myDelimiter |
separator between key and value | |
string | myComment |
indicator of comments | |
map< string, string > | myContents |
extracted keys and values | |
Friends | |
ostream & | operator<< (ostream &os, const ConfigFile &cf) |
Save a ConfigFile to os. | |
istream & | operator>> (istream &is, ConfigFile &cf) |
Load a ConfigFile from is, Read in keys and values. | |
Classes | |
struct | file_not_found |
File not found exception type. More... | |
struct | key_not_found |
Key not found exception type, thrown only by T read(key) variant of read(). More... |
typedef map<string,string>::iterator cqosdb::ConfigFile::mapi [protected] |
typedef map<string,string>::const_iterator cqosdb::ConfigFile::mapci [protected] |
cqosdb::ConfigFile::ConfigFile | ( | string | filename, | |
string | delimiter = ":" , |
|||
string | comment = "#" | |||
) |
Construct a ConfigFile, getting keys and values from given file.
cqosdb::ConfigFile::ConfigFile | ( | ) |
T cqosdb::ConfigFile::read | ( | const string & | key | ) | const [inline] |
Read the value corresponding to key.
T cqosdb::ConfigFile::read | ( | const string & | key, | |
const T & | value | |||
) | const [inline] |
Return the value corresponding to key or a given default value as specified by 'value' if key is not found.
bool cqosdb::ConfigFile::readInto | ( | T & | var, | |
const string & | key | |||
) | const [inline] |
Get the value corresponding to key and store in var, Return true if key is found.
Otherwise leave var untouched
bool cqosdb::ConfigFile::readInto | ( | T & | var, | |
const string & | key, | |||
const T & | value | |||
) | const [inline] |
Get the value corresponding to key and store in var.
Return true if key is found Otherwise set var to given default value in 'value'
void cqosdb::ConfigFile::add | ( | string | key, | |
const T & | value | |||
) | [inline] |
Add keys and values.
void cqosdb::ConfigFile::remove | ( | const string & | key | ) |
Delete key and value.
bool cqosdb::ConfigFile::keyExists | ( | const string & | key | ) | const |
Check whether a key exists in configuration.
string cqosdb::ConfigFile::getDelimiter | ( | ) | [inline] |
Grab separator between key and value.
string cqosdb::ConfigFile::getComment | ( | ) | [inline] |
Grab insicator of comment.
void cqosdb::ConfigFile::setDelimiter | ( | const string & | s | ) | [inline] |
Set separator between key and value.
void cqosdb::ConfigFile::setComment | ( | const string & | s | ) | [inline] |
Set indicator of comment.
ostream& operator<< | ( | ostream & | os, | |
const ConfigFile & | cf | |||
) | [friend] |
Save a ConfigFile to os.
istream& operator>> | ( | istream & | is, | |
ConfigFile & | cf | |||
) | [friend] |
Load a ConfigFile from is, Read in keys and values.
string cqosdb::ConfigFile::myDelimiter [protected] |
separator between key and value
string cqosdb::ConfigFile::myComment [protected] |
indicator of comments
map<string,string> cqosdb::ConfigFile::myContents [protected] |
extracted keys and values