6#ifndef MESSAGEFORMAT2_FORMATTABLE_H
7#define MESSAGEFORMAT2_FORMATTABLE_H
9#if U_SHOW_CPLUSPLUS_API
11#if !UCONFIG_NO_FORMATTING
17#include "unicode/messageformat2_data_model_names.h"
19#ifndef U_HIDE_DEPRECATED_API
78#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
79#if defined(U_REAL_MSVC) && defined(_MSVC_STL_VERSION)
80template class U_I18N_API std::_Variant_storage_<
false,
86 std::pair<const icu::message2::Formattable *,int32_t>>;
88typedef std::pair<const icu::message2::Formattable*, int32_t>
P;
139 return (std::get_if<icu::Formattable>(&contents))->getDouble();
141 if (std::holds_alternative<double>(contents)) {
142 return *(std::get_if<double>(&contents));
160 if (isDecimal() && getType() ==
UFMT_LONG) {
161 return std::get_if<icu::Formattable>(&contents)->getLong();
163 if (std::holds_alternative<int64_t>(contents)) {
164 return static_cast<int32_t>(*(std::get_if<int64_t>(&contents)));
184 return std::get_if<icu::Formattable>(&contents)->getInt64();
186 if (std::holds_alternative<int64_t>(contents)) {
187 return *(std::get_if<int64_t>(&contents));
220 if (std::holds_alternative<UnicodeString>(contents)) {
221 return *std::get_if<UnicodeString>(&contents);
240 return *std::get_if<double>(&contents);
283 return *std::get_if<const FormattableObject*>(&contents);
301 swap(
f1.contents,
f2.contents);
302 swap(
f1.holdsDate,
f2.holdsDate);
426 std::pair<const Formattable*, int32_t>> contents;
427 bool holdsDate =
false;
430 UBool isDecimal()
const {
431 return std::holds_alternative<icu::Formattable>(contents);
433 UBool isDate()
const {
434 return std::holds_alternative<double>(contents) && holdsDate;
452class U_I18N_API ResolvedFunctionOption :
public UObject {
459 const UnicodeString& getName()
const {
return name; }
460 const Formattable& getValue()
const {
return value; }
461 ResolvedFunctionOption(
const UnicodeString& n,
const Formattable& f) : name(n), value(f) {}
462 ResolvedFunctionOption() {}
463 ResolvedFunctionOption(ResolvedFunctionOption&&);
464 ResolvedFunctionOption& operator=(ResolvedFunctionOption&& other)
noexcept {
465 name = std::move(other.name);
466 value = std::move(other.value);
469 virtual ~ResolvedFunctionOption();
480using FunctionOptionsMap = std::map<UnicodeString, message2::Formattable>;
506 FunctionOptionsMap
result;
561 int32_t optionsCount()
const {
return functionOptionsLen; }
568 int32_t functionOptionsLen = 0;
711 : fallback(input.fallback), source(input.source),
726 : fallback(input.fallback), source(input.source),
727 formatted(
std::move(output)), previousOptions(
std::move(
opts)), type(kEvaluated) {}
738 : fallback(
fb), source(input), type(kUnevaluated) {}
795 bool canFormat()
const {
return !(isFallback() || isNullOperand()); }
C++ API: Character Iterator.
Base class for objects to which Unicode characters and strings can be appended.
Abstract class that defines an API for iteration on text objects.
Represents a span of a string containing a given field.
"Smart pointer" base class; do not use directly: use LocalPointer etc.
A Locale object represents a specific geographical, political, or cultural region.
A string-like object that points to a sized piece of memory.
UObject is the common ICU "boilerplate" class.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Structure encapsulating named options passed to a custom selector or formatter.
FunctionOptions()
Default constructor.
FunctionOptions & operator=(FunctionOptions &&) noexcept
Move assignment operator: The source FunctionOptions will be left in a valid but undefined state.
virtual ~FunctionOptions()
Destructor.
FunctionOptionsMap getOptions() const
Returns a map of all name-value pairs provided as options to this function.
int8_t UBool
The ICU boolean type, a signed-byte integer.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
@ U_ILLEGAL_ARGUMENT_ERROR
Start of codes indicating failure.
@ U_UNSUPPORTED_ERROR
Requested operation not supported in current context.
#define U_SUCCESS(x)
Does the error code indicate success?
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
double UDate
Date and Time data type.