mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-07-27 02:10:38 +00:00
fix: make info strings case insensitive (#871)
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user