ICU 76.1 76.1
|
A FormattablePlaceholder
encapsulates an input value (a message2::Formattable
) together with an optional output value (a message2::FormattedValue
).
More...
#include <messageformat2_formattable.h>
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 |
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.
Definition at line 686 of file messageformat2_formattable.h.
|
inlineexplicit |
Fallback constructor.
Constructs a value that represents a formatting error, without recording an input Formattable
as the source.
s | An error string. (See the MessageFormat specification for details on fallback strings.) |
Definition at line 698 of file messageformat2_formattable.h.
|
inline |
Constructor for fully formatted placeholders.
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. |
Definition at line 710 of file messageformat2_formattable.h.
|
inline |
Constructor for fully formatted placeholders with options.
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. |
Definition at line 725 of file messageformat2_formattable.h.
|
inline |
Constructor for unformatted placeholders.
input | A Formattable object. |
fb | Fallback string to use if an error occurs while formatting the input. |
Definition at line 737 of file messageformat2_formattable.h.
|
inline |
Default constructor.
Leaves the FormattedPlaceholder in a valid but undefined state.
Definition at line 746 of file messageformat2_formattable.h.
|
inline |
Move constructor: The source FormattedPlaceholder will be left in a valid but undefined state.
Definition at line 836 of file messageformat2_formattable.h.
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.
|
inline |
Returns true iff this represents a valid argument to the formatter.
Definition at line 795 of file messageformat2_formattable.h.
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.
locale | The locale to use for formatting numbers or dates |
status | Input/output error code |
|
inline |
Gets the fallback value of this placeholder, to be used in its place if an error occurs while formatting it.
Definition at line 803 of file messageformat2_formattable.h.
|
inline |
Returns true iff this has formatting output.
Formattable
and output FormattedValue
.Definition at line 786 of file messageformat2_formattable.h.
|
inline |
Returns true iff this is a fallback placeholder.
Formattable
source or formatting output.Definition at line 766 of file messageformat2_formattable.h.
|
inline |
Returns true iff this is a null placeholder.
Definition at line 776 of file messageformat2_formattable.h.
|
noexcept |
Move assignment operator: The source FormattedPlaceholder will be left in a valid but undefined state.
|
inline |
Returns the options of this placeholder.
The result is the empty map if !isEvaluated().
FormattedPlaceholder
(or empty if there is no output) Definition at line 812 of file messageformat2_formattable.h.
|
inline |
Returns the formatted output of this placeholder.
The result is undefined if !isEvaluated().
FormattedPlaceholder
. Definition at line 820 of file messageformat2_formattable.h.
|
friend |
Definition at line 856 of file messageformat2_formattable.h.