2024-06-08 14:57:25 -04:00
|
|
|
/*
|
2025-07-23 14:42:57 -04:00
|
|
|
* Copyright (c) 2024-2025, Tim Flynn <trflynn89@ladybird.org>
|
2024-06-08 14:57:25 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2025-07-23 14:42:57 -04:00
|
|
|
#include <AK/Utf16String.h>
|
2024-06-08 14:57:25 -04:00
|
|
|
#include <AK/Vector.h>
|
2024-06-23 09:14:27 -04:00
|
|
|
#include <LibUnicode/Locale.h>
|
2024-06-08 14:57:25 -04:00
|
|
|
|
2024-06-23 09:14:27 -04:00
|
|
|
namespace Unicode {
|
2024-06-08 14:57:25 -04:00
|
|
|
|
|
|
|
enum class ListFormatType {
|
|
|
|
Conjunction,
|
|
|
|
Disjunction,
|
|
|
|
Unit,
|
|
|
|
};
|
2024-06-17 16:46:59 -04:00
|
|
|
ListFormatType list_format_type_from_string(StringView);
|
|
|
|
StringView list_format_type_to_string(ListFormatType);
|
2024-06-08 14:57:25 -04:00
|
|
|
|
2024-06-17 16:46:59 -04:00
|
|
|
class ListFormat {
|
|
|
|
public:
|
|
|
|
static NonnullOwnPtr<ListFormat> create(StringView locale, ListFormatType, Style);
|
|
|
|
virtual ~ListFormat() = default;
|
2024-06-08 14:57:25 -04:00
|
|
|
|
2024-06-17 16:46:59 -04:00
|
|
|
struct Partition {
|
|
|
|
StringView type;
|
2025-07-23 14:42:57 -04:00
|
|
|
Utf16String value;
|
2024-06-17 16:46:59 -04:00
|
|
|
};
|
|
|
|
|
2025-07-23 14:42:57 -04:00
|
|
|
virtual Utf16String format(ReadonlySpan<Utf16String> list) const = 0;
|
|
|
|
virtual Vector<Partition> format_to_parts(ReadonlySpan<Utf16String> list) const = 0;
|
2024-06-08 14:57:25 -04:00
|
|
|
|
2024-06-17 16:46:59 -04:00
|
|
|
protected:
|
|
|
|
ListFormat() = default;
|
|
|
|
};
|
2024-06-08 14:57:25 -04:00
|
|
|
|
|
|
|
}
|