util/StringCompare: add more StringView overloads
This commit is contained in:
parent
a63d0ee8fc
commit
6876d160cf
@ -81,6 +81,14 @@ StringStartsWithIgnoreCase(const char *haystack, StringView needle) noexcept
|
||||
return StringIsEqualIgnoreCase(haystack, needle.data, needle.size);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
static inline bool
|
||||
StringStartsWithIgnoreCase(StringView haystack, StringView needle) noexcept
|
||||
{
|
||||
return haystack.size >= needle.size &&
|
||||
StringIsEqualIgnoreCase(haystack.data, needle.data, needle.size);
|
||||
}
|
||||
|
||||
gcc_pure gcc_nonnull_all
|
||||
static inline const char *
|
||||
StringAfterPrefixIgnoreCase(const char *haystack, StringView needle) noexcept
|
||||
@ -90,6 +98,16 @@ StringAfterPrefixIgnoreCase(const char *haystack, StringView needle) noexcept
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
static inline StringView
|
||||
StringAfterPrefixIgnoreCase(StringView haystack,
|
||||
StringView needle) noexcept
|
||||
{
|
||||
return StringStartsWithIgnoreCase(haystack, needle)
|
||||
? haystack.substr(needle.size)
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given string ends with the specified suffix. If yes,
|
||||
* returns the position of the suffix, and nullptr otherwise.
|
||||
|
Loading…
Reference in New Issue
Block a user