Remove some boost includes
The less we rely on boost, and more on std algorithms, the less people
have to look up, and the more likely that our code will deduplicate.
Replace all uses of boost::algorithms with std alternatives.
Tested: Redfish Service Validator passes.
Change-Id: I8a26f39b5709adc444b4178e92f5f3c7b988b05b
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/include/str_utility.hpp b/include/str_utility.hpp
index 7142583..8ac54b9 100644
--- a/include/str_utility.hpp
+++ b/include/str_utility.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <algorithm>
+#include <ranges>
#include <string>
#include <string_view>
#include <vector>
@@ -21,4 +23,22 @@
start = end + 1;
}
}
+
+inline char asciiToLower(char c)
+{
+ // Converts a character to lower case without relying on std::locale
+ if ('A' <= c && c <= 'Z')
+ {
+ c -= ('A' - 'a');
+ }
+ return c;
+}
+
+inline bool asciiIEquals(std::string_view left, std::string_view right)
+{
+ return std::ranges::equal(left, right, [](char lChar, char rChar) {
+ return asciiToLower(lChar) == asciiToLower(rChar);
+ });
+}
+
} // namespace bmcweb