ICU 78.1
78.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 | |
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::Formattable & | asFormattable () 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 UnicodeString & | getFallback () 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 FunctionOptions & | options () const |
Returns the options of this placeholder. More... | |
U_I18N_API const FormattedValue & | output () const |
Returns the formatted output of this placeholder. More... | |
U_I18N_API FormattedPlaceholder & | operator= (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... | |
![]() | |
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 |
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 691 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 703 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 715 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 730 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 742 of file messageformat2_formattable.h.
|
inline |
Default constructor.
Leaves the FormattedPlaceholder in a valid but undefined state.
Definition at line 751 of file messageformat2_formattable.h.
|
inline |
Move constructor: The source FormattedPlaceholder will be left in a valid but undefined state.
Definition at line 840 of file messageformat2_formattable.h.
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.
|
inline |
Returns true iff this represents a valid argument to the formatter.
Definition at line 800 of file messageformat2_formattable.h.
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.
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 808 of file messageformat2_formattable.h.
|
inline |
Returns true iff this has formatting output.
Formattable
and output FormattedValue
.Definition at line 791 of file messageformat2_formattable.h.
|
inline |
Returns true iff this is a fallback placeholder.
Formattable
source or formatting output.Definition at line 771 of file messageformat2_formattable.h.
|
inline |
Returns true iff this is a null placeholder.
Definition at line 781 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 817 of file messageformat2_formattable.h.
|
inline |
Returns the formatted output of this placeholder.
The result is undefined if !isEvaluated().
FormattedPlaceholder
. Definition at line 824 of file messageformat2_formattable.h.