GroupKV: Rename the internal map

This commit is contained in:
HanishKVC 2024-05-11 18:23:06 +05:30
parent fdefb39518
commit dde72df9d3

View file

@ -57,11 +57,11 @@ class GroupKV {
private: private:
GroupKVMapMapVariant mapV = {}; GroupKVMapMapVariant gkv = {};
public: public:
GroupKV(GroupKVMapMapVariant defaultMap) : mapV(defaultMap) {} GroupKV(GroupKVMapMapVariant defaultMap) : gkv(defaultMap) {}
static std::string joiner(const MultiPart& parts) { static std::string joiner(const MultiPart& parts) {
std::stringstream joined; std::stringstream joined;
@ -103,7 +103,7 @@ public:
template<typename SupportedDataType> template<typename SupportedDataType>
void set_value(const std::string &group, const MultiPart &keyParts, const SupportedDataType &value, const std::string &callerName="") { void set_value(const std::string &group, const MultiPart &keyParts, const SupportedDataType &value, const std::string &callerName="") {
auto key = joiner(keyParts); auto key = joiner(keyParts);
auto &gm = mapV[group]; auto &gm = gkv[group];
gm[key] = value; gm[key] = value;
LDBUG_LN("DBUG:GKV:%s_%s:%s:%s:%s", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(value).c_str()); LDBUG_LN("DBUG:GKV:%s_%s:%s:%s:%s", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(value).c_str());
} }
@ -111,7 +111,7 @@ public:
// Dump info about the specified group. // Dump info about the specified group.
// If group is empty, then dump info about all groups maintained in this instance. // If group is empty, then dump info about all groups maintained in this instance.
void dump(const std::string &group) { void dump(const std::string &group) {
for (auto gm: mapV) { for (auto gm: gkv) {
if (!group.empty() && (gm.first != group)) { if (!group.empty() && (gm.first != group)) {
LINFO_LN("INFO:GKV:%s:%s:Skipping...", __func__, gm.first.c_str()); LINFO_LN("INFO:GKV:%s:%s:Skipping...", __func__, gm.first.c_str());
continue; continue;
@ -125,7 +125,7 @@ public:
template<typename SupportedDataType> template<typename SupportedDataType>
SupportedDataType get_value(const std::string &group, const MultiPart &keyParts, const SupportedDataType &defaultValue, const std::string &callerName="") { SupportedDataType get_value(const std::string &group, const MultiPart &keyParts, const SupportedDataType &defaultValue, const std::string &callerName="") {
auto key = joiner(keyParts); auto key = joiner(keyParts);
auto gm = mapV[group]; auto gm = gkv[group];
if (gm.find(key) == gm.end()) { if (gm.find(key) == gm.end()) {
LDBUG_LN("WARN:GKV:%s_%s:%s:%s:%s[default]", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(defaultValue).c_str()); LDBUG_LN("WARN:GKV:%s_%s:%s:%s:%s[default]", __func__, callerName.c_str(), group.c_str(), key.c_str(), to_str(defaultValue).c_str());
return defaultValue; return defaultValue;
@ -138,7 +138,7 @@ public:
template<typename SupportedDataType> template<typename SupportedDataType>
std::vector<SupportedDataType> get_vector(const std::string &group, const MultiPart &keyParts, const std::vector<SupportedDataType> &defaultValue, const std::string &callerName="") { std::vector<SupportedDataType> get_vector(const std::string &group, const MultiPart &keyParts, const std::vector<SupportedDataType> &defaultValue, const std::string &callerName="") {
auto key = joiner(keyParts); auto key = joiner(keyParts);
auto gm = mapV[group]; auto gm = gkv[group];
std::vector<SupportedDataType> array; std::vector<SupportedDataType> array;
int i = 0; int i = 0;
while(true) { while(true) {