SimpCfg: Use to_str instead of using stringstream directly

This commit is contained in:
HanishKVC 2024-05-04 17:20:52 +05:30
parent 5380b1e86e
commit c6ecd9316e

View file

@ -295,9 +295,9 @@ public:
void set_value(const std::string &group, const std::string &key, const SupportedDataType &value, const std::string &callerName="") { void set_value(const std::string &group, const std::string &key, const SupportedDataType &value, const std::string &callerName="") {
auto &gm = mapV[group]; auto &gm = mapV[group];
gm[key] = value; gm[key] = value;
std::stringstream ss; #ifdef SC_DEBUG
ss << value; LDBUG_LN("DBUG:SC:%s_%s:%s:%s:%s", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(value).c_str());
LDBUG_LN("DBUG:SC:%s_%s:%s:%s:%s", __func__, callerName.c_str(), group.c_str(), key.c_str(), ss.str().c_str()); #endif
} }
void set_string(const std::string &group, const std::string &key, const std::string &value) { void set_string(const std::string &group, const std::string &key, const std::string &value) {
@ -349,13 +349,15 @@ public:
SupportedDataType get_value(const std::string &group, const std::string &key, const SupportedDataType &defaultValue, const std::string &callerName="") { SupportedDataType get_value(const std::string &group, const std::string &key, const SupportedDataType &defaultValue, const std::string &callerName="") {
auto gm = mapV[group]; auto gm = mapV[group];
if (gm.find(key) == gm.end()) { if (gm.find(key) == gm.end()) {
std::stringstream ss; #ifdef SC_DEBUG
ss << defaultValue; LWARN_LN("WARN:SC:%s_%s:%s:%s:%s[default]", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(defaultValue).c_str());
LWARN_LN("DBUG:SC:%s_%s:%s:%s:%s[default]", __func__, callerName.c_str(), group.c_str(), key.c_str(), ss.str().c_str()); #endif
return defaultValue; return defaultValue;
} }
auto value = gm[key]; auto value = gm[key];
#ifdef SC_DEBUG
LDBUG_LN("DBUG:SC:%s_%s:%s:%s:%s", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(value).c_str()); LDBUG_LN("DBUG:SC:%s_%s:%s:%s:%s", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(value).c_str());
#endif
return std::get<SupportedDataType>(value); return std::get<SupportedDataType>(value);
} }