cqosdb::ConfigFile Class Reference

A class intended to read in PerfDMF configuration file and parse parameter. More...

#include <ParseDBConfig.hxx>

List of all members.

Public Member Functions

 ConfigFile (string filename, string delimiter=":", string comment="#")
 Construct a ConfigFile, getting keys and values from given file.
 ConfigFile ()
template<class T>
read (const string &key) const
 Read the value corresponding to key.
template<class 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...


Detailed Description

A class intended to read in PerfDMF configuration file and parse parameter.

Member Typedef Documentation

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

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


Constructor & Destructor Documentation

cqosdb::ConfigFile::ConfigFile ( string  filename,
string  delimiter = ":",
string  comment = "#" 
)

Construct a ConfigFile, getting keys and values from given file.

cqosdb::ConfigFile::ConfigFile (  ) 


Member Function Documentation

template<class T>
T cqosdb::ConfigFile::read ( const string &  key  )  const [inline]

Read the value corresponding to key.

template<class T>
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.

template<class T>
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

template<class T>
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'

template<class T>
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.


Friends And Related Function Documentation

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.


Member Data Documentation

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


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

Generated on Tue Sep 23 19:59:06 2008 for CQoS Database Library by  doxygen 1.5.5