From 3923650aeb75611023aa1d46a4328838c8e0a33c Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Sun, 16 Aug 2020 14:11:21 +0200 Subject: Core/ChatCommands: Add support for enum type arguments (PR #25242) (cherry picked from commit 5e40eb20e2789b86d4786d86b4bbb8ae83de5e1e) --- src/common/Utilities/Util.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/common/Utilities/Util.cpp') diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index 42f87c36991..42064cc3466 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -652,6 +652,11 @@ void wstrToUpper(std::wstring& str) std::transform(str.begin(), str.end(), str.begin(), wcharToUpper); } +void strToLower(std::string& str) +{ + std::transform(str.begin(), str.end(), str.begin(), [](char c) { return std::tolower(c); }); +} + void wstrToLower(std::wstring& str) { std::transform(str.begin(), str.end(), str.begin(), wcharToLower); @@ -848,6 +853,20 @@ bool StringToBool(std::string const& str) return lowerStr == "1" || lowerStr == "true" || lowerStr == "yes"; } +bool StringEqualI(std::string const& str1, std::string const& str2) +{ + return std::equal(str1.begin(), str1.end(), str2.begin(), str2.end(), + [](char a, char b) + { + return std::tolower(a) == std::tolower(b); + }); +} + +bool StringStartsWith(std::string const& haystack, std::string const& needle) +{ + return (haystack.rfind(needle, 0) == 0); +} + bool StringContainsStringI(std::string const& haystack, std::string const& needle) { return haystack.end() != -- cgit v1.2.3