diff --git a/src/util/StringCompare.hxx b/src/util/StringCompare.hxx index a5d2b2ed1..620f3931f 100644 --- a/src/util/StringCompare.hxx +++ b/src/util/StringCompare.hxx @@ -139,4 +139,26 @@ StringAfterPrefixIgnoreCase(std::string_view haystack, const char * FindStringSuffix(const char *p, const char *suffix) noexcept; +template +bool +SkipPrefix(std::basic_string_view &haystack, + std::basic_string_view needle) noexcept +{ + bool match = haystack.starts_with(needle); + if (match) + haystack.remove_prefix(needle.size()); + return match; +} + +template +bool +RemoveSuffix(std::basic_string_view &haystack, + std::basic_string_view needle) noexcept +{ + bool match = haystack.ends_with(needle); + if (match) + haystack.remove_suffix(needle.size()); + return match; +} + #endif