summaryrefslogtreecommitdiff
path: root/Source/Core/Common/StringUtil.h
diff options
context:
space:
mode:
authormitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-09-21 22:32:24 -0700
committermitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-09-21 23:15:42 -0700
commit508ccc2054590a9efa89054e742b74521f272063 (patch)
treeb611a93de812ddf6d1ed025d72f047c1d312e6f0 /Source/Core/Common/StringUtil.h
parent067bdaa3ddfad15b6c08b4ab59361ebd0a31066c (diff)
IniFile: Migrate `Common::CaseInsensitiveLess` to StringUtil
Migrating `Common::CaseInsensitiveLess` to StringUtil.h will hopefully discourage rolling one's own solution in the future for case-insensitive associative containers when this (quite robust!) solution already exists. `Common::CaseInsensitiveStringCompare::IsEqual` was removed in favor of using the `Common::CaseInsensitiveEquals` function. The `a.size() != b.size()` condition in `Common::CaseInsensitiveEquals` can be removed, since `std::ranges::equal` already checks this condition (confirmed in libc++).
Diffstat (limited to 'Source/Core/Common/StringUtil.h')
-rw-r--r--Source/Core/Common/StringUtil.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h
index c1eaf94ad4..ef7597a1e5 100644
--- a/Source/Core/Common/StringUtil.h
+++ b/Source/Core/Common/StringUtil.h
@@ -314,5 +314,13 @@ std::string GetEscapedHtml(std::string html);
void ToLower(std::string* str);
void ToUpper(std::string* str);
bool CaseInsensitiveEquals(std::string_view a, std::string_view b);
+
+// 'std::less'-like comparison function object type for case-insensitive strings.
+struct CaseInsensitiveLess
+{
+ using is_transparent = void; // Allow heterogenous lookup.
+ bool operator()(std::string_view a, std::string_view b) const;
+};
+
std::string BytesToHexString(std::span<const u8> bytes);
} // namespace Common