mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Add a case insensitive of is_one_of to String[View]
This commit is contained in:
parent
e154c2c2ca
commit
820e03e8d4
Notes:
sideshowbarker
2024-07-17 17:00:50 +09:00
Author: https://github.com/Hendiadyoin1 🔰 Commit: https://github.com/SerenityOS/serenity/commit/820e03e8d4 Pull-request: https://github.com/SerenityOS/serenity/pull/13168
2 changed files with 24 additions and 0 deletions
12
AK/String.h
12
AK/String.h
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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 };
|
||||||
|
|
Loading…
Reference in a new issue