util/StringCompare: move code from StringView
This commit is contained in:
parent
5ec13c0b06
commit
c5f037fa64
@ -139,4 +139,26 @@ StringAfterPrefixIgnoreCase(std::string_view haystack,
|
||||
const char *
|
||||
FindStringSuffix(const char *p, const char *suffix) noexcept;
|
||||
|
||||
template<typename T>
|
||||
bool
|
||||
SkipPrefix(std::basic_string_view<T> &haystack,
|
||||
std::basic_string_view<T> needle) noexcept
|
||||
{
|
||||
bool match = haystack.starts_with(needle);
|
||||
if (match)
|
||||
haystack.remove_prefix(needle.size());
|
||||
return match;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool
|
||||
RemoveSuffix(std::basic_string_view<T> &haystack,
|
||||
std::basic_string_view<T> needle) noexcept
|
||||
{
|
||||
bool match = haystack.ends_with(needle);
|
||||
if (match)
|
||||
haystack.remove_suffix(needle.size());
|
||||
return match;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user