Loading...
Searching...
No Matches
icu::message2::MessageFormatter Class Reference

`#include <messageformat2.h>`

Inheritance diagram for icu::message2::MessageFormatter:

## 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

U_I18N_API MessageFormatter & | operator= (MessageFormatter &&) noexcept
| Move assignment operator: The source MessageFormatter will be left in a valid but undefined state.
virtual U_I18N_API | ~MessageFormatter ()
| Destructor.
U_I18N_API 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.
U_I18N_API 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.
U_I18N_API const Locale & | getLocale () const
| Accesses the locale that this MessageFormatter object was created with.
U_I18N_API UnicodeString | getPattern () const
| Serializes the data model as a string in MessageFormat 2.0 syntax.
U_I18N_API const MFDataModel & | getDataModel () const
| Accesses the data model referred to by this MessageFormatter object.
U_I18N_API const UnicodeString & | getNormalizedPattern () 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 | Checker
class | MessageArguments
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 54 of file messageformat2.h.

## Member Typedef Documentation

## UMFErrorHandlingBehavior

typedef enum icu::message2::MessageFormatter::UMFErrorHandlingBehavior icu::message2::MessageFormatter::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

enum icu::message2::MessageFormatter::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 152 of file messageformat2.h.

## Constructor & Destructor Documentation

## ~MessageFormatter()

virtual U_I18N_API 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.

References U_I18N_API.

## Member Function Documentation

## format()

U_I18N_API 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

  arguments | Reference to message arguments
  status | Input/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 105 of file messageformat2.h.

References format(), U_I18N_API, U_SUCCESS, and U_UNSUPPORTED_ERROR.

Referenced by format().

## formatToString()

U_I18N_API 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

  arguments | Reference to message arguments
  status | Input/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.

References formatToString(), and U_I18N_API.

Referenced by formatToString().

## getDataModel()

U_I18N_API 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.

References U_I18N_API.

## getLocale()

U_I18N_API 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 121 of file messageformat2.h.

References U_I18N_API.

## getNormalizedPattern()

U_I18N_API 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 329 of file messageformat2.h.

References U_I18N_API.

## getPattern()

U_I18N_API 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.

References U_I18N_API.

## operator=()

U_I18N_API 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.

References U_I18N_API.

## Friends And Related Symbol Documentation

## Builder

friend class Builder

friend

Definition at line 332 of file messageformat2.h.

## Checker

friend class Checker

friend

Definition at line 333 of file messageformat2.h.

## MessageArguments

friend class MessageArguments

friend

Definition at line 334 of file messageformat2.h.

## MessageContext

friend class MessageContext

friend

Definition at line 335 of file messageformat2.h.

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

- i18n/unicode/messageformat2.h