X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/45f7304806cbe47a5235c43e25e54f2a043bc42b..bc4721533e4041a19b42cb247064f9f42c3f9d5f:/projects/sgauth/settings_impl.cpp?ds=sidebyside diff --git a/projects/sgauth/settings_impl.cpp b/projects/sgauth/settings_impl.cpp index bcb56170..f8536420 100644 --- a/projects/sgauth/settings_impl.cpp +++ b/projects/sgauth/settings_impl.cpp @@ -21,9 +21,9 @@ #include #include +#include "stg/common.h" +#include "stg/conffiles.h" #include "settings_impl.h" -#include "common.h" -#include "conffiles.h" SETTINGS_IMPL::SETTINGS_IMPL() : port(0), @@ -38,71 +38,6 @@ SETTINGS_IMPL::SETTINGS_IMPL() { } //----------------------------------------------------------------------------- -int SETTINGS_IMPL::ParseYesNo(const string & value, bool * val) -{ -if (0 == strcasecmp(value.c_str(), "yes")) - { - *val = true; - return 0; - } -if (0 == strcasecmp(value.c_str(), "no")) - { - *val = false; - return 0; - } - -strError = "Incorrect value \'" + value + "\'."; -return -1; -} -//----------------------------------------------------------------------------- -int SETTINGS_IMPL::ParseInt(const string & value, int * val) -{ -if (str2x(value, *val)) - { - strError = "Cannot convert \'" + value + "\' to integer."; - return -1; - } -return 0; -} -//----------------------------------------------------------------------------- -int SETTINGS_IMPL::ParseUnsigned(const string & value, unsigned * val) -{ -if (str2x(value, *val)) - { - strError = "Cannot convert \'" + value + "\' to unsigned integer."; - return -1; - } -return 0; -} -//----------------------------------------------------------------------------- -int SETTINGS_IMPL::ParseIntInRange(const string & value, int min, int max, int * val) -{ -if (ParseInt(value, val) != 0) - return -1; - -if (*val < min || *val > max) - { - strError = "Value \'" + value + "\' out of range."; - return -1; - } - -return 0; -} -//----------------------------------------------------------------------------- -int SETTINGS_IMPL::ParseUnsignedInRange(const string & value, unsigned min, unsigned max, unsigned * val) -{ -if (ParseUnsigned(value, val) != 0) - return -1; - -if (*val < min || *val > max) - { - strError = "Value \'" + value + "\' out of range."; - return -1; - } - -return 0; -} -//----------------------------------------------------------------------------- int SETTINGS_IMPL::ReadSettings() { CONFIGFILE cf(confFile);