ICU 76.1 76.1
Loading...
Searching...
No Matches
Data Structures | Public Types | Public Member Functions | Friends
icu::message2::MessageFormatter Class Reference

#include <messageformat2.h>

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

Data Structures

class  Builder
 The mutable Builder class allows each part of the MessageFormatter to be initialized separately; calling its build() method yields an immutable MessageFormatter. More...
 

Public Types

enum  UMFErrorHandlingBehavior { U_MF_BEST_EFFORT = 0 , U_MF_STRICT }
 Used in conjunction with the MessageFormatter::Builder::setErrorHandlingBehavior() method. More...
 
typedef enum icu::message2::MessageFormatter::UMFErrorHandlingBehavior UMFErrorHandlingBehavior
 Used in conjunction with the MessageFormatter::Builder::setErrorHandlingBehavior() method.
 

Public Member Functions

MessageFormatteroperator= (MessageFormatter &&) noexcept
 Move assignment operator: The source MessageFormatter will be left in a valid but undefined state.
 
virtual ~MessageFormatter ()
 Destructor.
 
UnicodeString formatToString (const MessageArguments &arguments, UErrorCode &status)
 Formats the message to a string, using the data model that was previously set or parsed, and the given arguments object.
 
FormattedMessage format (const MessageArguments &arguments, UErrorCode &status) const
 Not yet implemented; formats the message to a FormattedMessage object, using the data model that was previously set or parsed, and the given arguments object.
 
const LocalegetLocale () const
 Accesses the locale that this MessageFormatter object was created with.
 
UnicodeString getPattern () const
 Serializes the data model as a string in MessageFormat 2.0 syntax.
 
const MFDataModel & getDataModel () const
 Accesses the data model referred to by this MessageFormatter object.
 
const UnicodeStringgetNormalizedPattern () const
 Returns a string consisting of the input with optional spaces removed.
 
- 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 Builder
 
class MessageContext
 

Detailed Description

MessageFormatter is a Technical Preview API implementing MessageFormat 2.0.

See the description of the syntax with examples and use cases and the corresponding ABNF grammar.

The MessageFormatter class is mutable and movable. It is not copyable. (It is mutable because if it has a custom function registry, the registry may include FormatterFactory objects implementing custom formatters, which are allowed to contain mutable state.)

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

Definition at line 51 of file messageformat2.h.

Member Typedef Documentation

◆ UMFErrorHandlingBehavior

Used in conjunction with the MessageFormatter::Builder::setErrorHandlingBehavior() method.

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

Member Enumeration Documentation

◆ UMFErrorHandlingBehavior

Used in conjunction with the MessageFormatter::Builder::setErrorHandlingBehavior() method.

Internal:
Do not use. This API is for internal use only. ICU 76 technology preview
Deprecated:
This API is for technology preview only.
Enumerator
U_MF_BEST_EFFORT 

Suppress errors and return best-effort output.

Internal:
Do not use. This API is for internal use only. ICU 76 technology preview
Deprecated:
This API is for technology preview only.
U_MF_STRICT 

Signal all MessageFormat errors using the UErrorCode argument.

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

Definition at line 149 of file messageformat2.h.

Constructor & Destructor Documentation

◆ ~MessageFormatter()

virtual icu::message2::MessageFormatter::~MessageFormatter ( )
virtual

Destructor.

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

Member Function Documentation

◆ format()

FormattedMessage icu::message2::MessageFormatter::format ( const MessageArguments arguments,
UErrorCode status 
) const
inline

Not yet implemented; formats the message to a FormattedMessage object, using the data model that was previously set or parsed, and the given arguments object.

Parameters
argumentsReference to message arguments
statusInput/output error code used to indicate syntax errors, data model errors, resolution errors, formatting errors, selection errors, as well as other errors (such as memory allocation failures). Partial output is still provided in the presence of most error types.
Returns
The FormattedMessage representing the formatted message.
Internal:
Do not use. This API is for internal use only. ICU 75 technology preview
Deprecated:
This API is for technology preview only.

Definition at line 102 of file messageformat2.h.

References U_SUCCESS, and U_UNSUPPORTED_ERROR.

◆ formatToString()

UnicodeString icu::message2::MessageFormatter::formatToString ( const MessageArguments arguments,
UErrorCode status 
)

Formats the message to a string, using the data model that was previously set or parsed, and the given arguments object.

Parameters
argumentsReference to message arguments
statusInput/output error code used to indicate syntax errors, data model errors, resolution errors, formatting errors, selection errors, as well as other errors (such as memory allocation failures). Partial output is still provided in the presence of most error types.
Returns
The string result of formatting the message with the given arguments.
Internal:
Do not use. This API is for internal use only. ICU 75 technology preview
Deprecated:
This API is for technology preview only.

◆ getDataModel()

const MFDataModel & icu::message2::MessageFormatter::getDataModel ( ) const

Accesses the data model referred to by this MessageFormatter object.

Returns
A reference to the data model.
Internal:
Do not use. This API is for internal use only. ICU 75 technology preview
Deprecated:
This API is for technology preview only.

◆ getLocale()

const Locale & icu::message2::MessageFormatter::getLocale ( ) const
inline

Accesses the locale that this MessageFormatter object was created with.

Returns
A reference to the locale.
Internal:
Do not use. This API is for internal use only. ICU 75 technology preview
Deprecated:
This API is for technology preview only.

Definition at line 118 of file messageformat2.h.

◆ getNormalizedPattern()

const UnicodeString & icu::message2::MessageFormatter::getNormalizedPattern ( ) const
inline

Returns a string consisting of the input with optional spaces removed.

Returns
A normalized string representation of the input
Internal:
Do not use. This API is for internal use only. ICU 75 technology preview
Deprecated:
This API is for technology preview only.

Definition at line 324 of file messageformat2.h.

◆ getPattern()

UnicodeString icu::message2::MessageFormatter::getPattern ( ) const

Serializes the data model as a string in MessageFormat 2.0 syntax.

Returns
result A string representation of the data model. The string is a valid MessageFormat 2.0 message.
Internal:
Do not use. This API is for internal use only. ICU 75 technology preview
Deprecated:
This API is for technology preview only.

◆ operator=()

MessageFormatter & icu::message2::MessageFormatter::operator= ( MessageFormatter &&  )
noexcept

Move assignment operator: The source MessageFormatter will be left in a valid but undefined state.

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

Friends And Related Symbol Documentation

◆ Builder

Definition at line 327 of file messageformat2.h.

◆ MessageContext

friend class MessageContext
friend

Definition at line 328 of file messageformat2.h.


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