util/StringView: add StartsWithIgnoreCase(), EndsWithIgnoreCase()

This commit is contained in:
Max Kellermann 2019-08-14 11:36:21 +02:00
parent 21b81dfb1d
commit 0f1e13d9ff
1 changed files with 13 additions and 0 deletions

View File

@ -127,6 +127,19 @@ struct BasicStringView : ConstBuffer<T> {
StringIsEqual(data, other.data, this->size);
}
gcc_pure
bool StartsWithIgnoreCase(BasicStringView<T> needle) const noexcept {
return this->size >= needle.size &&
StringIsEqualIgnoreCase(data, needle.data, needle.size);
}
gcc_pure
bool EndsWithIgnoreCase(BasicStringView<T> needle) const noexcept {
return this->size >= needle.size &&
StringIsEqualIgnoreCase(data + this->size - needle.size,
needle.data, needle.size);
}
gcc_pure
bool EqualsIgnoreCase(BasicStringView<T> other) const noexcept {
return this->size == other.size &&