/* * Copyright (c) 2021, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include namespace JS::Intl { class ListFormat final : public Object { JS_OBJECT(ListFormat, Object); public: enum class Type { Invalid, Conjunction, Disjunction, Unit, }; ListFormat(Object& prototype); virtual ~ListFormat() override = default; String const& locale() const { return m_locale; } void set_locale(String locale) { m_locale = move(locale); } Type type() const { return m_type; } void set_type(StringView type); StringView type_string() const; Unicode::Style style() const { return m_style; } void set_style(StringView style) { m_style = Unicode::style_from_string(style); } StringView style_string() const { return Unicode::style_to_string(m_style); } private: String m_locale; // [[Locale]] Type m_type { Type::Invalid }; // [[Type]] Unicode::Style m_style { Unicode::Style::Long }; // [[Style]] }; using Placeables = HashMap>>; Vector deconstruct_pattern(StringView pattern, Placeables placeables); Vector create_parts_from_list(ListFormat const& list_format, Vector const& list); String format_list(ListFormat const& list_format, Vector const& list); Array* format_list_to_parts(GlobalObject& global_object, ListFormat const& list_format, Vector const& list); ThrowCompletionOr> string_list_from_iterable(GlobalObject& global_object, Value iterable); }