--- smsdaemon/ConfigFile.cpp 2008/12/07 20:06:12 146 +++ smsdaemon/ConfigFile.cpp 2008/12/18 23:29:23 202 @@ -1,6 +1,7 @@ #include "ConfigFile.h" #include +#include const char SEPERATOR = '/'; @@ -61,8 +62,7 @@ name = trim(line.substr(0,posEqual)); value = trim(line.substr(posEqual+1)); - - content_[inSection+SEPERATOR+name]=Value(value); + content_.insert(std::make_pair(inSection+SEPERATOR+name,Value(value))); } return true; } @@ -70,13 +70,26 @@ Value const& ConfigFile::GetValue(std::string const& section, std::string const& entry) const { - std::map::const_iterator ci = content_.find(section + SEPERATOR + entry); + content_iterator ci = content_.find(section + SEPERATOR + entry); if (ci == content_.end()) throw "does not exist"; return ci->second; } +std::vector ConfigFile::GetValues(std::string const& section, std::string const& entry) const +{ + std::vector values; + std::string search = section + SEPERATOR + entry; + std::pair range = content_.equal_range(search); + + for (content_iterator it=range.first; it != range.second; ++it) + { + values.push_back( it->second ); + } + return values; +} + Value const& ConfigFile::GetValue(std::string const& section, std::string const& entry, double value) { try @@ -85,7 +98,7 @@ } catch (const char *) { - return content_.insert(std::make_pair(section+SEPERATOR+entry, Value(value))).first->second; + return content_.insert(std::make_pair(section+SEPERATOR+entry, Value(value)))->second; } } @@ -97,7 +110,16 @@ } catch (const char *) { - return content_.insert(std::make_pair(section+SEPERATOR+entry, Value(value))).first->second; + return content_.insert(std::make_pair(section+SEPERATOR+entry, Value(value)))->second; } } +std::string ConfigFile::DumpConfig() const +{ + std::ostringstream ss; + for (content_iterator it=content_.begin(); it!=content_.end(); ++it) + { + ss << it->first << "=" << it->second.StringValue() << std::endl; + } + return ss.str(); +}