diff --git a/source/mijin/util/string.hpp b/source/mijin/util/string.hpp index afaa00d..680cb0a 100644 --- a/source/mijin/util/string.hpp +++ b/source/mijin/util/string.hpp @@ -8,6 +8,8 @@ #include #include +#include "./iterators.hpp" + namespace mijin { @@ -28,7 +30,7 @@ namespace mijin // template -std::string join(const TRange& elements, const char* const delimiter) +[[nodiscard]] std::string join(const TRange& elements, const char* const delimiter) { std::ostringstream oss; auto first = std::begin(elements); @@ -47,6 +49,25 @@ std::string join(const TRange& elements, const char* const delimiter) return oss.str(); } +template +[[nodiscard]] bool equalsIgnoreCase(std::basic_string_view stringA, std::basic_string_view stringB) noexcept +{ + if (stringA.size() != stringB.size()) + { + return false; + } + + for (const auto [charA, charB] : zip(stringA, stringB)) + { + if (std::tolower(charA) != std::tolower(charB)) + { + return false; + } + } + + return true; +} + namespace pipe { struct Join @@ -62,7 +83,6 @@ auto operator|(TIterable&& iterable, const Join& joiner) return join(std::forward(iterable), joiner.delimiter); } } - } // namespace mijin #endif // !defined(MIJIN_UTIL_STRING_HPP_INCLUDED)