mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Add String::contains
This commit is contained in:
parent
bd9b65e82f
commit
cf0899f440
Notes:
sideshowbarker
2024-07-17 01:41:46 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/cf0899f440 Pull-request: https://github.com/SerenityOS/serenity/pull/17014 Reviewed-by: https://github.com/linusg ✅
2 changed files with 14 additions and 0 deletions
|
@ -339,6 +339,16 @@ ErrorOr<String> String::reverse() const
|
|||
return builder.to_string();
|
||||
}
|
||||
|
||||
bool String::contains(StringView needle, CaseSensitivity case_sensitivity) const
|
||||
{
|
||||
return StringUtils::contains(bytes_as_string_view(), needle, case_sensitivity);
|
||||
}
|
||||
|
||||
bool String::contains(char needle, CaseSensitivity case_sensitivity) const
|
||||
{
|
||||
return contains(StringView { &needle, 1 }, case_sensitivity);
|
||||
}
|
||||
|
||||
bool String::is_short_string() const
|
||||
{
|
||||
return has_short_string_bit(reinterpret_cast<uintptr_t>(m_data));
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <AK/Optional.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Span.h>
|
||||
#include <AK/StringUtils.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Traits.h>
|
||||
#include <AK/Types.h>
|
||||
|
@ -92,6 +93,9 @@ public:
|
|||
return (this->operator==(forward<Ts>(strings)) || ...);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool contains(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
|
||||
[[nodiscard]] bool contains(char, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
|
||||
|
||||
[[nodiscard]] u32 hash() const;
|
||||
|
||||
template<Arithmetic T>
|
||||
|
|
Loading…
Reference in a new issue