#include <cerrno> // E*
#include <cstring>
+#include <sstream>
#include <cstdlib>
#include <cstdio>
return val;
}
//---------------------------------------------------------------------------
-std::string Trim(std::string val)
+std::string Trim(const std::string& val)
{
return TrimR(TrimL(val));
}
-}
//---------------------------------------------------------------------------
} // namespace anonymous
return;
}
-<<<<<<< Updated upstream
std::string parameter = Trim(line.substr(0, pos));
std::string value = Trim(line.substr(pos + 1));
-=======
- std::string parameter = line.substr(0, pos);
- std::string value = line.substr(pos + 1);
->>>>>>> Stashed changes
param_val[parameter] = value;
}
}
//---------------------------------------------------------------------------
int CONFIGFILE::ReadString(const std::string & param, std::string * val, const std::string & defaultVal) const
{
-const std::map<std::string, std::string>::const_iterator it(param_val.find(param));
+const std::map<std::string, std::string, StringCaseCmp_t>::const_iterator it(param_val.find(param));
if (it != param_val.end())
{
//---------------------------------------------------------------------------
int CONFIGFILE::ReadTime(const std::string & param, time_t * val, time_t defaultVal) const
{
-const std::map<std::string, std::string>::const_iterator it(param_val.find(param));
+const std::map<std::string, std::string, StringCaseCmp_t>::const_iterator it(param_val.find(param));
if (it != param_val.end())
{
//---------------------------------------------------------------------------
int CONFIGFILE::ReadInt(const std::string & param, int * val, int defaultVal) const
{
-const std::map<std::string, std::string>::const_iterator it(param_val.find(param));
+const std::map<std::string, std::string, StringCaseCmp_t>::const_iterator it(param_val.find(param));
if (it != param_val.end())
{
//---------------------------------------------------------------------------
int CONFIGFILE::ReadUInt(const std::string & param, unsigned int * val, unsigned int defaultVal) const
{
-const std::map<std::string, std::string>::const_iterator it(param_val.find(param));
+const std::map<std::string, std::string, StringCaseCmp_t>::const_iterator it(param_val.find(param));
if (it != param_val.end())
{
//---------------------------------------------------------------------------
int CONFIGFILE::ReadLongInt(const std::string & param, long int * val, long int defaultVal) const
{
-const std::map<std::string, std::string>::const_iterator it(param_val.find(param));
+const std::map<std::string, std::string, StringCaseCmp_t>::const_iterator it(param_val.find(param));
if (it != param_val.end())
{
//---------------------------------------------------------------------------
int CONFIGFILE::ReadULongInt(const std::string & param, unsigned long int * val, unsigned long int defaultVal) const
{
-const std::map<std::string, std::string>::const_iterator it(param_val.find(param));
+const std::map<std::string, std::string, StringCaseCmp_t>::const_iterator it(param_val.find(param));
if (it != param_val.end())
{
//---------------------------------------------------------------------------
int CONFIGFILE::ReadLongLongInt(const std::string & param, int64_t * val, int64_t defaultVal) const
{
-const std::map<std::string, std::string>::const_iterator it(param_val.find(param));
+const std::map<std::string, std::string, StringCaseCmp_t>::const_iterator it(param_val.find(param));
if (it != param_val.end())
{
//---------------------------------------------------------------------------
int CONFIGFILE::ReadULongLongInt(const std::string & param, uint64_t * val, uint64_t defaultVal) const
{
-const std::map<std::string, std::string>::const_iterator it(param_val.find(param));
+const std::map<std::string, std::string, StringCaseCmp_t>::const_iterator it(param_val.find(param));
if (it != param_val.end())
{
//---------------------------------------------------------------------------
int CONFIGFILE::ReadShortInt(const std::string & param, short int * val, short int defaultVal) const
{
-const std::map<std::string, std::string>::const_iterator it(param_val.find(param));
+const std::map<std::string, std::string, StringCaseCmp_t>::const_iterator it(param_val.find(param));
if (it != param_val.end())
{
//---------------------------------------------------------------------------
int CONFIGFILE::ReadUShortInt(const std::string & param, unsigned short int * val, unsigned short int defaultVal) const
{
-const std::map<std::string, std::string>::const_iterator it(param_val.find(param));
+const std::map<std::string, std::string, StringCaseCmp_t>::const_iterator it(param_val.find(param));
if (it != param_val.end())
{
changed = true;
}
//---------------------------------------------------------------------------
+void CONFIGFILE::WriteTime(const std::string & param, time_t val)
+{
+std::stringstream ss;
+ss<<val;
+param_val[param] = ss.str();
+changed = true;
+}
+//---------------------------------------------------------------------------
int CONFIGFILE::ReadDouble(const std::string & param, double * val, double defaultVal) const
{
-const std::map<std::string, std::string>::const_iterator it(param_val.find(param));
+const std::map<std::string, std::string, StringCaseCmp_t>::const_iterator it(param_val.find(param));
if (it != param_val.end())
{
return EIO;
}
-std::map<std::string, std::string>::const_iterator it = param_val.begin();
+std::map<std::string, std::string, StringCaseCmp_t>::const_iterator it = param_val.begin();
while (it != param_val.end())
{
f << it->first << "=" << it->second << "\n";