diff --git a/src/Utils/InfoString.cpp b/src/Utils/InfoString.cpp index 523d7c0e..0dbd6429 100644 --- a/src/Utils/InfoString.cpp +++ b/src/Utils/InfoString.cpp @@ -10,17 +10,17 @@ namespace Utils void InfoString::set(const std::string& key, const std::string& value) { - this->keyValuePairs[key] = value; + this->keyValuePairs_[key] = value; } void InfoString::remove(const std::string& key) { - this->keyValuePairs.erase(key); + this->keyValuePairs_.erase(key); } std::string InfoString::get(const std::string& key) const { - if (const auto value = this->keyValuePairs.find(key); value != this->keyValuePairs.end()) + if (const auto value = this->keyValuePairs_.find(key); value != this->keyValuePairs_.end()) { return value->second; } @@ -35,13 +35,16 @@ namespace Utils buffer = buffer.substr(1); } - const auto keyValues = Utils::String::Split(buffer, '\\'); - + const auto keyValues = String::Split(buffer, '\\'); for (std::size_t i = 0; !keyValues.empty() && i < (keyValues.size() - 1); i += 2) { const auto& key = keyValues[i]; const auto& value = keyValues[i + 1]; - this->keyValuePairs[key] = value; + + if (!this->keyValuePairs_.contains(key)) + { + this->keyValuePairs_[key] = value; + } } } @@ -50,8 +53,7 @@ namespace Utils std::string infoString; auto first = true; - - for (const auto& [key, value] : this->keyValuePairs) + for (const auto& [key, value] : this->keyValuePairs_) { if (first) first = false; else infoString.append("\\"); @@ -67,7 +69,7 @@ namespace Utils #ifdef _DEBUG void InfoString::dump() { - for (const auto& [key, value] : this->keyValuePairs) + for (const auto& [key, value] : this->keyValuePairs_) { OutputDebugStringA(String::VA("%s: %s\n", key.data(), value.data())); } @@ -76,6 +78,6 @@ namespace Utils nlohmann::json InfoString::to_json() const { - return this->keyValuePairs; + return this->keyValuePairs_; } } diff --git a/src/Utils/InfoString.hpp b/src/Utils/InfoString.hpp index 3229eebb..ff0243ba 100644 --- a/src/Utils/InfoString.hpp +++ b/src/Utils/InfoString.hpp @@ -21,7 +21,8 @@ namespace Utils [[nodiscard]] nlohmann::json to_json() const; private: - std::unordered_map keyValuePairs; + std::unordered_map keyValuePairs_; + void parse(std::string buffer); }; }