ICU 77.1
77.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. More... | |
FormattedPlaceholder (const FormattedPlaceholder &input, FormattedValue &&output) | |
Constructor for fully formatted placeholders. More... | |
FormattedPlaceholder (const FormattedPlaceholder &input, FunctionOptions &&opts, FormattedValue &&output) | |
Constructor for fully formatted placeholders with options. More... | |
FormattedPlaceholder (const Formattable &input, const UnicodeString &fb) | |
Constructor for unformatted placeholders. More... | |
FormattedPlaceholder () | |
Default constructor. More... | |
const message2::Formattable & | asFormattable () const |
Returns the source Formattable value for this placeholder. More... | |
bool | isFallback () const |
Returns true iff this is a fallback placeholder. More... | |
bool | isNullOperand () const |
Returns true iff this is a null placeholder. More... | |
bool | isEvaluated () const |
Returns true iff this has formatting output. More... | |
bool | canFormat () const |
Returns true iff this represents a valid argument to the formatter. More... | |
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... | |
const FunctionOptions & | options () const |
Returns the options of this placeholder. More... | |
const FormattedValue & | output () const |
Returns the formatted output of this placeholder. More... | |
FormattedPlaceholder & | operator= (FormattedPlaceholder &&) noexcept |
Move assignment operator: The source FormattedPlaceholder will be left in a valid but undefined state. More... | |
FormattedPlaceholder (FormattedPlaceholder &&other) | |
Move constructor: The source FormattedPlaceholder will be left in a valid but undefined state. More... | |
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 687 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 699 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 711 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 726 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 738 of file messageformat2_formattable.h.
|
inline |
Default constructor.
Leaves the FormattedPlaceholder in a valid but undefined state.
Definition at line 747 of file messageformat2_formattable.h.
|
inline |
Move constructor: The source FormattedPlaceholder will be left in a valid but undefined state.
Definition at line 837 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 796 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 804 of file messageformat2_formattable.h.
|
inline |
Returns true iff this has formatting output.
Formattable
and output FormattedValue
.Definition at line 787 of file messageformat2_formattable.h.
|
inline |
Returns true iff this is a fallback placeholder.
Formattable
source or formatting output.Definition at line 767 of file messageformat2_formattable.h.
|
inline |
Returns true iff this is a null placeholder.
Definition at line 777 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 813 of file messageformat2_formattable.h.
|
inline |
Returns the formatted output of this placeholder.
The result is undefined if !isEvaluated().
FormattedPlaceholder
. Definition at line 821 of file messageformat2_formattable.h.