mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:27:45 +00:00
AK: Replace the boolean parameter of StringView::lines with a named enum
This commit is contained in:
parent
d9349f1510
commit
07a27b2ec0
4 changed files with 9 additions and 5 deletions
|
@ -68,12 +68,12 @@ Vector<StringView> StringView::split_view(StringView separator, SplitBehavior sp
|
|||
return parts;
|
||||
}
|
||||
|
||||
Vector<StringView> StringView::lines(bool consider_cr) const
|
||||
Vector<StringView> StringView::lines(ConsiderCarriageReturn consider_carriage_return) const
|
||||
{
|
||||
if (is_empty())
|
||||
return {};
|
||||
|
||||
if (!consider_cr)
|
||||
if (consider_carriage_return == ConsiderCarriageReturn::No)
|
||||
return split_view('\n', SplitBehavior::KeepEmpty);
|
||||
|
||||
Vector<StringView> v;
|
||||
|
|
|
@ -235,7 +235,11 @@ public:
|
|||
// 0.29, the spec defines a line ending as "a newline (U+000A), a carriage
|
||||
// return (U+000D) not followed by a newline, or a carriage return and a
|
||||
// following newline.".
|
||||
[[nodiscard]] Vector<StringView> lines(bool consider_cr = true) const;
|
||||
enum class ConsiderCarriageReturn {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
[[nodiscard]] Vector<StringView> lines(ConsiderCarriageReturn = ConsiderCarriageReturn::Yes) const;
|
||||
|
||||
// Create a new substring view of this string view, starting either at the beginning of
|
||||
// the given substring view, or after its end, and continuing until the end of this string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue