messageformat2_data_model.h
// © 2024 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
#include "unicode/utypes.h"
#ifndef MESSAGEFORMAT_DATA_MODEL_H
#define MESSAGEFORMAT_DATA_MODEL_H
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_NORMALIZATION
#if !UCONFIG_NO_FORMATTING
#if !UCONFIG_NO_MF2
#include "unicode/localpointer.h"
#include "unicode/messageformat2_data_model_names.h"
#ifndef U_HIDE_DEPRECATED_API
#include <algorithm>
#include <cstddef>
#include <iterator>
#include <optional>
#include <variant>
#include <vector>
U_NAMESPACE_BEGIN
class UVector;
// Helpers
// Note: this _must_ be declared `inline` or else gcc will generate code
// for its instantiations, which needs to be avoided because it returns
// a std::vector
template<typename T>
static inline std::vector<T> toStdVector(const T* arr, int32_t len) {
std::vector<T> result;
for (int32_t i = 0; i < len; i++) {
result.push_back(arr[i]);
}
return result;
}
#if defined(U_REAL_MSVC)
#pragma warning(push)
// Ignore warning 4251 as these templates are instantiated later in this file,
// after the classes used to instantiate them have been defined.
#pragma warning(disable: 4251)
#endif
namespace message2 {
class Checker;
class MessageFormatter;
class Parser;
class Serializer;
namespace data_model {
class Binding;
class Literal;
class Operator;
class MFDataModel;
class U_I18N_API Literal : public UObject {
public:
UnicodeString quoted() const;
const UnicodeString& unquoted() const;
UBool isQuoted() const { return thisIsQuoted; }
Literal(UBool q, const UnicodeString& s) : thisIsQuoted(q), contents(s) {}
Literal(const Literal& other) : thisIsQuoted(other.thisIsQuoted), contents(other.contents) {}
friend inline void swap(Literal& l1, Literal& l2) noexcept {
using std::swap;
swap(l1.thisIsQuoted, l2.thisIsQuoted);
swap(l1.contents, l2.contents);
}
Literal& operator=(Literal) noexcept;
Literal() = default;
bool operator<(const Literal& other) const;
bool operator==(const Literal& other) const;
virtual ~Literal();
private:
/* const */ bool thisIsQuoted = false;
/* const */ UnicodeString contents;
};
class U_I18N_API_CLASS Operand : public UObject {
public:
U_I18N_API UBool isVariable() const;
U_I18N_API UBool isLiteral() const;
U_I18N_API virtual UBool isNull() const;
U_I18N_API const UnicodeString& asVariable() const;
U_I18N_API const Literal& asLiteral() const;
U_I18N_API Operand() : contents(std::nullopt) {}
U_I18N_API explicit Operand(const UnicodeString& v) : contents(VariableName(v)) {}
U_I18N_API explicit Operand(const Literal& l) : contents(l) {}
U_I18N_API friend inline void swap(Operand& o1, Operand& o2) noexcept {
using std::swap;
(void) o1;
(void) o2;
swap(o1.contents, o2.contents);
}
U_I18N_API virtual Operand& operator=(Operand) noexcept;
U_I18N_API Operand(const Operand&);
U_I18N_API virtual ~Operand();
private:
std::optional<std::variant<VariableName, Literal>> contents;
}; // class Operand
class U_I18N_API_CLASS Key : public UObject {
public:
U_I18N_API UBool isWildcard() const { return !contents.has_value(); }
U_I18N_API const Literal& asLiteral() const;
U_I18N_API Key(const Key& other) : contents(other.contents) {}
U_I18N_API Key() : contents(std::nullopt) {}
U_I18N_API explicit Key(const Literal& lit) : contents(lit) {}
U_I18N_API friend inline void swap(Key& k1, Key& k2) noexcept {
using std::swap;
swap(k1.contents, k2.contents);
}
U_I18N_API Key& operator=(Key) noexcept;
U_I18N_API bool operator<(const Key& other) const;
U_I18N_API bool operator==(const Key& other) const;
U_I18N_API virtual ~Key();
private:
/* const */ std::optional<Literal> contents;
}; // class Key
class U_I18N_API_CLASS SelectorKeys : public UObject {
public:
U_I18N_API std::vector<Key> getKeys() const {
return toStdVector<Key>(keys.getAlias(), len);
}
class U_I18N_API Builder : public UMemory {
private:
friend class SelectorKeys;
UVector* keys; // This is a raw pointer and not a LocalPointer<UVector> to avoid undefined behavior warnings,
// since UVector is forward-declared
// The vector owns its elements
public:
Builder& add(Key&& key, UErrorCode& status) noexcept;
SelectorKeys build(UErrorCode& status) const;
Builder(UErrorCode& status);
virtual ~Builder();
Builder(const Builder&) = delete;
Builder& operator=(const Builder&) = delete;
Builder(Builder&&) = delete;
Builder& operator=(Builder&&) = delete;
}; // class SelectorKeys::Builder
U_I18N_API bool operator<(const SelectorKeys& other) const;
U_I18N_API SelectorKeys() : len(0) {}
U_I18N_API friend inline void swap(SelectorKeys& s1, SelectorKeys& s2) noexcept {
using std::swap;
swap(s1.len, s2.len);
swap(s1.keys, s2.keys);
}
U_I18N_API SelectorKeys(const SelectorKeys& other);
U_I18N_API SelectorKeys& operator=(SelectorKeys other) noexcept;
U_I18N_API virtual ~SelectorKeys();
private:
friend class Builder;
friend class message2::Checker;
friend class message2::MessageFormatter;
friend class message2::Serializer;
/* const */ LocalArray<Key> keys;
/* const */ int32_t len;
const Key* getKeysInternal() const;
SelectorKeys(const UVector& ks, UErrorCode& status);
}; // class SelectorKeys
class Operator;
class U_I18N_API Option : public UObject {
public:
const Operand& getValue() const { return rand; }
const UnicodeString& getName() const { return name; }
Option(const UnicodeString& n, Operand&& r) : name(n), rand(std::move(r)) {}
Option() {}
friend inline void swap(Option& o1, Option& o2) noexcept {
using std::swap;
swap(o1.name, o2.name);
swap(o1.rand, o2.rand);
}
Option(const Option& other);
Option& operator=(Option other) noexcept;
virtual ~Option();
private:
/* const */ UnicodeString name;
/* const */ Operand rand;
}; // class Option
// Internal only
#ifndef U_IN_DOXYGEN
// Options
// This is a wrapper class around a vector of options that provides lookup operations
class U_I18N_API_CLASS OptionMap : public UObject {
public:
U_I18N_API int32_t size() const;
// Needs to take an error code b/c an earlier copy might have failed
U_I18N_API const Option& getOption(int32_t, UErrorCode&) const;
U_I18N_API friend inline void swap(OptionMap& m1, OptionMap& m2) noexcept {
using std::swap;
swap(m1.bogus, m2.bogus);
swap(m1.options, m2.options);
swap(m1.len, m2.len);
}
U_I18N_API OptionMap() : len(0) {}
U_I18N_API OptionMap(const OptionMap&);
U_I18N_API OptionMap& operator=(OptionMap);
U_I18N_API std::vector<Option> getOptions() const {
return toStdVector<Option>(options.getAlias(), len);
}
U_I18N_API OptionMap(const UVector&, UErrorCode&);
U_I18N_API OptionMap(Option*, int32_t);
U_I18N_API virtual ~OptionMap();
class U_I18N_API Builder : public UObject {
private:
UVector* options;
bool checkDuplicates = true;
public:
Builder& add(Option&& opt, UErrorCode&);
Builder(UErrorCode&);
static Builder attributes(UErrorCode&);
// As this class is private, build() is destructive
OptionMap build(UErrorCode&);
friend inline void swap(Builder& m1, Builder& m2) noexcept {
using std::swap;
swap(m1.options, m2.options);
swap(m1.checkDuplicates, m2.checkDuplicates);
}
Builder(Builder&&);
Builder(const Builder&) = delete;
Builder& operator=(Builder) noexcept;
virtual ~Builder();
}; // class OptionMap::Builder
private:
friend class message2::Serializer;
bool bogus = false;
LocalArray<Option> options;
int32_t len;
}; // class OptionMap
#endif
class U_I18N_API Operator : public UObject {
public:
const FunctionName& getFunctionName() const;
std::vector<Option> getOptions() const {
return options.getOptions();
}
class U_I18N_API Builder : public UMemory {
private:
friend class Operator;
FunctionName functionName;
OptionMap::Builder options;
public:
Builder& setFunctionName(FunctionName&& func);
Builder& addOption(const UnicodeString &key, Operand&& value, UErrorCode& status) noexcept;
Operator build(UErrorCode& status);
Builder(UErrorCode& status);
virtual ~Builder();
Builder(const Builder&) = delete;
Builder& operator=(const Builder&) = delete;
Builder(Builder&&) = delete;
Builder& operator=(Builder&&) = delete;
}; // class Operator::Builder
Operator(const Operator& other) noexcept;
friend inline void swap(Operator& o1, Operator& o2) noexcept {
using std::swap;
swap(o1.name, o2.name);
swap(o1.options, o2.options);
}
Operator& operator=(Operator) noexcept;
Operator() {}
virtual ~Operator();
private:
friend class Binding;
friend class Builder;
friend class message2::Checker;
friend class message2::MessageFormatter;
friend class message2::Serializer;
// Function call constructor
Operator(const FunctionName& f, const UVector& options, UErrorCode&);
const OptionMap& getOptionsInternal() const;
Operator(const FunctionName&, const OptionMap&);
/* const */ FunctionName name;
/* const */ OptionMap options;
}; // class Operator
// Internal only
typedef enum UMarkupType {
UMARKUP_OPEN = 0,
UMARKUP_CLOSE,
UMARKUP_STANDALONE,
UMARKUP_COUNT
} UMarkupType;
class U_I18N_API Markup : public UObject {
public:
UBool isOpen() const { return (type == UMARKUP_OPEN); }
UBool isClose() const { return (type == UMARKUP_CLOSE); }
UBool isStandalone() const { return (type == UMARKUP_STANDALONE); }
const UnicodeString& getName() const { return name; }
std::vector<Option> getOptions() const { return options.getOptions(); }
std::vector<Option> getAttributes() const { return attributes.getOptions(); }
Markup() {}
virtual ~Markup();
class U_I18N_API Builder : public UMemory {
private:
friend class Markup;
UnicodeString name;
OptionMap::Builder options;
OptionMap::Builder attributes;
UMarkupType type = UMARKUP_COUNT;
public:
Builder& setName(const UnicodeString& n) { name = n; return *this; }
Builder& setOpen() { type = UMARKUP_OPEN; return *this; }
Builder& setClose() { type = UMARKUP_CLOSE; return *this; }
Builder& setStandalone() { type = UMARKUP_STANDALONE; return *this; }
Builder& addOption(const UnicodeString &key, Operand&& value, UErrorCode& status);
Builder& addAttribute(const UnicodeString &key, Operand&& value, UErrorCode& status);
Markup build(UErrorCode& status);
Builder(UErrorCode& status);
virtual ~Builder();
Builder(const Builder&) = delete;
Builder& operator=(const Builder&) = delete;
Builder(Builder&&) = delete;
Builder& operator=(Builder&&) = delete;
}; // class Markup::Builder
private:
friend class Builder;
friend class message2::Serializer;
UMarkupType type;
UnicodeString name;
OptionMap options;
OptionMap attributes;
const OptionMap& getOptionsInternal() const { return options; }
const OptionMap& getAttributesInternal() const { return attributes; }
Markup(UMarkupType, UnicodeString, OptionMap&&, OptionMap&&);
}; // class Markup
class U_I18N_API_CLASS Expression : public UObject {
public:
U_I18N_API UBool isStandaloneAnnotation() const;
U_I18N_API UBool isFunctionCall() const;
U_I18N_API const Operator* getOperator(UErrorCode& status) const;
U_I18N_API const Operand& getOperand() const;
U_I18N_API std::vector<Option> getAttributes() const { return attributes.getOptions(); }
class U_I18N_API Builder : public UMemory {
private:
friend class Expression;
bool hasOperand = false;
bool hasOperator = false;
Operand rand;
Operator rator;
OptionMap::Builder attributes;
public:
Builder& setOperand(Operand&& rAnd);
Builder& setOperator(Operator&& rAtor);
Builder& addAttribute(const UnicodeString &key, Operand&& value, UErrorCode& status);
Expression build(UErrorCode& status);
Builder(UErrorCode& status);
virtual ~Builder();
Builder(const Builder&) = delete;
Builder& operator=(const Builder&) = delete;
Builder(Builder&&) = delete;
Builder& operator=(Builder&&) = delete;
}; // class Expression::Builder
U_I18N_API friend inline void swap(Expression& e1, Expression& e2) noexcept {
using std::swap;
swap(e1.rator, e2.rator);
swap(e1.rand, e2.rand);
swap(e1.attributes, e2.attributes);
}
U_I18N_API Expression(const Expression& other);
U_I18N_API Expression& operator=(Expression) noexcept;
U_I18N_API Expression();
U_I18N_API virtual ~Expression();
private:
friend class message2::Serializer;
/*
Internally, an expression is represented as the application of an optional operator to an operand.
The operand is always present; for function calls with no operand, it's represented
as an operand for which `isNull()` is true.
Operator | Operand
--------------------------------
{ |42| :fun opt=value } => (FunctionName=fun, | Literal(quoted=true, contents="42")
options={opt: value})
{ abcd } => null | Literal(quoted=false, contents="abcd")
{ : fun opt=value } => (FunctionName=fun,
options={opt: value}) | NullOperand()
*/
Expression(const Operator &rAtor, const Operand &rAnd, const OptionMap& attrs) : rator(rAtor), rand(rAnd), attributes(attrs) {}
Expression(const Operand &rAnd, const OptionMap& attrs) : rator(std::nullopt), rand(Operand(rAnd)), attributes(attrs) {}
Expression(const Operator &rAtor, const OptionMap& attrs) : rator(rAtor), rand(), attributes(attrs) {}
/* const */ std::optional<Operator> rator;
/* const */ Operand rand;
/* const */ OptionMap attributes;
const OptionMap& getAttributesInternal() const { return attributes; }
}; // class Expression
class Pattern;
// Despite the comments, `PatternPart` is internal-only
class U_I18N_API_CLASS PatternPart : public UObject {
public:
U_I18N_API UBool isText() const { return std::holds_alternative<UnicodeString>(piece); }
U_I18N_API UBool isMarkup() const { return std::holds_alternative<Markup>(piece); }
U_I18N_API UBool isExpression() const { return std::holds_alternative<Expression>(piece); }
U_I18N_API const Expression& contents() const;
U_I18N_API const Markup& asMarkup() const;
U_I18N_API const UnicodeString& asText() const;
U_I18N_API friend inline void swap(PatternPart& p1, PatternPart& p2) noexcept {
using std::swap;
swap(p1.piece, p2.piece);
}
U_I18N_API PatternPart(const PatternPart& other);
U_I18N_API PatternPart& operator=(PatternPart) noexcept;
U_I18N_API virtual ~PatternPart();
U_I18N_API explicit PatternPart(const UnicodeString& t) : piece(t) {}
U_I18N_API explicit PatternPart(Expression&& e) : piece(e) {}
U_I18N_API explicit PatternPart(Markup&& m) : piece(m) {}
U_I18N_API PatternPart() = default;
private:
friend class Pattern;
std::variant<UnicodeString, Expression, Markup> piece;
}; // class PatternPart
class U_I18N_API_CLASS Pattern : public UObject {
private:
friend class PatternPart;
public:
#ifndef U_IN_DOXYGEN
struct U_I18N_API Iterator;
#endif
U_I18N_API Iterator begin() const {
return Iterator(this, 0);
}
U_I18N_API Iterator end() const {
return Iterator(this, len);
}
class U_I18N_API Builder : public UMemory {
private:
friend class Pattern;
UVector* parts; // Not a LocalPointer for the same reason as in `SelectorKeys::Builder`
public:
Builder& add(Expression&& part, UErrorCode& status) noexcept;
Builder& add(Markup&& part, UErrorCode& status) noexcept;
Builder& add(UnicodeString&& part, UErrorCode& status) noexcept;
Pattern build(UErrorCode& status) const noexcept;
Builder(UErrorCode& status);
virtual ~Builder();
Builder(const Builder&) = delete;
Builder& operator=(const Builder&) = delete;
Builder(Builder&&) = delete;
Builder& operator=(Builder&&) = delete;
}; // class Pattern::Builder
U_I18N_API Pattern() : parts(LocalArray<PatternPart>()) {}
U_I18N_API friend inline void swap(Pattern& p1, Pattern& p2) noexcept {
using std::swap;
swap(p1.bogus, p2.bogus);
swap(p1.len, p2.len);
swap(p1.parts, p2.parts);
}
U_I18N_API Pattern(const Pattern& other);
U_I18N_API Pattern& operator=(Pattern) noexcept;
U_I18N_API virtual ~Pattern();
struct U_I18N_API Iterator {
private:
using iterator_category = std::forward_iterator_tag;
using difference_type = std::ptrdiff_t;
using value_type = std::variant<UnicodeString, Expression, Markup>;
using pointer = value_type*;
using reference = const value_type&;
friend class Pattern;
Iterator(const Pattern* p, int32_t i) : pos(i), pat(p) {}
friend bool operator== (const Iterator& a, const Iterator& b) { return (a.pat == b.pat && a.pos == b.pos); }
int32_t pos;
const Pattern* pat;
public:
reference operator*() const {
const PatternPart& part = pat->parts[pos];
return patternContents(part);
}
Iterator operator++() { pos++; return *this; }
friend bool operator!= (const Iterator& a, const Iterator& b) { return !(a == b); }
}; // struct Iterator
private:
friend class Builder;
friend class message2::MessageFormatter;
friend class message2::Serializer;
// Set to true if a copy constructor fails;
// needed in order to distinguish an uninitialized
// Pattern from a 0-length pattern
bool bogus = false;
// Possibly-empty array of parts
int32_t len = 0;
LocalArray<PatternPart> parts;
Pattern(const UVector& parts, UErrorCode& status);
// Helper
static void initParts(Pattern&, const Pattern&);
int32_t numParts() const;
const PatternPart& getPart(int32_t i) const;
// Gets around not being able to declare Pattern::Iterator as a friend
// in PatternPart
static const std::variant<UnicodeString, Expression, Markup>&
patternContents(const PatternPart& p) { return p.piece; }
}; // class Pattern
class U_I18N_API Variant : public UObject {
public:
const Pattern& getPattern() const { return p; }
const SelectorKeys& getKeys() const { return k; }
Variant(const SelectorKeys& keys, Pattern&& pattern) : k(keys), p(std::move(pattern)) {}
friend inline void swap(Variant& v1, Variant& v2) noexcept {
using std::swap;
swap(v1.k, v2.k);
swap(v1.p, v2.p);
}
Variant& operator=(Variant other) noexcept;
Variant() = default;
Variant(const Variant&);
virtual ~Variant();
private:
/* const */ SelectorKeys k;
/* const */ Pattern p;
}; // class Variant
class U_I18N_API Binding : public UObject {
public:
const Expression& getValue() const;
const VariableName& getVariable() const { return var; }
static Binding input(UnicodeString&& variableName, Expression&& rhs, UErrorCode& errorCode);
UBool isLocal() const { return local; }
Binding(const VariableName& v, Expression&& e) : var(v), expr(std::move(e)), local(true), annotation(nullptr) {}
friend inline void swap(Binding& b1, Binding& b2) noexcept {
using std::swap;
swap(b1.var, b2.var);
swap(b1.expr, b2.expr);
swap(b1.local, b2.local);
b1.updateAnnotation();
b2.updateAnnotation();
}
Binding(const Binding& other);
Binding& operator=(Binding) noexcept;
Binding() : local(true) {}
virtual ~Binding();
private:
friend class message2::Checker;
friend class message2::MessageFormatter;
friend class message2::Parser;
friend class message2::Serializer;
/* const */ VariableName var;
/* const */ Expression expr;
/* const */ bool local;
// The following field is always nullptr for a local
// declaration, and possibly nullptr for an .input declaration
// If non-null, the referent is a member of `expr` so
// its lifetime is the same as the lifetime of the enclosing Binding
// (as long as there's no mutation)
const Operator* annotation = nullptr;
const OptionMap& getOptionsInternal() const;
bool hasAnnotation() const { return !local && (annotation != nullptr); }
void updateAnnotation();
}; // class Binding
// Internal only
#ifndef U_IN_DOXYGEN
class U_I18N_API_CLASS Matcher : public UObject {
public:
U_I18N_API Matcher& operator=(Matcher);
U_I18N_API Matcher(const Matcher&);
U_I18N_API friend inline void swap(Matcher& m1, Matcher& m2) noexcept {
using std::swap;
if (m1.bogus) {
m2.bogus = true;
return;
}
if (m2.bogus) {
m1.bogus = true;
return;
}
swap(m1.selectors, m2.selectors);
swap(m1.numSelectors, m2.numSelectors);
swap(m1.variants, m2.variants);
swap(m1.numVariants, m2.numVariants);
}
U_I18N_API virtual ~Matcher();
private:
friend class MFDataModel;
Matcher(VariableName* ss, int32_t ns, Variant* vs, int32_t nv);
Matcher() {}
// A Matcher may have numSelectors=0 and numVariants=0
// (this is a data model error, but it's representable).
// So we have to keep a separate flag to track failed copies.
bool bogus = false;
// The variables that are being matched on.
LocalArray<VariableName> selectors;
// The number of selectors
int32_t numSelectors = 0;
// The list of `when` clauses (case arms).
LocalArray<Variant> variants;
// The number of variants
int32_t numVariants = 0;
}; // class Matcher
#endif
// -----------------------------------------------------------------------
// Public MFDataModel class
class U_I18N_API_CLASS MFDataModel : public UMemory {
/*
Classes that represent nodes in the data model are nested inside the
`MFDataModel` class.
Classes such as `Expression`, `Pattern` and `VariantMap` are immutable and
are constructed using the builder pattern.
Most classes representing nodes have copy constructors. This is because builders
contain immutable data that must be copied when calling `build()`, since the builder
could go out of scope before the immutable result of the builder does. Copying is
also necessary to prevent unexpected mutation if intermediate builders are saved
and mutated again after calling `build()`.
The copy constructors perform a deep copy, for example by copying the entire
list of options for an `Operator` (and copying the entire underlying vector.)
Some internal fields should be `const`, but are declared as non-`const` to make
the copy constructor simpler to implement. (These are noted throughout.) In
other words, those fields are `const` except during the execution of a copy
constructor.
On the other hand, intermediate `Builder` methods that return a `Builder&`
mutate the state of the builder, so in code like:
Expression::Builder& exprBuilder = Expression::builder()-> setOperand(foo);
Expression::Builder& exprBuilder2 = exprBuilder.setOperator(bar);
the call to `setOperator()` would mutate `exprBuilder`, since `exprBuilder`
and `exprBuilder2` are references to the same object.
An alternate choice would be to make `build()` destructive, so that copying would
be unnecessary. Or, both copying and moving variants of `build()` could be
provided. Copying variants of the intermediate `Builder` methods could be
provided as well, if this proved useful.
*/
public:
U_I18N_API std::vector<Binding> getLocalVariables() const {
std::vector<Binding> result;
if (!bogus) {
return toStdVector<Binding>(bindings.getAlias(), bindingsLen);
}
return {};
}
U_I18N_API std::vector<VariableName> getSelectors() const {
if (std::holds_alternative<Pattern>(body)) {
return {};
}
const Matcher* match = std::get_if<Matcher>(&body);
// match must be non-null, given the previous check
return toStdVector<VariableName>(match->selectors.getAlias(), match->numSelectors);
}
U_I18N_API std::vector<Variant> getVariants() const {
// Return empty vector if no variants
if (std::holds_alternative<Pattern>(body)) {
return {};
}
const Matcher* match = std::get_if<Matcher>(&body);
// match must be non-null, given the previous check
return toStdVector<Variant>(match->variants.getAlias(), match->numVariants);
return {};
}
U_I18N_API const Pattern& getPattern() const;
class U_I18N_API Builder;
U_I18N_API MFDataModel();
U_I18N_API friend inline void swap(MFDataModel& m1, MFDataModel& m2) noexcept {
using std::swap;
if (m1.bogus) {
m2.bogus = true;
return;
}
if (m2.bogus) {
m1.bogus = true;
return;
}
swap(m1.body, m2.body);
swap(m1.bindings, m2.bindings);
swap(m1.bindingsLen, m2.bindingsLen);
}
U_I18N_API MFDataModel& operator=(MFDataModel) noexcept;
U_I18N_API MFDataModel(const MFDataModel& other);
U_I18N_API virtual ~MFDataModel();
class U_I18N_API Builder : public UMemory {
private:
friend class MFDataModel;
void checkDuplicate(const VariableName&, UErrorCode&) const;
void buildSelectorsMessage(UErrorCode&);
bool hasPattern = true;
bool hasSelectors = false;
Pattern pattern;
// The following members are not LocalPointers for the same reason as in SelectorKeys::Builder
UVector* selectors = nullptr;
UVector* variants = nullptr;
UVector* bindings = nullptr;
public:
Builder& addBinding(Binding&& b, UErrorCode& status);
Builder& addSelector(VariableName&& selector, UErrorCode& errorCode);
Builder& addVariant(SelectorKeys&& keys, Pattern&& pattern, UErrorCode& errorCode) noexcept;
Builder& setPattern(Pattern&& pattern);
MFDataModel build(UErrorCode& status) const noexcept;
Builder(UErrorCode& status);
virtual ~Builder();
Builder(const Builder&) = delete;
Builder& operator=(const Builder&) = delete;
Builder(Builder&&) = delete;
Builder& operator=(Builder&&) = delete;
}; // class Builder
private:
friend class message2::Checker;
friend class message2::MessageFormatter;
friend class message2::Serializer;
Pattern empty; // Provided so that `getPattern()` can return a result
// if called on a selectors message
bool hasPattern() const { return std::holds_alternative<Pattern>(body); }
bool bogus = false; // Set if a copy constructor fails
// A message body is either a matcher (selector list and variant list),
// or a single pattern
std::variant<Matcher, Pattern> body;
// Bindings for local variables
/* const */ LocalArray<Binding> bindings;
int32_t bindingsLen = 0;
const Binding* getLocalVariablesInternal() const;
const VariableName* getSelectorsInternal() const;
const Variant* getVariantsInternal() const;
int32_t numSelectors() const {
const Matcher* matcher = std::get_if<Matcher>(&body);
return (matcher == nullptr ? 0 : matcher->numSelectors);
}
int32_t numVariants() const {
const Matcher* matcher = std::get_if<Matcher>(&body);
return (matcher == nullptr ? 0 : matcher->numVariants);
}
// Helper
void initBindings(const Binding*);
MFDataModel(const Builder& builder, UErrorCode&) noexcept;
}; // class MFDataModel
} // namespace data_model
} // namespace message2
U_NAMESPACE_END
#endif // U_HIDE_DEPRECATED_API
#endif /* #if !UCONFIG_NO_MF2 */
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif /* #if !UCONFIG_NO_NORMALIZATION */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // MESSAGEFORMAT_DATA_MODEL_H
// eof
icu::LocalArray
"Smart pointer" class, deletes objects via the C++ array delete[] operator.
Definition: localpointer.h:364
icu::UMemory
UMemory is the common ICU base class.
Definition: uobject.h:115
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:222
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:303
icu::message2::MessageFormatter
Definition: messageformat2.h:54
icu::message2::data_model::Binding
A Binding pairs a variable name with an expression.
Definition: messageformat2_data_model.h:1897
icu::message2::data_model::Binding::operator=
Binding & operator=(Binding) noexcept
Copy assignment operator.
icu::message2::data_model::Binding::isLocal
UBool isLocal() const
Returns true if and only if this binding represents a local declaration.
Definition: messageformat2_data_model.h:1941
icu::message2::data_model::Binding::Binding
Binding(const Binding &other)
Copy constructor.
icu::message2::data_model::Binding::getValue
const Expression & getValue() const
Accesses the right-hand side of a binding.
icu::message2::data_model::Binding::getVariable
const VariableName & getVariable() const
Accesses the left-hand side of the binding.
Definition: messageformat2_data_model.h:1916
icu::message2::data_model::Binding::Binding
Binding()
Default constructor.
Definition: messageformat2_data_model.h:1990
icu::message2::data_model::Binding::input
static Binding input(UnicodeString &&variableName, Expression &&rhs, UErrorCode &errorCode)
Constructor for input binding.
icu::message2::data_model::Binding::Binding
Binding(const VariableName &v, Expression &&e)
Constructor.
Definition: messageformat2_data_model.h:1951
icu::message2::data_model::Binding::~Binding
virtual ~Binding()
Destructor.
icu::message2::data_model::Binding::swap
friend void swap(Binding &b1, Binding &b2) noexcept
Non-member swap function.
Definition: messageformat2_data_model.h:1960
icu::message2::data_model::Expression::Builder
The mutable Expression::Builder class allows the operator to be constructed incrementally.
Definition: messageformat2_data_model.h:1227
icu::message2::data_model::Expression::Builder::build
Expression build(UErrorCode &status)
Constructs a new immutable Expression using the operand and operator that were previously set.
icu::message2::data_model::Expression::Builder::~Builder
virtual ~Builder()
Destructor.
icu::message2::data_model::Expression::Builder::addAttribute
Builder & addAttribute(const UnicodeString &key, Operand &&value, UErrorCode &status)
Adds a single attribute.
icu::message2::data_model::Expression::Builder::setOperator
Builder & setOperator(Operator &&rAtor)
Sets the operator of this expression.
icu::message2::data_model::Expression::Builder::setOperand
Builder & setOperand(Operand &&rAnd)
Sets the operand of this expression.
icu::message2::data_model::Expression::Builder::Builder
Builder(UErrorCode &status)
Default constructor.
icu::message2::data_model::Expression
The Expression class corresponds to the expression nonterminal in the MessageFormat 2 grammar and the...
Definition: messageformat2_data_model.h:1161
icu::message2::data_model::Expression::Expression
U_I18N_API Expression()
Default constructor.
icu::message2::data_model::Expression::getOperand
U_I18N_API const Operand & getOperand() const
Accesses the operand of this expression.
icu::message2::data_model::Expression::swap
U_I18N_API friend void swap(Expression &e1, Expression &e2) noexcept
Non-member swap function.
Definition: messageformat2_data_model.h:1317
icu::message2::data_model::Expression::getAttributes
U_I18N_API std::vector< Option > getAttributes() const
Gets the attributes of this expression.
Definition: messageformat2_data_model.h:1217
icu::message2::data_model::Expression::operator=
U_I18N_API Expression & operator=(Expression) noexcept
Assignment operator.
icu::message2::data_model::Expression::~Expression
virtual U_I18N_API ~Expression()
Destructor.
icu::message2::data_model::Expression::getOperator
U_I18N_API const Operator * getOperator(UErrorCode &status) const
Accesses the function annotating this expression.
icu::message2::data_model::Expression::isStandaloneAnnotation
U_I18N_API UBool isStandaloneAnnotation() const
Checks if this expression is an annotation with no operand.
icu::message2::data_model::Expression::isFunctionCall
U_I18N_API UBool isFunctionCall() const
Checks if this expression has a function annotation (with or without an operand).
icu::message2::data_model::Expression::Expression
U_I18N_API Expression(const Expression &other)
Copy constructor.
icu::message2::data_model::Key
The Key class corresponds to the key nonterminal in the MessageFormat 2 grammar, https://github....
Definition: messageformat2_data_model.h:346
icu::message2::data_model::Key::asLiteral
U_I18N_API const Literal & asLiteral() const
Returns the contents of this key as a literal.
icu::message2::data_model::Key::operator==
U_I18N_API bool operator==(const Key &other) const
Equality operator.
icu::message2::data_model::Key::operator<
U_I18N_API bool operator<(const Key &other) const
Less than operator.
icu::message2::data_model::Key::operator=
U_I18N_API Key & operator=(Key) noexcept
Assignment operator.
icu::message2::data_model::Key::~Key
virtual U_I18N_API ~Key()
Destructor.
icu::message2::data_model::Key::isWildcard
U_I18N_API UBool isWildcard() const
Determines if this is a wildcard key.
Definition: messageformat2_data_model.h:356
icu::message2::data_model::Key::Key
U_I18N_API Key(const Literal &lit)
Literal key constructor.
Definition: messageformat2_data_model.h:391
icu::message2::data_model::Key::Key
U_I18N_API Key(const Key &other)
Copy constructor.
Definition: messageformat2_data_model.h:373
icu::message2::data_model::Key::swap
U_I18N_API friend void swap(Key &k1, Key &k2) noexcept
Non-member swap function.
Definition: messageformat2_data_model.h:400
icu::message2::data_model::Key::Key
U_I18N_API Key()
Wildcard constructor; constructs a Key representing the catchall or wildcard key, '*'.
Definition: messageformat2_data_model.h:381
icu::message2::data_model::Literal
The Literal class corresponds to the literal nonterminal in the MessageFormat 2 grammar,...
Definition: messageformat2_data_model.h:78
icu::message2::data_model::Literal::isQuoted
UBool isQuoted() const
Determines if this literal appeared as a quoted literal in the message.
Definition: messageformat2_data_model.h:107
icu::message2::data_model::Literal::swap
friend void swap(Literal &l1, Literal &l2) noexcept
Non-member swap function.
Definition: messageformat2_data_model.h:135
icu::message2::data_model::Literal::Literal
Literal(UBool q, const UnicodeString &s)
Literal constructor.
Definition: messageformat2_data_model.h:119
icu::message2::data_model::Literal::unquoted
const UnicodeString & unquoted() const
Returns the parsed string contents of this literal.
icu::message2::data_model::Literal::quoted
UnicodeString quoted() const
Returns the quoted representation of this literal (enclosed in '|' characters)
icu::message2::data_model::Literal::Literal
Literal()=default
Default constructor.
icu::message2::data_model::Literal::operator<
bool operator<(const Literal &other) const
Less than operator.
icu::message2::data_model::Literal::operator=
Literal & operator=(Literal) noexcept
Assignment operator.
icu::message2::data_model::Literal::Literal
Literal(const Literal &other)
Copy constructor.
Definition: messageformat2_data_model.h:126
icu::message2::data_model::Literal::operator==
bool operator==(const Literal &other) const
Equality operator.
icu::message2::data_model::Literal::~Literal
virtual ~Literal()
Destructor.
icu::message2::data_model::MFDataModel::Builder
The mutable MFDataModel::Builder class allows the data model to be constructed incrementally.
Definition: messageformat2_data_model.h:2258
icu::message2::data_model::MFDataModel::Builder::addBinding
Builder & addBinding(Binding &&b, UErrorCode &status)
Adds a binding, There must not already be a binding with the same name.
icu::message2::data_model::MFDataModel::Builder::Builder
Builder(UErrorCode &status)
Default constructor.
icu::message2::data_model::MFDataModel::Builder::addSelector
Builder & addSelector(VariableName &&selector, UErrorCode &errorCode)
Adds a selector variable.
icu::message2::data_model::MFDataModel::Builder::build
MFDataModel build(UErrorCode &status) const noexcept
Constructs a new immutable data model.
icu::message2::data_model::MFDataModel::Builder::addVariant
Builder & addVariant(SelectorKeys &&keys, Pattern &&pattern, UErrorCode &errorCode) noexcept
Adds a single variant.
icu::message2::data_model::MFDataModel::Builder::~Builder
virtual ~Builder()
Destructor.
icu::message2::data_model::MFDataModel::Builder::setPattern
Builder & setPattern(Pattern &&pattern)
Sets the body of the message as a pattern.
icu::message2::data_model::MFDataModel
The MFDataModel class describes a parsed representation of the text of a message.
Definition: messageformat2_data_model.h:2095
icu::message2::data_model::MFDataModel::getVariants
U_I18N_API std::vector< Variant > getVariants() const
Accesses the variants.
Definition: messageformat2_data_model.h:2170
icu::message2::data_model::MFDataModel::getSelectors
U_I18N_API std::vector< VariableName > getSelectors() const
Accesses the selectors.
Definition: messageformat2_data_model.h:2154
icu::message2::data_model::MFDataModel::MFDataModel
U_I18N_API MFDataModel(const MFDataModel &other)
Copy constructor.
icu::message2::data_model::MFDataModel::~MFDataModel
virtual U_I18N_API ~MFDataModel()
Destructor.
icu::message2::data_model::MFDataModel::swap
U_I18N_API friend void swap(MFDataModel &m1, MFDataModel &m2) noexcept
Non-member swap function.
Definition: messageformat2_data_model.h:2214
icu::message2::data_model::MFDataModel::getLocalVariables
U_I18N_API std::vector< Binding > getLocalVariables() const
Accesses the local variable declarations for this data model.
Definition: messageformat2_data_model.h:2139
icu::message2::data_model::MFDataModel::MFDataModel
U_I18N_API MFDataModel()
Default constructor.
icu::message2::data_model::MFDataModel::operator=
U_I18N_API MFDataModel & operator=(MFDataModel) noexcept
Assignment operator.
icu::message2::data_model::Markup::Builder
The mutable Markup::Builder class allows the markup to be constructed incrementally.
Definition: messageformat2_data_model.h:1024
icu::message2::data_model::Markup::Builder::setName
Builder & setName(const UnicodeString &n)
Sets the name of this markup.
Definition: messageformat2_data_model.h:1042
icu::message2::data_model::Markup::Builder::setStandalone
Builder & setStandalone()
Sets this to be a standalone markup.
Definition: messageformat2_data_model.h:1069
icu::message2::data_model::Markup::Builder::Builder
Builder(UErrorCode &status)
Default constructor.
icu::message2::data_model::Markup::Builder::setOpen
Builder & setOpen()
Sets this to be an opening markup.
Definition: messageformat2_data_model.h:1051
icu::message2::data_model::Markup::Builder::addOption
Builder & addOption(const UnicodeString &key, Operand &&value, UErrorCode &status)
Adds a single option.
icu::message2::data_model::Markup::Builder::~Builder
virtual ~Builder()
Destructor.
icu::message2::data_model::Markup::Builder::setClose
Builder & setClose()
Sets this to be an closing markup.
Definition: messageformat2_data_model.h:1060
icu::message2::data_model::Markup::Builder::build
Markup build(UErrorCode &status)
Constructs a new immutable Markup using the name and type and (optionally) options and attributes tha...
icu::message2::data_model::Markup::Builder::addAttribute
Builder & addAttribute(const UnicodeString &key, Operand &&value, UErrorCode &status)
Adds a single attribute.
icu::message2::data_model::Markup
The Markup class corresponds to the markup nonterminal in the MessageFormat 2 grammar and the markup ...
Definition: messageformat2_data_model.h:944
icu::message2::data_model::Markup::Markup
Markup()
Default constructor.
Definition: messageformat2_data_model.h:1007
icu::message2::data_model::Markup::getAttributes
std::vector< Option > getAttributes() const
Gets the attributes of this markup.
Definition: messageformat2_data_model.h:999
icu::message2::data_model::Markup::isOpen
UBool isOpen() const
Checks if this markup is an opening tag.
Definition: messageformat2_data_model.h:954
icu::message2::data_model::Markup::isClose
UBool isClose() const
Checks if this markup is an closing tag.
Definition: messageformat2_data_model.h:963
icu::message2::data_model::Markup::~Markup
virtual ~Markup()
Destructor.
icu::message2::data_model::Markup::getOptions
std::vector< Option > getOptions() const
Gets the options of this markup.
Definition: messageformat2_data_model.h:990
icu::message2::data_model::Markup::getName
const UnicodeString & getName() const
Gets the name of this markup.
Definition: messageformat2_data_model.h:981
icu::message2::data_model::Markup::isStandalone
UBool isStandalone() const
Checks if this markup is an standalone tag.
Definition: messageformat2_data_model.h:972
icu::message2::data_model::Operand
The Operand class corresponds to the operand nonterminal in the MessageFormat 2 grammar,...
Definition: messageformat2_data_model.h:215
icu::message2::data_model::Operand::isNull
virtual U_I18N_API UBool isNull() const
Determines if this operand is the null operand.
icu::message2::data_model::Operand::asVariable
U_I18N_API const UnicodeString & asVariable() const
Returns a reference to this operand's variable name.
icu::message2::data_model::Operand::Operand
U_I18N_API Operand(const Operand &)
Copy constructor.
icu::message2::data_model::Operand::isLiteral
U_I18N_API UBool isLiteral() const
Determines if this operand represents a literal.
icu::message2::data_model::Operand::swap
U_I18N_API friend void swap(Operand &o1, Operand &o2) noexcept
Non-member swap function.
Definition: messageformat2_data_model.h:300
icu::message2::data_model::Operand::Operand
U_I18N_API Operand(const UnicodeString &v)
Variable operand constructor.
Definition: messageformat2_data_model.h:281
icu::message2::data_model::Operand::operator=
virtual U_I18N_API Operand & operator=(Operand) noexcept
Assignment operator.
icu::message2::data_model::Operand::isVariable
U_I18N_API UBool isVariable() const
Determines if this operand represents a variable.
icu::message2::data_model::Operand::Operand
U_I18N_API Operand(const Literal &l)
Literal operand constructor.
Definition: messageformat2_data_model.h:291
icu::message2::data_model::Operand::asLiteral
U_I18N_API const Literal & asLiteral() const
Returns a reference to this operand's literal contents.
icu::message2::data_model::Operand::~Operand
virtual U_I18N_API ~Operand()
Destructor.
icu::message2::data_model::Operand::Operand
U_I18N_API Operand()
Default constructor.
Definition: messageformat2_data_model.h:271
icu::message2::data_model::Operator::Builder
The mutable Operator::Builder class allows the operator to be constructed incrementally.
Definition: messageformat2_data_model.h:798
icu::message2::data_model::Operator::Builder::build
Operator build(UErrorCode &status)
Constructs a new immutable Operator using the function name and options that were previously set.
icu::message2::data_model::Operator::Builder::setFunctionName
Builder & setFunctionName(FunctionName &&func)
Sets this operator to be a function annotation and sets its name to func.
icu::message2::data_model::Operator::Builder::addOption
Builder & addOption(const UnicodeString &key, Operand &&value, UErrorCode &status) noexcept
Sets this operator to be a function annotation and adds a single option.
icu::message2::data_model::Operator::Builder::Builder
Builder(UErrorCode &status)
Default constructor.
icu::message2::data_model::Operator::Builder::~Builder
virtual ~Builder()
Destructor.
icu::message2::data_model::Operator
The Operator class corresponds to the FunctionRef type in the Expression interface defined in https:/...
Definition: messageformat2_data_model.h:767
icu::message2::data_model::Operator::Operator
Operator(const Operator &other) noexcept
Copy constructor.
icu::message2::data_model::Operator::operator=
Operator & operator=(Operator) noexcept
Assignment operator.
icu::message2::data_model::Operator::~Operator
virtual ~Operator()
Destructor.
icu::message2::data_model::Operator::Operator
Operator()
Default constructor.
Definition: messageformat2_data_model.h:901
icu::message2::data_model::Operator::swap
friend void swap(Operator &o1, Operator &o2) noexcept
Non-member swap function.
Definition: messageformat2_data_model.h:881
icu::message2::data_model::Operator::getFunctionName
const FunctionName & getFunctionName() const
Accesses the function name.
icu::message2::data_model::Operator::getOptions
std::vector< Option > getOptions() const
Accesses function options.
Definition: messageformat2_data_model.h:786
icu::message2::data_model::Option
An Option pairs an option name with an Operand.
Definition: messageformat2_data_model.h:619
icu::message2::data_model::Option::getName
const UnicodeString & getName() const
Accesses the left-hand side of the option.
Definition: messageformat2_data_model.h:638
icu::message2::data_model::Option::operator=
Option & operator=(Option other) noexcept
Assignment operator.
icu::message2::data_model::Option::getValue
const Operand & getValue() const
Accesses the right-hand side of the option.
Definition: messageformat2_data_model.h:629
icu::message2::data_model::Option::Option
Option(const Option &other)
Copy constructor.
icu::message2::data_model::Option::~Option
virtual ~Option()
Destructor.
icu::message2::data_model::Option::Option
Option()
Default constructor.
Definition: messageformat2_data_model.h:657
icu::message2::data_model::Option::Option
Option(const UnicodeString &n, Operand &&r)
Constructor.
Definition: messageformat2_data_model.h:649
icu::message2::data_model::Option::swap
friend void swap(Option &o1, Option &o2) noexcept
Non-member swap function.
Definition: messageformat2_data_model.h:666
icu::message2::data_model::PatternPart
A PatternPart is a single element (text or expression) in a Pattern.
Definition: messageformat2_data_model.h:1392
icu::message2::data_model::PatternPart::isMarkup
U_I18N_API UBool isMarkup() const
Checks if the part is a markup part.
Definition: messageformat2_data_model.h:1411
icu::message2::data_model::PatternPart::PatternPart
U_I18N_API PatternPart(const PatternPart &other)
Copy constructor.
icu::message2::data_model::PatternPart::~PatternPart
virtual U_I18N_API ~PatternPart()
Destructor.
icu::message2::data_model::PatternPart::isExpression
U_I18N_API UBool isExpression() const
Checks if the part is an expression part.
Definition: messageformat2_data_model.h:1420
icu::message2::data_model::PatternPart::PatternPart
U_I18N_API PatternPart(const UnicodeString &t)
Text part constructor.
Definition: messageformat2_data_model.h:1494
icu::message2::data_model::PatternPart::asText
U_I18N_API const UnicodeString & asText() const
Accesses the text contents of the part.
icu::message2::data_model::PatternPart::asMarkup
U_I18N_API const Markup & asMarkup() const
Accesses the expression of the part.
icu::message2::data_model::PatternPart::swap
U_I18N_API friend void swap(PatternPart &p1, PatternPart &p2) noexcept
Non-member swap function.
Definition: messageformat2_data_model.h:1459
icu::message2::data_model::PatternPart::contents
U_I18N_API const Expression & contents() const
Accesses the expression of the part.
icu::message2::data_model::PatternPart::PatternPart
U_I18N_API PatternPart(Markup &&m)
Markup part constructor.
Definition: messageformat2_data_model.h:1514
icu::message2::data_model::PatternPart::isText
U_I18N_API UBool isText() const
Checks if the part is a text part.
Definition: messageformat2_data_model.h:1402
icu::message2::data_model::PatternPart::PatternPart
U_I18N_API PatternPart()=default
Default constructor.
icu::message2::data_model::PatternPart::PatternPart
U_I18N_API PatternPart(Expression &&e)
Expression part constructor.
Definition: messageformat2_data_model.h:1504
icu::message2::data_model::PatternPart::operator=
U_I18N_API PatternPart & operator=(PatternPart) noexcept
Assignment operator.
icu::message2::data_model::Pattern::Builder
The mutable Pattern::Builder class allows the pattern to be constructed one part at a time.
Definition: messageformat2_data_model.h:1580
icu::message2::data_model::Pattern::Builder::~Builder
virtual ~Builder()
Destructor.
icu::message2::data_model::Pattern::Builder::build
Pattern build(UErrorCode &status) const noexcept
Constructs a new immutable Pattern using the list of parts set with previous add() calls.
icu::message2::data_model::Pattern::Builder::Builder
Builder(UErrorCode &status)
Default constructor.
icu::message2::data_model::Pattern::Builder::add
Builder & add(UnicodeString &&part, UErrorCode &status) noexcept
Adds a single text part to the pattern.
icu::message2::data_model::Pattern::Builder::add
Builder & add(Expression &&part, UErrorCode &status) noexcept
Adds a single expression part to the pattern.
icu::message2::data_model::Pattern::Builder::add
Builder & add(Markup &&part, UErrorCode &status) noexcept
Adds a single markup part to the pattern.
icu::message2::data_model::Pattern
A Pattern is a sequence of formattable parts.
Definition: messageformat2_data_model.h:1539
icu::message2::data_model::Pattern::begin
U_I18N_API Iterator begin() const
Returns the parts of this pattern.
Definition: messageformat2_data_model.h:1556
icu::message2::data_model::Pattern::swap
U_I18N_API friend void swap(Pattern &p1, Pattern &p2) noexcept
Non-member swap function.
Definition: messageformat2_data_model.h:1672
icu::message2::data_model::Pattern::~Pattern
virtual U_I18N_API ~Pattern()
Destructor.
icu::message2::data_model::Pattern::end
U_I18N_API Iterator end() const
Returns a special value to mark the end of iteration.
Definition: messageformat2_data_model.h:1568
icu::message2::data_model::Pattern::operator=
U_I18N_API Pattern & operator=(Pattern) noexcept
Assignment operator.
icu::message2::data_model::Pattern::Pattern
U_I18N_API Pattern(const Pattern &other)
Copy constructor.
icu::message2::data_model::Pattern::Pattern
U_I18N_API Pattern()
Default constructor.
Definition: messageformat2_data_model.h:1663
icu::message2::data_model::SelectorKeys::Builder
The mutable SelectorKeys::Builder class allows the key list to be constructed one key at a time.
Definition: messageformat2_data_model.h:485
icu::message2::data_model::SelectorKeys::Builder::add
Builder & add(Key &&key, UErrorCode &status) noexcept
Adds a single key to the list.
icu::message2::data_model::SelectorKeys::Builder::~Builder
virtual ~Builder()
Destructor.
icu::message2::data_model::SelectorKeys::Builder::Builder
Builder(UErrorCode &status)
Default constructor.
icu::message2::data_model::SelectorKeys::Builder::build
SelectorKeys build(UErrorCode &status) const
Constructs a new immutable SelectorKeys using the list of keys set with previous add() calls.
icu::message2::data_model::SelectorKeys
The SelectorKeys class represents the key list for a single variant.
Definition: messageformat2_data_model.h:461
icu::message2::data_model::SelectorKeys::SelectorKeys
U_I18N_API SelectorKeys(const SelectorKeys &other)
Copy constructor.
icu::message2::data_model::SelectorKeys::swap
U_I18N_API friend void swap(SelectorKeys &s1, SelectorKeys &s2) noexcept
Non-member swap function.
Definition: messageformat2_data_model.h:569
icu::message2::data_model::SelectorKeys::SelectorKeys
U_I18N_API SelectorKeys()
Default constructor.
Definition: messageformat2_data_model.h:560
icu::message2::data_model::SelectorKeys::getKeys
U_I18N_API std::vector< Key > getKeys() const
Returns the underlying list of keys.
Definition: messageformat2_data_model.h:473
icu::message2::data_model::SelectorKeys::operator<
U_I18N_API bool operator<(const SelectorKeys &other) const
Less than operator.
icu::message2::data_model::SelectorKeys::operator=
U_I18N_API SelectorKeys & operator=(SelectorKeys other) noexcept
Assignment operator.
icu::message2::data_model::SelectorKeys::~SelectorKeys
virtual U_I18N_API ~SelectorKeys()
Destructor.
icu::message2::data_model::Variant
A Variant pairs a list of keys with a pattern It corresponds to the Variant interface defined in http...
Definition: messageformat2_data_model.h:1807
icu::message2::data_model::Variant::Variant
Variant(const Variant &)
Copy constructor.
icu::message2::data_model::Variant::Variant
Variant(const SelectorKeys &keys, Pattern &&pattern)
Constructor.
Definition: messageformat2_data_model.h:1838
icu::message2::data_model::Variant::~Variant
virtual ~Variant()
Destructor.
icu::message2::data_model::Variant::swap
friend void swap(Variant &v1, Variant &v2) noexcept
Non-member swap function.
Definition: messageformat2_data_model.h:1847
icu::message2::data_model::Variant::operator=
Variant & operator=(Variant other) noexcept
Assignment operator.
icu::message2::data_model::Variant::getKeys
const SelectorKeys & getKeys() const
Accesses the keys of the variant.
Definition: messageformat2_data_model.h:1826
icu::message2::data_model::Variant::Variant
Variant()=default
Default constructor.
icu::message2::data_model::Variant::getPattern
const Pattern & getPattern() const
Accesses the pattern of the variant.
Definition: messageformat2_data_model.h:1817
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
icu::operator==
U_COMMON_API UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::operator!=
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:346
icu::message2::data_model::Pattern::Iterator
The Pattern::Iterator class provides an iterator over the formattable parts of a pattern.
Definition: messageformat2_data_model.h:1710
icu::message2::data_model::Pattern::Iterator::operator*
reference operator*() const
Dereference operator (gets the element at the current iterator position)
Definition: messageformat2_data_model.h:1732
icu::message2::data_model::Pattern::Iterator::operator++
Iterator operator++()
Increment operator (advances to the next iterator position)
Definition: messageformat2_data_model.h:1742
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:509
U_I18N_API_CLASS
#define U_I18N_API_CLASS
Set to export library symbols from inside the i18n library, and to import them from outside,...
Definition: utypes.h:457
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:316