|
ICU4C 79
|
Type representing argument and return values for custom functions. More...
#include <messageformat2_function_registry.h>
Public Member Functions | |
| virtual U_I18N_API UnicodeString | formatToString (UErrorCode &status) const |
| Returns the string representation of this value. | |
| virtual U_I18N_API const Formattable & | unwrap () const |
| Returns the Formattable operand that was used to construct this value. | |
| virtual U_I18N_API const FunctionOptions & | getResolvedOptions () const |
| Returns a reference to the resolved options for this value. | |
| virtual U_I18N_API UMFDirectionality | getDirection () const |
| Returns the directionality of this value, i.e. | |
| virtual U_I18N_API UMFBidiOption | getDirectionAnnotation () const |
| Returns the directionality that this value was annotated with. | |
| virtual U_I18N_API UBool | isSelectable () const |
| Returns true if this value supports selection. | |
| virtual U_I18N_API UBool | isNullOperand () const |
| Returns true if this value represents a null operand, that is, the absence of an argument. | |
| virtual U_I18N_API void | selectKeys (const UnicodeString *keys, int32_t keysLen, int32_t *prefs, int32_t &prefsLen, UErrorCode &status) const |
| Compares this value to an array of keys, and returns an array of matching keys sorted by preference. | |
| virtual U_I18N_API const FunctionName & | getFunctionName () const |
| Returns the name of the function that constructed this value. | |
| virtual U_I18N_API const UnicodeString & | getFallback () const |
| Returns a fallback string that can be used as output if processing this function results in an error. | |
| virtual U_I18N_API | ~FunctionValue () |
| Destructor. | |
| 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. | |
Protected Attributes | |
| Formattable | innerValue |
| Computed result of the function invocation that returned this FunctionValue. | |
| FunctionOptions | opts |
| Resolved options attached to this value. | |
| FunctionName | functionName |
| The name of the function that constructed this FunctionValue. | |
| UnicodeString | fallback |
| Fallback string that can be used if a later function encounters an error when processing this FunctionValue. | |
| Locale | locale |
| Locale from u:locale option. | |
| UMFDirectionality | dir = U_MF_DIRECTIONALITY_UNKNOWN |
| Directionality of formatted result. | |
| UMFBidiOption | inputDir = U_MF_BIDI_OPTION_INHERIT |
| Input directionality from u:dir option. | |
Friends | |
| class | FunctionOptions |
Type representing argument and return values for custom functions.
It encapsulates an operand and resolved options, and can be extended with additional state. Adding a new custom function requires adding a new class that implements this interface.
FunctionValues are assumed to be immutable (the call() method on Function takes a const FunctionValue&, and the formatToString() and selectKeys() methods are const.) Feedback on whether internal mutable state in classes implementing FunctionValue is welcomed during the Technology Preview period.
Definition at line 368 of file messageformat2_function_registry.h.
|
virtual |
Destructor.
References U_I18N_API.
|
inlinevirtual |
Returns the string representation of this value.
The default method signals an error. Must be overridden by classes implementing values that support formatting.
| status | Input/output error code |
Definition at line 381 of file messageformat2_function_registry.h.
References U_I18N_API, U_MF_FORMATTING_ERROR, and U_SUCCESS.
|
inlinevirtual |
Returns the directionality of this value, i.e.
the directionality that its formatted result should have.
Definition at line 417 of file messageformat2_function_registry.h.
References dir, and U_I18N_API.
|
inlinevirtual |
Returns the directionality that this value was annotated with.
This is distinct from the directionality of the formatted text. See the description of the "Default Bidi Strategy", https://github.com/unicode-org/message-format-wg/blob/main/spec/formatting.md#handling-bidirectional-text for further context.
Definition at line 432 of file messageformat2_function_registry.h.
References inputDir, and U_I18N_API.
|
inlinevirtual |
Returns a fallback string that can be used as output if processing this function results in an error.
Definition at line 512 of file messageformat2_function_registry.h.
References fallback, and U_I18N_API.
|
inlinevirtual |
Returns the name of the function that constructed this value.
Definition at line 502 of file messageformat2_function_registry.h.
References functionName, and U_I18N_API.
|
inlinevirtual |
Returns a reference to the resolved options for this value.
Definition at line 406 of file messageformat2_function_registry.h.
References opts, and U_I18N_API.
|
inlinevirtual |
Returns true if this value represents a null operand, that is, the absence of an argument.
This method should not be overridden. It can be called in order to check whether the argument is present. Some functions may be nullary (they may work with no arguments).
Definition at line 459 of file messageformat2_function_registry.h.
References U_I18N_API.
|
inlinevirtual |
Returns true if this value supports selection.
The default method returns false. The method must be overridden for values that support selection.
Definition at line 443 of file messageformat2_function_registry.h.
References U_I18N_API.
|
inlinevirtual |
Compares this value to an array of keys, and returns an array of matching keys sorted by preference.
The default implementation of this method signals an error. It should be overridden for value classes that support selection.
| keys | An array of strings to compare to the input. |
| keysLen | The length of keys. |
| prefs | An array of indices into keys. The initial contents of the array is undefined. selectKey() should set the contents of prefs to a subset of the indices in keys, with the best match placed at the lowest index in prefs. |
| prefsLen | A reference that selectKey() should set to the length of prefs, which must be less than or equal to keysLen. |
| status | Input/output error code. |
Definition at line 480 of file messageformat2_function_registry.h.
References U_I18N_API, U_MF_SELECTOR_ERROR, and U_SUCCESS.
|
inlinevirtual |
Returns the Formattable operand that was used to construct this value.
The operand may be obtained from calling getOperand() on the input FunctionValue, or it may be constructed separately.
Definition at line 397 of file messageformat2_function_registry.h.
References innerValue, and U_I18N_API.
|
friend |
Definition at line 579 of file messageformat2_function_registry.h.
|
protected |
Directionality of formatted result.
Defaults to U_MF_DIRECTIONALITY_UNKNOWN if not set by the subclass's constructor.
Definition at line 568 of file messageformat2_function_registry.h.
Referenced by getDirection().
|
protected |
Fallback string that can be used if a later function encounters an error when processing this FunctionValue.
Definition at line 551 of file messageformat2_function_registry.h.
Referenced by getFallback().
|
protected |
The name of the function that constructed this FunctionValue.
Definition at line 543 of file messageformat2_function_registry.h.
Referenced by getFunctionName().
|
protected |
Computed result of the function invocation that returned this FunctionValue.
This may simply be the operand, or may be a value computed from the operand.
Definition at line 529 of file messageformat2_function_registry.h.
Referenced by unwrap().
|
protected |
Input directionality from u:dir option.
Defaults to U_MF_BIDI_OPTION_INHERIT if not set by the subclass's constructor.
Definition at line 577 of file messageformat2_function_registry.h.
Referenced by getDirectionAnnotation().
|
protected |
Locale from u:locale option.
Must be set from function context.
Definition at line 559 of file messageformat2_function_registry.h.
|
protected |
Resolved options attached to this value.
Definition at line 536 of file messageformat2_function_registry.h.
Referenced by getResolvedOptions().