8 string comment,
string sentry )
9 : myDelimiter(delimiter), myComment(comment), mySentry(sentry),file(filename),listmode(isList)
13 std::ifstream in( filename.c_str() );
22 : myDelimiter( string(1,
'=') ), myComment( string(2,
'#') ),listmode(false)
32 std::ifstream in( filename.c_str() );
41 std::ofstream out(
file.c_str() );
67 static const char whitespace[] =
" \n\t\v\r\f";
68 s.erase( 0, s.find_first_not_of(whitespace) );
69 s.erase( s.find_last_not_of(whitespace) + 1U );
80 os << p->first <<
" " ;
96 typedef string::size_type pos;
100 const pos skip = delim.length();
102 string nextline =
"";
104 while( is || nextline.length() > 0 )
108 if( nextline.length() > 0 )
115 std::getline( is, line );
119 line = line.substr( 0, line.find(comm) );
122 if( sentry !=
"" && line.find(sentry) != string::npos )
return is;
125 pos delimPos = line.find( delim );
126 if( delimPos < string::npos )
129 string key = line.substr( 0, delimPos );
130 line.replace( 0, delimPos+skip,
"" );
135 bool terminate =
false;
136 while( !terminate && is )
138 std::getline( is, nextline );
141 string nlcopy = nextline;
143 if( nlcopy ==
"" )
continue;
145 nextline = nextline.substr( 0, nextline.find(comm) );
146 if( nextline.find(delim) != string::npos )
148 if( sentry !=
"" && nextline.find(sentry) != string::npos )
153 if( nlcopy !=
"" ) line +=
"\n";
std::map< string, string >::const_iterator mapci
static void trim(string &s)
bool keyExists(const string &key) const
void remove(const string &key)
std::ostream & operator<<(std::ostream &os, const ConfigFile &cf)
std::istream & operator>>(std::istream &is, ConfigFile &cf)
std::map< string, string > myContents
void load(string filename, bool isList=false)