summaryrefslogtreecommitdiff
path: root/AK/StringUtils.h
diff options
context:
space:
mode:
authorMax Wipfli <mail@maxwipfli.ch>2021-07-01 14:58:37 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-02 21:54:21 +0200
commit56253bf3895e258729130a7ec22acff74e5b4212 (patch)
treedcc590c88205f8872c610f0d455002bee379176e /AK/StringUtils.h
parent3ea65200d82a59530ed94136c8fb8baa9461d69c (diff)
downloadserenity-56253bf3895e258729130a7ec22acff74e5b4212.zip
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.
Diffstat (limited to 'AK/StringUtils.h')
-rw-r--r--AK/StringUtils.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/AK/StringUtils.h b/AK/StringUtils.h
index fa7ae1902d..f7211b0561 100644
--- a/AK/StringUtils.h
+++ b/AK/StringUtils.h
@@ -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&);
}