8 string comment,
string sentry )
9 : myDelimiter(delimiter), myComment(comment), mySentry(sentry)
13 std::ifstream in( filename.c_str() );
48 static const char whitespace[] =
" \n\t\v\r\f";
49 s.erase( 0, s.find_first_not_of(whitespace) );
50 s.erase( s.find_last_not_of(whitespace) + 1U );
62 os << p->second << std::endl;
72 typedef string::size_type pos;
76 const pos skip = delim.length();
80 while( is || nextline.length() > 0 )
84 if( nextline.length() > 0 )
91 std::getline( is, line );
95 line = line.substr( 0, line.find(comm) );
98 if( sentry !=
"" && line.find(sentry) != string::npos )
return is;
101 pos delimPos = line.find( delim );
102 if( delimPos < string::npos )
105 string key = line.substr( 0, delimPos );
106 line.replace( 0, delimPos+skip,
"" );
111 bool terminate =
false;
112 while( !terminate && is )
114 std::getline( is, nextline );
117 string nlcopy = nextline;
119 if( nlcopy ==
"" )
continue;
121 nextline = nextline.substr( 0, nextline.find(comm) );
122 if( nextline.find(delim) != string::npos )
124 if( sentry !=
"" && nextline.find(sentry) != string::npos )
129 if( nlcopy !=
"" ) line +=
"\n";
friend std::istream & operator>>(std::istream &is, ConfigFile &cf)
std::map< string, string >::const_iterator mapci
static void trim(string &s)
friend std::ostream & operator<<(std::ostream &os, const ConfigFile &cf)
void remove(const string &key)
std::map< string, string > myContents
bool keyExists(const string &key) const