ConfigFile Class Reference

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 >
read (const string &key, const T &value) const
template<class T >
read (const string &key) const
template<class T >
read (const string &sectionKey, const string &key)
template<class T >
bool readInto (T &var, const string &key) const
template<class T >
bool readInto (T &var, const string &sectionKey, 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 &sectionKey, const string &key)
void save ()
bool keyExists (const string &key) const
bool keyExists (const string &sectionKey, const string &key)
bool sectionExists (const string &sectionKey)
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
SortTreeVectormySortVectorObj
std::map< string, string > myContents
std::map< string, std::map
< string, string > > 
mySectionRelatedContents
std::vector< SortTreeVectormySortVector

Friends

std::ostream & operator<< (std::ostream &os, ConfigFile &cf)
std::istream & operator>> (std::istream &is, ConfigFile &cf)

Detailed Description

Reads and writes a configuration file.

Definition at line 126 of file ConfigFile.hpp.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

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.


Member Function Documentation

void add ( string  sectionKey,
string  key,
const T &  value 
) [inline]

Definition at line 371 of file ConfigFile.hpp.

Here is the call graph for this function:

void add ( string  key,
const T &  value 
) [inline]

Definition at line 356 of file ConfigFile.hpp.

Here is the call graph for this function:

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]

Definition at line 245 of file ConfigFile.hpp.

Here is the caller graph for this function:

void trim ( string &  s  )  [static, protected]

Definition at line 97 of file ConfigFile.cpp.

Here is the caller graph for this function:


Friends And Related Function Documentation

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.


Field Documentation

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.

Definition at line 135 of file ConfigFile.hpp.


The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.3