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

@@ -56,6 +56,10 @@ gcc_pure gcc_nonnull_all
bool
StringEndsWith(const char *haystack, const char *needle) noexcept;
gcc_pure gcc_nonnull_all
bool
StringEndsWithIgnoreCase(const char *haystack, const char *needle) noexcept;
/**
* Returns the portion of the string after a prefix. If the string
* does not begin with the specified prefix, this function returns
@@ -70,6 +74,13 @@ StringAfterPrefix(const char *haystack, StringView needle) noexcept
: nullptr;
}
gcc_pure gcc_nonnull_all
static inline bool
StringStartsWithIgnoreCase(const char *haystack, StringView 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.