util/StringCompare: add StringEndsWithIgnoreCase(), StringStartsWithIgnoreCase()

This commit is contained in:
Max Kellermann
2018-09-06 19:29:25 +02:00
parent 2d6f9f9a9c
commit 728e4e9a38
4 changed files with 47 additions and 0 deletions

View File

@@ -54,6 +54,11 @@ gcc_pure gcc_nonnull_all
bool
StringEndsWith(const wchar_t *haystack, const wchar_t *needle) noexcept;
gcc_pure gcc_nonnull_all
bool
StringEndsWithIgnoreCase(const wchar_t *haystack,
const wchar_t *needle) noexcept;
/**
* Returns the portion of the string after a prefix. If the string
* does not begin with the specified prefix, this function returns
@@ -68,6 +73,14 @@ StringAfterPrefix(const wchar_t *haystack, WStringView needle) noexcept
: nullptr;
}
gcc_pure gcc_nonnull_all
static inline bool
StringStartsWithIgnoreCase(const wchar_t *haystack,
WStringView needle) noexcept
{
return StringIsEqualIgnoreCase(haystack, needle.data, needle.size);
}
/**
* Check if the given string ends with the specified suffix. If yes,
* returns the position of the suffix, and nullptr otherwise.