git.stg.codes
/
stg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Ticket 37. TIMEZONE fixed to TIMESTAMP for the change_policy_timeout in
[stg.git]
/
stglibs
/
conffiles.lib
/
conffiles.cpp
diff --git
a/stglibs/conffiles.lib/conffiles.cpp
b/stglibs/conffiles.lib/conffiles.cpp
index 4fb72f618ddc6e5f60abab6dff8d754280008446..a9c3e555093a87e8e60cc7c7d946cfdf347865b8 100644
(file)
--- a/
stglibs/conffiles.lib/conffiles.cpp
+++ b/
stglibs/conffiles.lib/conffiles.cpp
@@
-35,6
+35,7
@@
#include <cerrno> // E*
#include <cstring>
#include <cerrno> // E*
#include <cstring>
+#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <cstdlib>
#include <cstdio>
@@
-73,7
+74,6
@@
std::string Trim(std::string val)
{
return TrimR(TrimL(val));
}
{
return TrimR(TrimL(val));
}
-}
//---------------------------------------------------------------------------
} // namespace anonymous
//---------------------------------------------------------------------------
} // namespace anonymous
@@
-115,13
+115,8
@@
while (getline(f, line))
return;
}
return;
}
-<<<<<<< Updated upstream
std::string parameter = Trim(line.substr(0, pos));
std::string value = Trim(line.substr(pos + 1));
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;
}
}
param_val[parameter] = value;
}
}
@@
-145,7
+140,7
@@
return e;
//---------------------------------------------------------------------------
int CONFIGFILE::ReadString(const std::string & param, std::string * val, const std::string & defaultVal) const
{
//---------------------------------------------------------------------------
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())
{
if (it != param_val.end())
{
@@
-165,7
+160,7
@@
changed = true;
//---------------------------------------------------------------------------
int CONFIGFILE::ReadTime(const std::string & param, time_t * val, time_t defaultVal) const
{
//---------------------------------------------------------------------------
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())
{
if (it != param_val.end())
{
@@
-185,7
+180,7
@@
return -1;
//---------------------------------------------------------------------------
int CONFIGFILE::ReadInt(const std::string & param, int * val, int defaultVal) const
{
//---------------------------------------------------------------------------
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())
{
if (it != param_val.end())
{
@@
-205,7
+200,7
@@
return -1;
//---------------------------------------------------------------------------
int CONFIGFILE::ReadUInt(const std::string & param, unsigned int * val, unsigned int defaultVal) const
{
//---------------------------------------------------------------------------
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())
{
if (it != param_val.end())
{
@@
-225,7
+220,7
@@
return -1;
//---------------------------------------------------------------------------
int CONFIGFILE::ReadLongInt(const std::string & param, long int * val, long int defaultVal) const
{
//---------------------------------------------------------------------------
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())
{
if (it != param_val.end())
{
@@
-245,7
+240,7
@@
return -1;
//---------------------------------------------------------------------------
int CONFIGFILE::ReadULongInt(const std::string & param, unsigned long int * val, unsigned long int defaultVal) const
{
//---------------------------------------------------------------------------
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())
{
if (it != param_val.end())
{
@@
-265,7
+260,7
@@
return -1;
//---------------------------------------------------------------------------
int CONFIGFILE::ReadLongLongInt(const std::string & param, int64_t * val, int64_t defaultVal) const
{
//---------------------------------------------------------------------------
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())
{
if (it != param_val.end())
{
@@
-285,7
+280,7
@@
return -1;
//---------------------------------------------------------------------------
int CONFIGFILE::ReadULongLongInt(const std::string & param, uint64_t * val, uint64_t defaultVal) const
{
//---------------------------------------------------------------------------
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())
{
if (it != param_val.end())
{
@@
-305,7
+300,7
@@
return -1;
//---------------------------------------------------------------------------
int CONFIGFILE::ReadShortInt(const std::string & param, short int * val, short int defaultVal) const
{
//---------------------------------------------------------------------------
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())
{
if (it != param_val.end())
{
@@
-325,7
+320,7
@@
return -1;
//---------------------------------------------------------------------------
int CONFIGFILE::ReadUShortInt(const std::string & param, unsigned short int * val, unsigned short int defaultVal) const
{
//---------------------------------------------------------------------------
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())
{
if (it != param_val.end())
{
@@
-351,9
+346,17
@@
param_val[param] = buf;
changed = true;
}
//---------------------------------------------------------------------------
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
{
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())
{
if (it != param_val.end())
{
@@
-388,7
+391,7
@@
if (!f.is_open())
return EIO;
}
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";
while (it != param_val.end())
{
f << it->first << "=" << it->second << "\n";