ICU 76.1: icu::message2::FormattedPlaceholder Class Reference

ICU 76.1 76.1

Public Member Functions | Friends
icu::message2::FormattedPlaceholder Class Reference

A `FormattablePlaceholder` encapsulates an input value (a `message2::Formattable`) together with an optional output value (a `message2::FormattedValue`). More...

`#include <messageformat2_formattable.h>`

Inheritance diagram for icu::message2::FormattedPlaceholder:

## Public Member Functions
| FormattedPlaceholder (const UnicodeString &s)
| Fallback constructor.
| FormattedPlaceholder (const FormattedPlaceholder &input, FormattedValue &&output)
| Constructor for fully formatted placeholders.
| FormattedPlaceholder (const FormattedPlaceholder &input, FunctionOptions &&opts, FormattedValue &&output)
| Constructor for fully formatted placeholders with options.
| FormattedPlaceholder (const Formattable &input, const UnicodeString &fb)
| Constructor for unformatted placeholders.
| FormattedPlaceholder ()
| Default constructor.
const message2::Formattable & | asFormattable () const
| Returns the source `Formattable` value for this placeholder.
bool | isFallback () const
| Returns true iff this is a fallback placeholder.
bool | isNullOperand () const
| Returns true iff this is a null placeholder.
bool | isEvaluated () const
| Returns true iff this has formatting output.
bool | canFormat () const
| Returns true iff this represents a valid argument to the formatter.
const UnicodeString & | getFallback () const
| Gets the fallback value of this placeholder, to be used in its place if an error occurs while formatting it.
const FunctionOptions & | options () const
| Returns the options of this placeholder.
const FormattedValue & | output () const
| Returns the formatted output of this placeholder.
FormattedPlaceholder & | operator= (FormattedPlaceholder &&) noexcept
| Move assignment operator: The source FormattedPlaceholder will be left in a valid but undefined state.
| FormattedPlaceholder (FormattedPlaceholder &&other)
| Move constructor: The source FormattedPlaceholder will be left in a valid but undefined state.
UnicodeString | formatToString (const Locale &locale, UErrorCode &status) const
| Formats this as a string, using defaults.
Public Member Functions inherited from icu::UObject
virtual | ~UObject ()
| Destructor.
virtual UClassID | getDynamicClassID () const
| ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.

## Friends
class | MessageFormatter

## Detailed Description

A `FormattablePlaceholder` encapsulates an input value (a `message2::Formattable`) together with an optional output value (a `message2::FormattedValue`).

More information, such as source line/column numbers, could be added to the class in the future.

`FormattablePlaceholder` is immutable (not deeply immutable) and movable. It is not copyable.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 686 of file messageformat2_formattable.h.

## Constructor & Destructor Documentation

## ◆ FormattedPlaceholder() [1/6]

icu::message2::FormattedPlaceholder::FormattedPlaceholder | ( | const UnicodeString & | s | ) |
| inlineexplicit

Fallback constructor.

Constructs a value that represents a formatting error, without recording an input `Formattable` as the source.

Parameters

  s | An error string. (See the MessageFormat specification for details on fallback strings.)

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 698 of file messageformat2_formattable.h.

## ◆ FormattedPlaceholder() [2/6]

icu::message2::FormattedPlaceholder::FormattedPlaceholder | ( | const FormattedPlaceholder & | input,
|  | FormattedValue && | output )
| inline

Constructor for fully formatted placeholders.

Parameters

  input | A `FormattedPlaceholder` containing the fallback string and source `Formattable` used to construct the formatted value.
  output | A `FormattedValue` representing the formatted output of `input`. Passed by move.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 710 of file messageformat2_formattable.h.

## ◆ FormattedPlaceholder() [3/6]

icu::message2::FormattedPlaceholder::FormattedPlaceholder | ( | const FormattedPlaceholder & | input,
|  | FunctionOptions && | opts,
|  | FormattedValue && | output )
| inline

Constructor for fully formatted placeholders with options.

Parameters

  input | A `FormattedPlaceholder` containing the fallback string and source `Formattable` used to construct the formatted value.
  opts | Function options that were used to construct `output`. May be the empty map.
  output | A `FormattedValue` representing the formatted output of `input`. Passed by move.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 725 of file messageformat2_formattable.h.

## ◆ FormattedPlaceholder() [4/6]

icu::message2::FormattedPlaceholder::FormattedPlaceholder | ( | const Formattable & | input,
|  | const UnicodeString & | fb )
| inline

Constructor for unformatted placeholders.

Parameters

  input | A `Formattable` object.
  fb | Fallback string to use if an error occurs while formatting the input.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 737 of file messageformat2_formattable.h.

## ◆ FormattedPlaceholder() [5/6]

icu::message2::FormattedPlaceholder::FormattedPlaceholder | ( |  | ) |
| inline

Default constructor.

Leaves the FormattedPlaceholder in a valid but undefined state.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 746 of file messageformat2_formattable.h.

## ◆ FormattedPlaceholder() [6/6]

icu::message2::FormattedPlaceholder::FormattedPlaceholder | ( | FormattedPlaceholder && | other | ) |
| inline

Move constructor: The source FormattedPlaceholder will be left in a valid but undefined state.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 836 of file messageformat2_formattable.h.

## Member Function Documentation

## ◆ asFormattable()

const message2::Formattable & icu::message2::FormattedPlaceholder::asFormattable | ( |  | ) | const

Returns the source `Formattable` value for this placeholder.

The result is undefined if this is a null operand.

Returns
  A message2::Formattable value.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

## ◆ canFormat()

bool icu::message2::FormattedPlaceholder::canFormat | ( |  | ) | const
| inline

Returns true iff this represents a valid argument to the formatter.

Returns
  True if and only if this is neither the null argument nor a fallback placeholder.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 795 of file messageformat2_formattable.h.

## ◆ formatToString()

UnicodeString icu::message2::FormattedPlaceholder::formatToString | ( | const Locale & | locale,
|  | UErrorCode & | status ) const

Formats this as a string, using defaults.

If this is either the null operand or is a fallback value, the return value is the result of formatting the fallback value (which is the default fallback string if this is the null operand). If there is no formatted output and the input is object- or array-typed, then the argument is treated as a fallback value, since there is no default formatter for objects or arrays.

Parameters

  locale | The locale to use for formatting numbers or dates
  status | Input/output error code

Returns
  The result of formatting this placeholder.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

## ◆ getFallback()

const UnicodeString & icu::message2::FormattedPlaceholder::getFallback | ( |  | ) | const
| inline

Gets the fallback value of this placeholder, to be used in its place if an error occurs while formatting it.

Returns
  A reference to this placeholder's fallback string.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 803 of file messageformat2_formattable.h.

## ◆ isEvaluated()

bool icu::message2::FormattedPlaceholder::isEvaluated | ( |  | ) | const
| inline

Returns true iff this has formatting output.

Returns
  True if and only if this was constructed from both an input `Formattable` and output `FormattedValue`.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 786 of file messageformat2_formattable.h.

## ◆ isFallback()

bool icu::message2::FormattedPlaceholder::isFallback | ( |  | ) | const
| inline

Returns true iff this is a fallback placeholder.

Returns
  True if and only if this placeholder was constructed from a fallback string, with no `Formattable` source or formatting output.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 766 of file messageformat2_formattable.h.

## ◆ isNullOperand()

bool icu::message2::FormattedPlaceholder::isNullOperand | ( |  | ) | const
| inline

Returns true iff this is a null placeholder.

Returns
  True if and only if this placeholder represents the absent argument to a formatter that was invoked without an argument.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 776 of file messageformat2_formattable.h.

## ◆ operator=()

FormattedPlaceholder & icu::message2::FormattedPlaceholder::operator= | ( | FormattedPlaceholder && |  | ) |
| noexcept

Move assignment operator: The source FormattedPlaceholder will be left in a valid but undefined state.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

## ◆ options()

const FunctionOptions & icu::message2::FormattedPlaceholder::options | ( |  | ) | const
| inline

Returns the options of this placeholder.

The result is the empty map if !isEvaluated().

Returns
  A reference to an option map, capturing the options that were used in producing the output of this `FormattedPlaceholder` (or empty if there is no output)

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 812 of file messageformat2_formattable.h.

## ◆ output()

const FormattedValue & icu::message2::FormattedPlaceholder::output | ( |  | ) | const
| inline

Returns the formatted output of this placeholder.

The result is undefined if !isEvaluated().

Returns
  A fully formatted `FormattedPlaceholder`.

Internal
  Do not use. This API is for internal use only. ICU 75 technology preview

Deprecated
  This API is for technology preview only.

Definition at line 820 of file messageformat2_formattable.h.

## Friends And Related Symbol Documentation

## ◆ MessageFormatter

friend class MessageFormatter
| friend

Definition at line 856 of file messageformat2_formattable.h.

The documentation for this class was generated from the following file:

- i18n/unicode/messageformat2_formattable.h