ICU 78.1  78.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:
icu::UObject icu::UMemory

Public Member Functions

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

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 691 of file messageformat2_formattable.h.

Constructor & Destructor Documentation

◆ FormattedPlaceholder() [1/6]

U_I18N_API 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
sAn 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 703 of file messageformat2_formattable.h.

◆ FormattedPlaceholder() [2/6]

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

Constructor for fully formatted placeholders.

Parameters
inputA FormattedPlaceholder containing the fallback string and source Formattable used to construct the formatted value.
outputA 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 715 of file messageformat2_formattable.h.

◆ FormattedPlaceholder() [3/6]

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

Constructor for fully formatted placeholders with options.

Parameters
inputA FormattedPlaceholder containing the fallback string and source Formattable used to construct the formatted value.
optsFunction options that were used to construct output. May be the empty map.
outputA 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 730 of file messageformat2_formattable.h.

◆ FormattedPlaceholder() [4/6]

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

Constructor for unformatted placeholders.

Parameters
inputA Formattable object.
fbFallback 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 742 of file messageformat2_formattable.h.

◆ FormattedPlaceholder() [5/6]

U_I18N_API 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 751 of file messageformat2_formattable.h.

◆ FormattedPlaceholder() [6/6]

U_I18N_API 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 840 of file messageformat2_formattable.h.

Member Function Documentation

◆ asFormattable()

U_I18N_API 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()

U_I18N_API 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 800 of file messageformat2_formattable.h.

◆ formatToString()

U_I18N_API 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
localeThe locale to use for formatting numbers or dates
statusInput/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()

U_I18N_API 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 808 of file messageformat2_formattable.h.

◆ isEvaluated()

U_I18N_API 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 791 of file messageformat2_formattable.h.

◆ isFallback()

U_I18N_API 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 771 of file messageformat2_formattable.h.

◆ isNullOperand()

U_I18N_API 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 781 of file messageformat2_formattable.h.

◆ operator=()

U_I18N_API 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()

U_I18N_API 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 817 of file messageformat2_formattable.h.

◆ output()

U_I18N_API 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 824 of file messageformat2_formattable.h.


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