diff options
author | Kargatum <dowlandtop@yandex.com> | 2018-06-05 18:14:57 +0700 |
---|---|---|
committer | José González <Deku@users.noreply.github.com> | 2018-06-05 07:14:57 -0400 |
commit | f122ed57bf07575e89492701250f10fc190162dc (patch) | |
tree | 56a808106aa3640d26da1ab62bb7fa9ca6b0f911 /src/common/Configuration/Config.cpp | |
parent | e222cbbc0a19abe407cbb8df1fc8e04ddde19d16 (diff) |
Show default options, missing in config files (#908)
Diffstat (limited to 'src/common/Configuration/Config.cpp')
-rw-r--r-- | src/common/Configuration/Config.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/common/Configuration/Config.cpp b/src/common/Configuration/Config.cpp index 00f8398ee3..c5a65dc874 100644 --- a/src/common/Configuration/Config.cpp +++ b/src/common/Configuration/Config.cpp @@ -6,6 +6,7 @@ #include "Config.h" #include "Errors.h" +#include "Log.h" // Defined here as it must not be exposed to end-users. bool ConfigMgr::GetValueHelper(const char* name, ACE_TString &result) @@ -86,6 +87,15 @@ bool ConfigMgr::LoadData(char const* file) std::string ConfigMgr::GetStringDefault(const char* name, const std::string &def) { ACE_TString val; + + if (GetValueHelper(name, val)) + return val.c_str(); + else + { + sLog->outError("-> Not found option '%s'. The default value is used (%s)", name, def.c_str()); + return def; + } + return GetValueHelper(name, val) ? val.c_str() : def; } @@ -94,7 +104,10 @@ bool ConfigMgr::GetBoolDefault(const char* name, bool def) ACE_TString val; if (!GetValueHelper(name, val)) + { + def ? sLog->outError("-> Not found option '%s'. The default value is used (Yes)", name) : sLog->outError(">> Not found option '%s'. The default value is used (No)", name); return def; + } return (val == "true" || val == "TRUE" || val == "yes" || val == "YES" || val == "1"); @@ -103,13 +116,27 @@ bool ConfigMgr::GetBoolDefault(const char* name, bool def) int ConfigMgr::GetIntDefault(const char* name, int def) { ACE_TString val; - return GetValueHelper(name, val) ? atoi(val.c_str()) : def; + + if (GetValueHelper(name, val)) + return atoi(val.c_str()); + else + { + sLog->outError("-> Not found option '%s'. The default value is used (%i)", name, def); + return def; + } } float ConfigMgr::GetFloatDefault(const char* name, float def) { ACE_TString val; - return GetValueHelper(name, val) ? (float)atof(val.c_str()) : def; + + if (GetValueHelper(name, val)) + return (float)atof(val.c_str()); + else + { + sLog->outError("-> Not found option '%s'. The default value is used (%f)", name, def); + return def; + } } std::list<std::string> ConfigMgr::GetKeysByString(std::string const& name) |