mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Add find_first_split_view() helper for StringView container
Similar to the find_last_split_view() helper, but in this helper we search for the first split view instead of the last one.
This commit is contained in:
parent
123cdfa1f1
commit
13c8695523
Notes:
sideshowbarker
2024-07-17 07:38:26 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/13c8695523 Pull-request: https://github.com/SerenityOS/serenity/pull/14776 Reviewed-by: https://github.com/kleinesfilmroellchen ✅ Reviewed-by: https://github.com/linusg ✅
1 changed files with 8 additions and 0 deletions
|
@ -140,6 +140,14 @@ public:
|
||||||
return substring_view(begin.release_value() + 1);
|
return substring_view(begin.release_value() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] StringView find_first_split_view(char separator) const
|
||||||
|
{
|
||||||
|
auto needle_begin = find(separator);
|
||||||
|
if (!needle_begin.has_value())
|
||||||
|
return *this;
|
||||||
|
return substring_view(0, needle_begin.release_value());
|
||||||
|
}
|
||||||
|
|
||||||
template<VoidFunction<StringView> Callback>
|
template<VoidFunction<StringView> Callback>
|
||||||
void for_each_split_view(char separator, bool keep_empty, Callback callback) const
|
void for_each_split_view(char separator, bool keep_empty, Callback callback) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue