IBR-DTNSuite  0.8
ibrcommon::ConfigFile Class Reference

#include <ConfigFile.h>

Collaboration diagram for ibrcommon::ConfigFile:

List of all members.

Classes

struct  file_not_found
struct  key_not_found

Public Member Functions

 ConfigFile (string filename, string delimiter="=", string comment="#", string sentry="EndConfigFile")
 ConfigFile ()
template<class T >
read (const string &key) const
template<class T >
read (const string &key, const T &value) const
template<class T >
bool readInto (T &var, const string &key) const
template<class T >
bool readInto (T &var, const string &key, const T &value) const
template<class T >
void add (string key, const T &value)
void remove (const string &key)
bool keyExists (const string &key) const
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

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 mySentry
std::map< string, string > myContents

Friends

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

Detailed Description

Definition at line 56 of file ConfigFile.h.


Member Typedef Documentation

typedef std::map<string,string>::const_iterator ibrcommon::ConfigFile::mapci [protected]

Definition at line 65 of file ConfigFile.h.

typedef std::map<string,string>::iterator ibrcommon::ConfigFile::mapi [protected]

Definition at line 64 of file ConfigFile.h.


Constructor & Destructor Documentation

ibrcommon::ConfigFile::ConfigFile ( string  filename,
string  delimiter = "=",
string  comment = "#",
string  sentry = "EndConfigFile" 
)

Definition at line 8 of file ConfigFile.cpp.

Definition at line 22 of file ConfigFile.cpp.


Member Function Documentation

template<class T >
void ibrcommon::ConfigFile::add ( string  key,
const T &  value 
)

Definition at line 226 of file ConfigFile.h.

References myContents, T_as_string(), and trim().

Referenced by dtn::daemon::Configuration::load().

Here is the call graph for this function:

string ibrcommon::ConfigFile::getComment ( ) const [inline]

Definition at line 91 of file ConfigFile.h.

References myComment.

string ibrcommon::ConfigFile::getDelimiter ( ) const [inline]

Definition at line 90 of file ConfigFile.h.

References myDelimiter.

string ibrcommon::ConfigFile::getSentry ( ) const [inline]

Definition at line 92 of file ConfigFile.h.

References mySentry.

bool ibrcommon::ConfigFile::keyExists ( const string &  key) const
template<class T >
T ibrcommon::ConfigFile::read ( const string &  key,
const T &  value 
) const

Definition at line 186 of file ConfigFile.h.

References myContents.

template<class T >
bool ibrcommon::ConfigFile::readInto ( T &  var,
const string &  key 
) const

Definition at line 197 of file ConfigFile.h.

References myContents.

template<class T >
bool ibrcommon::ConfigFile::readInto ( T &  var,
const string &  key,
const T &  value 
) const

Definition at line 210 of file ConfigFile.h.

References myContents.

void ibrcommon::ConfigFile::remove ( const string &  key)

Definition at line 29 of file ConfigFile.cpp.

References myContents.

string ibrcommon::ConfigFile::setComment ( const string &  s) [inline]

Definition at line 95 of file ConfigFile.h.

References myComment.

string ibrcommon::ConfigFile::setDelimiter ( const string &  s) [inline]

Definition at line 93 of file ConfigFile.h.

References myDelimiter.

bool ibrcommon::ConfigFile::string_as_T< bool > ( const string &  s) [inline, static, protected]

Definition at line 135 of file ConfigFile.h.

template<class T >
string ibrcommon::ConfigFile::T_as_string ( const T &  t) [static, protected]

Definition at line 123 of file ConfigFile.h.

Referenced by add().

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

Definition at line 46 of file ConfigFile.cpp.

Referenced by add(), and ibrcommon::operator>>().


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const ConfigFile cf 
) [friend]

Definition at line 55 of file ConfigFile.cpp.

std::istream& operator>> ( std::istream &  is,
ConfigFile cf 
) [friend]

Definition at line 69 of file ConfigFile.cpp.


Member Data Documentation

Definition at line 60 of file ConfigFile.h.

Referenced by getComment(), ibrcommon::operator>>(), and setComment().

std::map<string,string> ibrcommon::ConfigFile::myContents [protected]
string ibrcommon::ConfigFile::mySentry [protected]

Definition at line 61 of file ConfigFile.h.

Referenced by getSentry(), and ibrcommon::operator>>().


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