2024-06-08 15:57:25 -03:00
|
|
|
/*
|
2025-07-23 15:42:57 -03:00
|
|
|
* Copyright (c) 2024-2025, Tim Flynn <trflynn89@ladybird.org>
|
2024-06-08 15:57:25 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-07-23 15:42:57 -03:00
|
|
|
#include <AK/Utf16String.h>
|
2026-06-21 14:03:06 -03:00
|
|
|
#include <AK/Utf16View.h>
|
2024-06-08 15:57:25 -03:00
|
|
|
#include <AK/Vector.h>
|
2024-06-23 10:14:27 -03:00
|
|
|
#include <LibUnicode/Locale.h>
|
2024-06-08 15:57:25 -03:00
|
|
|
|
2024-06-23 10:14:27 -03:00
|
|
|
namespace Unicode {
|
2024-06-08 15:57:25 -03:00
|
|
|
|
|
|
|
|
enum class ListFormatType {
|
|
|
|
|
Conjunction,
|
|
|
|
|
Disjunction,
|
|
|
|
|
Unit,
|
|
|
|
|
};
|
2024-06-17 17:46:59 -03:00
|
|
|
ListFormatType list_format_type_from_string(StringView);
|
2026-06-21 14:03:06 -03:00
|
|
|
ListFormatType list_format_type_from_string(Utf16View);
|
2026-06-21 14:03:10 -03:00
|
|
|
Utf16String list_format_type_to_string(ListFormatType);
|
2024-06-08 15:57:25 -03:00
|
|
|
|
2024-06-17 17:46:59 -03:00
|
|
|
class ListFormat {
|
|
|
|
|
public:
|
Libraries: Clean up UTF-16 source text paths
Store parser errors, source range filenames, source code filenames,
module source, and Rust parser errors as UTF-16 where they flow back
into JavaScript-visible strings. Keep byte-oriented source buffers
byte-backed.
Remove temporary PrimitiveString, ByteString, and UTF-8 detours from
JSON, RegExp, module debug logging, print formatting, and tests.
2026-06-21 14:03:19 -03:00
|
|
|
static NonnullOwnPtr<ListFormat> create(Utf16View locale, ListFormatType, Style);
|
2024-06-17 17:46:59 -03:00
|
|
|
virtual ~ListFormat() = default;
|
2024-06-08 15:57:25 -03:00
|
|
|
|
2024-06-17 17:46:59 -03:00
|
|
|
struct Partition {
|
2026-06-21 14:03:10 -03:00
|
|
|
Utf16String type;
|
2025-07-23 15:42:57 -03:00
|
|
|
Utf16String value;
|
2024-06-17 17:46:59 -03:00
|
|
|
};
|
|
|
|
|
|
2025-07-23 15:42:57 -03:00
|
|
|
virtual Utf16String format(ReadonlySpan<Utf16String> list) const = 0;
|
|
|
|
|
virtual Vector<Partition> format_to_parts(ReadonlySpan<Utf16String> list) const = 0;
|
2024-06-08 15:57:25 -03:00
|
|
|
|
2024-06-17 17:46:59 -03:00
|
|
|
protected:
|
|
|
|
|
ListFormat() = default;
|
|
|
|
|
};
|
2024-06-08 15:57:25 -03:00
|
|
|
|
|
|
|
|
}
|