mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 02:13:56 +09:00

ListFormat was the first formatter I ported to ICU. This patch makes it match the style of subsequently ported formatters, where we create the formatter once per Intl object, rather than once per prototype invocation.
40 lines
835 B
C++
40 lines
835 B
C++
/*
|
|
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/String.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibLocale/Locale.h>
|
|
|
|
namespace Locale {
|
|
|
|
enum class ListFormatType {
|
|
Conjunction,
|
|
Disjunction,
|
|
Unit,
|
|
};
|
|
ListFormatType list_format_type_from_string(StringView);
|
|
StringView list_format_type_to_string(ListFormatType);
|
|
|
|
class ListFormat {
|
|
public:
|
|
static NonnullOwnPtr<ListFormat> create(StringView locale, ListFormatType, Style);
|
|
virtual ~ListFormat() = default;
|
|
|
|
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;
|
|
|
|
protected:
|
|
ListFormat() = default;
|
|
};
|
|
|
|
}
|