#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
//---------------------------------------------------------------------------
bool StringCaseCmp(const std::string & str1, const std::string & str2)
//---------------------------------------------------------------------------
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())
{
char *res;
- *val = strtol(it->second.c_str(), &res, 10);
+ *val = static_cast<int>(strtol(it->second.c_str(), &res, 10));
if (*res != 0)
{
*val = defaultVal; //Error!
//---------------------------------------------------------------------------
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())
{
char *res;
- *val = strtoul(it->second.c_str(), &res, 10);
+ *val = static_cast<unsigned int>(strtoul(it->second.c_str(), &res, 10));
if (*res != 0)
{
*val = defaultVal; //Error!
//---------------------------------------------------------------------------
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";