IBR-DTNSuite  0.10
ibrcommon::ConfigFile Class Reference

#include <ConfigFile.h>

Collaboration diagram for ibrcommon::ConfigFile:
Collaboration graph

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)
 
template<class T >
string T_as_string (const T &t)
 
template<class T >
string_as_T (const string &s)
 

Protected Types

typedef std::map< string,
string >::iterator 
mapi
 
typedef std::map< string,
string >::const_iterator 
mapci
 

Protected Member Functions

template<>
string string_as_T (const string &s)
 
template<>
bool string_as_T (const string &s)
 

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 59 of file ConfigFile.h.

Member Typedef Documentation

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

Definition at line 68 of file ConfigFile.h.

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

Definition at line 67 of file ConfigFile.h.

Constructor & Destructor Documentation

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

Definition at line 34 of file ConfigFile.cpp.

ibrcommon::ConfigFile::ConfigFile ( )

Definition at line 48 of file ConfigFile.cpp.

Member Function Documentation

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

Definition at line 229 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 94 of file ConfigFile.h.

References myComment.

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

Definition at line 93 of file ConfigFile.h.

References myDelimiter.

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

Definition at line 95 of file ConfigFile.h.

References mySentry.

bool ibrcommon::ConfigFile::keyExists ( const string &  key) const

Definition at line 63 of file ConfigFile.cpp.

References myContents.

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

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

Definition at line 189 of file ConfigFile.h.

References myContents.

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

Definition at line 200 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 213 of file ConfigFile.h.

References myContents.

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

Definition at line 55 of file ConfigFile.cpp.

References myContents.

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

Definition at line 98 of file ConfigFile.h.

References myComment.

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

Definition at line 96 of file ConfigFile.h.

References myDelimiter.

template<class T >
static T ibrcommon::ConfigFile::string_as_T ( const string &  s)
staticprotected
template<class T >
T ibrcommon::ConfigFile::string_as_T ( const string &  s)

Definition at line 138 of file ConfigFile.h.

template<>
string ibrcommon::ConfigFile::string_as_T ( const string &  s)
inlineprotected

Definition at line 151 of file ConfigFile.h.

template<>
bool ibrcommon::ConfigFile::string_as_T ( const string &  s)
inlineprotected

Definition at line 161 of file ConfigFile.h.

template<class T >
static string ibrcommon::ConfigFile::T_as_string ( const T &  t)
staticprotected

Referenced by add().

template<class T >
string ibrcommon::ConfigFile::T_as_string ( const T &  t)

Definition at line 126 of file ConfigFile.h.

void ibrcommon::ConfigFile::trim ( string &  s)
staticprotected

Definition at line 72 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 81 of file ConfigFile.cpp.

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

Definition at line 95 of file ConfigFile.cpp.

Member Data Documentation

string ibrcommon::ConfigFile::myComment
protected

Definition at line 63 of file ConfigFile.h.

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

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

Definition at line 64 of file ConfigFile.h.

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


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