AK: Add a case insensitive of is_one_of to String[View]

This commit is contained in:
Hendiadyoin1 2022-03-20 23:52:36 +01:00 committed by Andreas Kling
parent e154c2c2ca
commit 820e03e8d4
Notes: sideshowbarker 2024-07-17 17:00:50 +09:00
2 changed files with 24 additions and 0 deletions

View file

@ -302,6 +302,18 @@ public:
return (... || this->operator==(forward<Ts>(strings))); return (... || this->operator==(forward<Ts>(strings)));
} }
template<typename... Ts>
[[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of_ignoring_case(Ts&&... strings) const
{
return (... ||
[this, &strings]() -> bool {
if constexpr (requires(Ts a) { a.view()->StringView; })
return this->equals_ignoring_case(forward<Ts>(strings.view()));
else
return this->equals_ignoring_case(forward<Ts>(strings));
}());
}
private: private:
RefPtr<StringImpl> m_impl; RefPtr<StringImpl> m_impl;
}; };

View file

@ -279,6 +279,18 @@ public:
return (... || this->operator==(forward<Ts>(strings))); return (... || this->operator==(forward<Ts>(strings)));
} }
template<typename... Ts>
[[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of_ignoring_case(Ts&&... strings) const
{
return (... ||
[this, &strings]() -> bool {
if constexpr (requires(Ts a) { a.view()->StringView; })
return this->equals_ignoring_case(forward<Ts>(strings.view()));
else
return this->equals_ignoring_case(forward<Ts>(strings));
}());
}
private: private:
friend class String; friend class String;
const char* m_characters { nullptr }; const char* m_characters { nullptr };