46 #ifndef IBRCOMMON_CONFIGFILE_H
47 #define IBRCOMMON_CONFIGFILE_H
67 typedef std::map<string,string>::iterator
mapi;
68 typedef std::map<string,string>::const_iterator
mapci;
73 string delimiter =
"=",
75 string sentry =
"EndConfigFile" );
79 template<
class T> T
read(
const string& key )
const;
80 template<
class T> T
read(
const string& key,
const T& value )
const;
81 template<
class T>
bool readInto( T& var,
const string& key )
const;
83 bool readInto( T& var,
const string& key,
const T& value )
const;
86 template<
class T>
void add(
string key,
const T& value );
87 void remove(
const string& key );
90 bool keyExists(
const string& key )
const;
106 template<
class T>
static string T_as_string(
const T& t );
107 template<
class T>
static T
string_as_T(
const string& s );
108 static void trim(
string& s );
130 std::ostringstream ost;
143 std::istringstream ist(s);
151 inline string ConfigFile::string_as_T<string>(
const string& s )
161 inline bool ConfigFile::string_as_T<bool>(
const string& s )
168 for( string::iterator p = sup.begin(); p != sup.end(); ++p )
169 *p = static_cast<char>(toupper(*p));
170 if( sup==
string(
"FALSE") || sup==string(
"F") ||
171 sup==string(
"NO") || sup==string(
"N") ||
172 sup==string(
"0") || sup==string(
"NONE") )
184 return string_as_T<T>( p->second );
195 return string_as_T<T>( p->second );
207 if( found ) var = string_as_T<T>( p->second );
221 var = string_as_T<T>( p->second );
240 #endif // CONFIGFILE_H