mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 01:51:03 +09:00
AK: Add StringView::contains(char)
This commit is contained in:
parent
1f6578ee0a
commit
b77ceecb02
Notes:
sideshowbarker
2024-07-19 07:32:10 +09:00
Author: https://github.com/sunverwerth
Commit: b77ceecb02
Pull-request: https://github.com/SerenityOS/serenity/pull/1826
2 changed files with 11 additions and 1 deletions
|
@ -25,10 +25,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/ByteBuffer.h>
|
#include <AK/ByteBuffer.h>
|
||||||
|
#include <AK/FlyString.h>
|
||||||
#include <AK/Memory.h>
|
#include <AK/Memory.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/StringView.h>
|
#include <AK/StringView.h>
|
||||||
#include <AK/FlyString.h>
|
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
@ -157,6 +157,15 @@ bool StringView::matches(const StringView& mask, CaseSensitivity case_sensitivit
|
||||||
return StringUtils::matches(*this, mask, case_sensitivity);
|
return StringUtils::matches(*this, mask, case_sensitivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StringView::contains(char needle) const
|
||||||
|
{
|
||||||
|
for (char current : *this) {
|
||||||
|
if (current == needle)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
StringView StringView::substring_view(size_t start, size_t length) const
|
StringView StringView::substring_view(size_t start, size_t length) const
|
||||||
{
|
{
|
||||||
ASSERT(start + length <= m_length);
|
ASSERT(start + length <= m_length);
|
||||||
|
|
|
@ -73,6 +73,7 @@ public:
|
||||||
bool starts_with(char) const;
|
bool starts_with(char) const;
|
||||||
bool ends_with(char) const;
|
bool ends_with(char) const;
|
||||||
bool matches(const StringView& mask, CaseSensitivity = CaseSensitivity::CaseInsensitive) const;
|
bool matches(const StringView& mask, CaseSensitivity = CaseSensitivity::CaseInsensitive) const;
|
||||||
|
bool contains(char) const;
|
||||||
|
|
||||||
StringView substring_view(size_t start, size_t length) const;
|
StringView substring_view(size_t start, size_t length) const;
|
||||||
Vector<StringView> split_view(char, bool keep_empty = false) const;
|
Vector<StringView> split_view(char, bool keep_empty = false) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue