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