ICU4C 79
Loading...
Searching...
No Matches
icu::message2::FunctionValue Class Reference

Type representing argument and return values for custom functions. More...

#include <messageformat2_function_registry.h>

Inheritance diagram for icu::message2::FunctionValue:
icu::UObject icu::UMemory

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

Detailed Description

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.

Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 368 of file messageformat2_function_registry.h.

Constructor & Destructor Documentation

◆ ~FunctionValue()

virtual U_I18N_API icu::message2::FunctionValue::~FunctionValue ( )
virtual

Destructor.

Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

References U_I18N_API.

Member Function Documentation

◆ formatToString()

virtual U_I18N_API UnicodeString icu::message2::FunctionValue::formatToString ( UErrorCode & status) const
inlinevirtual

Returns the string representation of this value.

The default method signals an error. Must be overridden by classes implementing values that support formatting.

Parameters
statusInput/output error code
Returns
A string.
Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 381 of file messageformat2_function_registry.h.

References U_I18N_API, U_MF_FORMATTING_ERROR, and U_SUCCESS.

◆ getDirection()

virtual U_I18N_API UMFDirectionality icu::message2::FunctionValue::getDirection ( ) const
inlinevirtual

Returns the directionality of this value, i.e.

the directionality that its formatted result should have.

Returns
A UBiDiDirection indicating the directionality that the formatted result of this value should have.
Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 417 of file messageformat2_function_registry.h.

References dir, and U_I18N_API.

◆ getDirectionAnnotation()

virtual U_I18N_API UMFBidiOption icu::message2::FunctionValue::getDirectionAnnotation ( ) const
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.

Returns
A UMFBidiOption indicating the directionality that this value was annotated with.
Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 432 of file messageformat2_function_registry.h.

References inputDir, and U_I18N_API.

◆ getFallback()

virtual U_I18N_API const UnicodeString & icu::message2::FunctionValue::getFallback ( ) const
inlinevirtual

Returns a fallback string that can be used as output if processing this function results in an error.

Returns
A string determined by the creator of this FunctionValue.
Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 512 of file messageformat2_function_registry.h.

References fallback, and U_I18N_API.

◆ getFunctionName()

virtual U_I18N_API const FunctionName & icu::message2::FunctionValue::getFunctionName ( ) const
inlinevirtual

Returns the name of the function that constructed this value.

Returns
A string representing a function name. The string does not include a leading ':'.
Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 502 of file messageformat2_function_registry.h.

References functionName, and U_I18N_API.

◆ getResolvedOptions()

virtual U_I18N_API const FunctionOptions & icu::message2::FunctionValue::getResolvedOptions ( ) const
inlinevirtual

Returns a reference to the resolved options for this value.

Returns
A reference to the resolved options for this value.
Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 406 of file messageformat2_function_registry.h.

References opts, and U_I18N_API.

◆ isNullOperand()

virtual U_I18N_API UBool icu::message2::FunctionValue::isNullOperand ( ) const
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).

Returns
True iff this value represents an absent operand.
Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 459 of file messageformat2_function_registry.h.

References U_I18N_API.

◆ isSelectable()

virtual U_I18N_API UBool icu::message2::FunctionValue::isSelectable ( ) const
inlinevirtual

Returns true if this value supports selection.

The default method returns false. The method must be overridden for values that support selection.

Returns
True iff this value supports selection.
Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 443 of file messageformat2_function_registry.h.

References U_I18N_API.

◆ selectKeys()

virtual U_I18N_API void icu::message2::FunctionValue::selectKeys ( const UnicodeString * keys,
int32_t keysLen,
int32_t * prefs,
int32_t & prefsLen,
UErrorCode & status ) const
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.

Parameters
keysAn array of strings to compare to the input.
keysLenThe length of keys.
prefsAn 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.
prefsLenA reference that selectKey() should set to the length of prefs, which must be less than or equal to keysLen.
statusInput/output error code.
Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 480 of file messageformat2_function_registry.h.

References U_I18N_API, U_MF_SELECTOR_ERROR, and U_SUCCESS.

◆ unwrap()

virtual U_I18N_API const Formattable & icu::message2::FunctionValue::unwrap ( ) const
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.

Returns
A reference to a message2::Formattable object.
Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 397 of file messageformat2_function_registry.h.

References innerValue, and U_I18N_API.

◆ FunctionOptions

friend class FunctionOptions
friend

Definition at line 579 of file messageformat2_function_registry.h.

Field Documentation

◆ dir

UMFDirectionality icu::message2::FunctionValue::dir = U_MF_DIRECTIONALITY_UNKNOWN
protected

Directionality of formatted result.

Defaults to U_MF_DIRECTIONALITY_UNKNOWN if not set by the subclass's constructor.

Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 568 of file messageformat2_function_registry.h.

Referenced by getDirection().

◆ fallback

UnicodeString icu::message2::FunctionValue::fallback
protected

Fallback string that can be used if a later function encounters an error when processing this FunctionValue.

Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 551 of file messageformat2_function_registry.h.

Referenced by getFallback().

◆ functionName

FunctionName icu::message2::FunctionValue::functionName
protected

The name of the function that constructed this FunctionValue.

Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 543 of file messageformat2_function_registry.h.

Referenced by getFunctionName().

◆ innerValue

Formattable icu::message2::FunctionValue::innerValue
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.

Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 529 of file messageformat2_function_registry.h.

Referenced by unwrap().

◆ inputDir

UMFBidiOption icu::message2::FunctionValue::inputDir = U_MF_BIDI_OPTION_INHERIT
protected

Input directionality from u:dir option.

Defaults to U_MF_BIDI_OPTION_INHERIT if not set by the subclass's constructor.

Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 577 of file messageformat2_function_registry.h.

Referenced by getDirectionAnnotation().

◆ locale

Locale icu::message2::FunctionValue::locale
protected

Locale from u:locale option.

Must be set from function context.

Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 559 of file messageformat2_function_registry.h.

◆ opts

FunctionOptions icu::message2::FunctionValue::opts
protected

Resolved options attached to this value.

Internal
Do not use. This API is for internal use only. ICU 79 technology preview
Deprecated
This API is for technology preview only.

Definition at line 536 of file messageformat2_function_registry.h.

Referenced by getResolvedOptions().


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