1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09:00

AK: Reimplement StringView::find methods in StringUtils

This patch reimplements the StringView::find methods in StringUtils, so
they can also be used by String. The methods now also take an optional
start parameter, which moves their API in line with String's respective
methods.

This also implements a StringView::find_ast(char) method, which is
currently functionally equivalent to find_last_of(char). This is because
find_last_of(char) will be removed in a further commit.
This commit is contained in:
Max Wipfli 2021-07-01 14:58:37 +02:00 committed by Andreas Kling
parent 3ea65200d8
commit 56253bf389
Notes: sideshowbarker 2024-07-18 11:06:21 +09:00
5 changed files with 37 additions and 20 deletions

View file

@ -57,7 +57,12 @@ bool contains(const StringView&, const StringView&, CaseSensitivity);
bool is_whitespace(const StringView&);
StringView trim(const StringView& string, const StringView& characters, TrimMode mode);
StringView trim_whitespace(const StringView& string, TrimMode mode);
Optional<size_t> find(const StringView& haystack, const StringView& needle);
Optional<size_t> find(StringView const& haystack, char needle, size_t start = 0);
Optional<size_t> find(StringView const& haystack, StringView const& needle, size_t start = 0);
Optional<size_t> find_last(StringView const& haystack, char needle);
Vector<size_t> find_all(StringView const& haystack, StringView const& needle);
String to_snakecase(const StringView&);
}