17 if (
lhs.size() !=
rhs.size()) {
20 for (std::size_t i = 0; i <
lhs.size(); ++i) {
42 return std::string_view::npos;
44 for (std::size_t i =
from; i <=
str.size() -
needle.size(); ++i) {
49 return std::string_view::npos;
61 for (std::size_t i = 0; i <
common; ++i) {
62 const auto a =
static_cast<unsigned char>(
toLower(
lhs[i]));
63 const auto b =
static_cast<unsigned char>(
toLower(
rhs[i]));
65 return a < b ? -1 : 1;
68 return lhs.size() ==
rhs.size() ? 0 : (
lhs.size() <
rhs.size() ? -1 : 1);
String helpers: case, trimming, splitting, joining, replacing, parsing and hashing.
Definition Char.hpp:3
constexpr char toLower(char c) noexcept
Definition Char.hpp:16
constexpr bool endsWithIgnoreCase(std::string_view str, std::string_view suffix) noexcept
Definition Compare.hpp:33
constexpr std::size_t findIgnoreCase(std::string_view str, std::string_view needle, std::size_t from=0) noexcept
Position of the first needle at or after from, or std::string_view::npos.
Definition Compare.hpp:39
constexpr bool startsWithIgnoreCase(std::string_view str, std::string_view prefix) noexcept
Definition Compare.hpp:28
constexpr bool contains(std::string_view str, std::string_view needle) noexcept
Definition Compare.hpp:12
constexpr bool equalsIgnoreCase(std::string_view lhs, std::string_view rhs) noexcept
Definition Compare.hpp:15
constexpr int compareIgnoreCase(std::string_view lhs, std::string_view rhs) noexcept
Three-way comparison like strcmp: negative, zero or positive.
Definition Compare.hpp:58
constexpr bool containsIgnoreCase(std::string_view str, std::string_view needle) noexcept
Definition Compare.hpp:52
std::optional< T > parseNumber(std::string_view text, int base=10) noexcept
Parses text as a number, or returns std::nullopt if it is not entirely one.
Definition Convert.hpp:23