From 0f1e13d9ff26585c6cfe68618f168577c936964d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 14 Aug 2019 11:36:21 +0200 Subject: [PATCH] util/StringView: add StartsWithIgnoreCase(), EndsWithIgnoreCase() --- src/util/StringView.hxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/util/StringView.hxx b/src/util/StringView.hxx index d89fbd32d..9848619d8 100644 --- a/src/util/StringView.hxx +++ b/src/util/StringView.hxx @@ -127,6 +127,19 @@ struct BasicStringView : ConstBuffer { StringIsEqual(data, other.data, this->size); } + gcc_pure + bool StartsWithIgnoreCase(BasicStringView needle) const noexcept { + return this->size >= needle.size && + StringIsEqualIgnoreCase(data, needle.data, needle.size); + } + + gcc_pure + bool EndsWithIgnoreCase(BasicStringView needle) const noexcept { + return this->size >= needle.size && + StringIsEqualIgnoreCase(data + this->size - needle.size, + needle.data, needle.size); + } + gcc_pure bool EqualsIgnoreCase(BasicStringView other) const noexcept { return this->size == other.size &&