diff --git a/utils/basic/string_utils.h b/utils/basic/string_utils.h new file mode 100644 index 000000000..94f17636a --- /dev/null +++ b/utils/basic/string_utils.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include + +namespace datatypes +{ +inline bool ASCIIStringCaseInsensetiveEquals(const std::string& left, const std::string& right) +{ + auto asciiHigher = [](char c) { return (c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c; }; + return left.size() == right.size() && + std::equal(left.begin(), left.end(), right.begin(), + [&asciiHigher](char l, char r) { return asciiHigher(l) == asciiHigher(r); }); +} +} // namespace datatypes \ No newline at end of file