Ref T709, move case insensitive compare to utils (so it can be used elsewhere)

This commit is contained in:
Klaus Basan
2019-07-25 16:05:21 +02:00
committed by Mat Sutcliffe
parent 14bb3ea249
commit cc4b8b61ae
2 changed files with 19 additions and 15 deletions

View File

@@ -129,6 +129,16 @@ namespace BlackMisc
return s;
}
//! Compare case insensitive
inline bool stringCompareCaseInsensitive(const std::string &str1, const std::string &str2)
{
if (str1.size() != str2.size()) { return false; }
return std::equal(str1.begin(), str1.end(), str2.begin(), [](const char &c1, const char &c2)
{
return (c1 == c2 || std::toupper(c1) == std::toupper(c2));
});
}
//! Trim whitespace from the beginning and end, and replace sequences of whitespace with single space characters
inline std::string simplifyWhitespace(const std::string &s)
{