fix: make info strings case insensitive (#871)

This commit is contained in:
Jan
2026-06-30 20:19:18 +02:00
committed by GitHub
parent c9595794a3
commit 3ab002db1d
5 changed files with 147 additions and 33 deletions
+28 -6
View File
@@ -1,6 +1,8 @@
#pragma once
#include "Obj/Gdt/GdtEntry.h"
#include "Utils/StreamUtils.h"
#include "Utils/StringUtils.h"
#include <istream>
#include <string>
@@ -9,13 +11,9 @@
class InfoString
{
static constexpr const char* GDT_PREFIX_FIELD = "configstringFileType";
static const std::string EMPTY_VALUE;
std::unordered_map<std::string, std::string> m_values;
std::vector<std::string> m_keys_by_insertion;
public:
InfoString() = default;
[[nodiscard]] bool HasKey(const std::string& key) const;
[[nodiscard]] const std::string& GetValueForKey(const std::string& key) const;
const std::string& GetValueForKey(const std::string& key, bool* foundValue) const;
@@ -29,4 +27,28 @@ public:
bool FromStream(std::istream& stream);
bool FromStream(const std::string& prefix, std::istream& stream);
bool FromGdtProperties(const GdtEntry& gdtEntry);
private:
class HashValue
{
public:
std::size_t operator()(const std::string& s) const noexcept
{
std::string lower(s);
utils::MakeStringLowerCase(lower);
return std::hash<std::string>{}(lower);
}
};
class EqualValue
{
public:
constexpr bool operator()(const std::string& lhs, const std::string& rhs) const
{
return utils::StringEqualsIgnoreCase(lhs, rhs);
}
};
std::unordered_map<std::string, std::string, HashValue, EqualValue> m_value_lookup;
std::vector<std::string> m_keys_by_insertion;
};