X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/d49162286e811faacd7d7f3277da61efdfb635db..04af0b0b4df91a7a1f579edf17f49a81d10db592:/stglibs/conffiles.lib/conffiles.cpp?ds=sidebyside diff --git a/stglibs/conffiles.lib/conffiles.cpp b/stglibs/conffiles.lib/conffiles.cpp index 3c3f3917..a9c3e555 100644 --- a/stglibs/conffiles.lib/conffiles.cpp +++ b/stglibs/conffiles.lib/conffiles.cpp @@ -35,6 +35,7 @@ #include // E* #include +#include #include #include @@ -74,7 +75,7 @@ std::string Trim(std::string val) return TrimR(TrimL(val)); } //--------------------------------------------------------------------------- -} +} // namespace anonymous //--------------------------------------------------------------------------- bool StringCaseCmp(const std::string & str1, const std::string & str2) @@ -139,7 +140,7 @@ return e; //--------------------------------------------------------------------------- int CONFIGFILE::ReadString(const std::string & param, std::string * val, const std::string & defaultVal) const { -const std::map::const_iterator it(param_val.find(param)); +const std::map::const_iterator it(param_val.find(param)); if (it != param_val.end()) { @@ -159,7 +160,7 @@ changed = true; //--------------------------------------------------------------------------- int CONFIGFILE::ReadTime(const std::string & param, time_t * val, time_t defaultVal) const { -const std::map::const_iterator it(param_val.find(param)); +const std::map::const_iterator it(param_val.find(param)); if (it != param_val.end()) { @@ -179,12 +180,12 @@ return -1; //--------------------------------------------------------------------------- int CONFIGFILE::ReadInt(const std::string & param, int * val, int defaultVal) const { -const std::map::const_iterator it(param_val.find(param)); +const std::map::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(strtol(it->second.c_str(), &res, 10)); if (*res != 0) { *val = defaultVal; //Error! @@ -199,12 +200,12 @@ return -1; //--------------------------------------------------------------------------- int CONFIGFILE::ReadUInt(const std::string & param, unsigned int * val, unsigned int defaultVal) const { -const std::map::const_iterator it(param_val.find(param)); +const std::map::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(strtoul(it->second.c_str(), &res, 10)); if (*res != 0) { *val = defaultVal; //Error! @@ -219,7 +220,7 @@ return -1; //--------------------------------------------------------------------------- int CONFIGFILE::ReadLongInt(const std::string & param, long int * val, long int defaultVal) const { -const std::map::const_iterator it(param_val.find(param)); +const std::map::const_iterator it(param_val.find(param)); if (it != param_val.end()) { @@ -239,7 +240,7 @@ return -1; //--------------------------------------------------------------------------- int CONFIGFILE::ReadULongInt(const std::string & param, unsigned long int * val, unsigned long int defaultVal) const { -const std::map::const_iterator it(param_val.find(param)); +const std::map::const_iterator it(param_val.find(param)); if (it != param_val.end()) { @@ -259,7 +260,7 @@ return -1; //--------------------------------------------------------------------------- int CONFIGFILE::ReadLongLongInt(const std::string & param, int64_t * val, int64_t defaultVal) const { -const std::map::const_iterator it(param_val.find(param)); +const std::map::const_iterator it(param_val.find(param)); if (it != param_val.end()) { @@ -279,7 +280,7 @@ return -1; //--------------------------------------------------------------------------- int CONFIGFILE::ReadULongLongInt(const std::string & param, uint64_t * val, uint64_t defaultVal) const { -const std::map::const_iterator it(param_val.find(param)); +const std::map::const_iterator it(param_val.find(param)); if (it != param_val.end()) { @@ -299,7 +300,7 @@ return -1; //--------------------------------------------------------------------------- int CONFIGFILE::ReadShortInt(const std::string & param, short int * val, short int defaultVal) const { -const std::map::const_iterator it(param_val.find(param)); +const std::map::const_iterator it(param_val.find(param)); if (it != param_val.end()) { @@ -319,7 +320,7 @@ return -1; //--------------------------------------------------------------------------- int CONFIGFILE::ReadUShortInt(const std::string & param, unsigned short int * val, unsigned short int defaultVal) const { -const std::map::const_iterator it(param_val.find(param)); +const std::map::const_iterator it(param_val.find(param)); if (it != param_val.end()) { @@ -345,9 +346,17 @@ param_val[param] = buf; changed = true; } //--------------------------------------------------------------------------- +void CONFIGFILE::WriteTime(const std::string & param, time_t val) +{ +std::stringstream ss; +ss<::const_iterator it(param_val.find(param)); +const std::map::const_iterator it(param_val.find(param)); if (it != param_val.end()) { @@ -382,7 +391,7 @@ if (!f.is_open()) return EIO; } -std::map::const_iterator it = param_val.begin(); +std::map::const_iterator it = param_val.begin(); while (it != param_val.end()) { f << it->first << "=" << it->second << "\n";