aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Utilities/Util.cpp19
-rw-r--r--src/common/Utilities/Util.h3
2 files changed, 22 insertions, 0 deletions
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() !=
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h
index a7f6619838a..d048f3437aa 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -324,6 +324,7 @@ inline bool isUpper(wchar_t wchar)
TC_COMMON_API std::wstring wstrCaseAccentInsensitiveParse(std::wstring const& wstr, LocaleConstant locale);
TC_COMMON_API void wstrToUpper(std::wstring& str);
+TC_COMMON_API void strToLower(std::string& str);
TC_COMMON_API void wstrToLower(std::wstring& str);
TC_COMMON_API std::wstring GetMainPartOfName(std::wstring const& wname, uint32 declension);
@@ -377,6 +378,8 @@ inline std::vector<uint8> HexStrToByteVector(std::string const& str, bool revers
TC_COMMON_API bool StringToBool(std::string const& str);
TC_COMMON_API float DegToRad(float degrees);
+TC_COMMON_API bool StringEqualI(std::string const& str1, std::string const& str2);
+TC_COMMON_API bool StringStartsWith(std::string const& haystack, std::string const& needle);
TC_COMMON_API bool StringContainsStringI(std::string const& haystack, std::string const& needle);
template <typename T>
inline bool ValueContainsStringI(std::pair<T, std::string> const& haystack, std::string const& needle)