|
ICU4C 79
|
The mutable Builder class allows each part of the MessageFormatter to be initialized separately; calling its build() method yields an immutable MessageFormatter. More...
#include <messageformat2.h>
Public Member Functions | |
| U_I18N_API Builder & | setLocale (const Locale &locale) |
| Sets the locale to use for formatting. | |
| U_I18N_API Builder & | setPattern (const UnicodeString &pattern, UParseError &parseError, UErrorCode &status) |
| Sets the pattern (contents of the message) and parses it into a data model. | |
| U_I18N_API Builder & | setFunctionRegistry (const MFFunctionRegistry &functionRegistry) |
| Sets a custom function registry. | |
| U_I18N_API Builder & | setDataModel (MFDataModel &&dataModel) |
| Sets a data model. | |
| U_I18N_API Builder & | setErrorHandlingBehavior (UMFErrorHandlingBehavior type) |
| Set the error handling behavior for this formatter. | |
| U_I18N_API Builder & | setBidiIsolationStrategy (UMFBidiIsolationStrategy strategy) |
| Set the bidi isolation behavior for this formatter. | |
| U_I18N_API Builder & | setBidiIsolationStyle (UMFBidiIsolationStyle style) |
| Set the bidi isolation style for this formatter. | |
| U_I18N_API Builder & | setBidiContext (UMFBidiContext dir) |
| Set the directionality context of the input message. | |
| U_I18N_API MessageFormatter | build (UErrorCode &status) const |
| Constructs a new immutable MessageFormatter using the pattern or data model that was previously set, and the locale (if it was previously set) or default locale (otherwise). | |
| U_I18N_API | Builder (UErrorCode &status) |
| Default constructor. | |
| virtual U_I18N_API | ~Builder () |
| 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. | |
Friends | |
| class | MessageFormatter |
The mutable Builder class allows each part of the MessageFormatter to be initialized separately; calling its build() method yields an immutable MessageFormatter.
Not copyable or movable.
Definition at line 214 of file messageformat2.h.
| U_I18N_API icu::message2::MessageFormatter::Builder::Builder | ( | UErrorCode & | status | ) |
Default constructor.
Returns a Builder with the default locale and with no data model or pattern set. Either setPattern() or setDataModel() has to be called before calling build().
| status | Input/output error code. |
References U_I18N_API.
Referenced by setBidiContext(), setBidiIsolationStrategy(), setBidiIsolationStyle(), setDataModel(), setErrorHandlingBehavior(), setFunctionRegistry(), setLocale(), and setPattern().
|
virtual |
Destructor.
References U_I18N_API.
| U_I18N_API MessageFormatter icu::message2::MessageFormatter::Builder::build | ( | UErrorCode & | status | ) | const |
Constructs a new immutable MessageFormatter using the pattern or data model that was previously set, and the locale (if it was previously set) or default locale (otherwise).
The builder object (this) can still be used after calling build().
| status | Input/output error code. If neither the pattern nor the data model is set, set to failure code. |
References U_I18N_API.
| U_I18N_API Builder & icu::message2::MessageFormatter::Builder::setBidiContext | ( | UMFBidiContext | dir | ) |
Set the directionality context of the input message.
"LTR" means left-to-right and "RTL" means right-to-left. "AUTO" means to infer the context from the locale (either what was set with setLocale(), or the default locale if setLocale() was never called on the builder.)
| dir | An enum with type UMFBidiContext that specifies the directionality of the message. The default is U_MF_BIDI_CONTEXT_AUTO.. |
References Builder(), and U_I18N_API.
| U_I18N_API Builder & icu::message2::MessageFormatter::Builder::setBidiIsolationStrategy | ( | UMFBidiIsolationStrategy | strategy | ) |
Set the bidi isolation behavior for this formatter.
"OFF" means that no bidi isolation will be performed. "AUTO" means that the default bidi isolation strategy as described in the MF2 specification ( https://github.com/unicode-org/message-format-wg/blob/main/spec/formatting.md#handling-bidirectional-text ) will be applied.
| strategy | An enum with type UMFBidiIsolationStrategy; that specifies how bidi isolation marks are inserted into the formatting result. The default is U_MF_BIDI_AUTO. |
References Builder(), and U_I18N_API.
| U_I18N_API Builder & icu::message2::MessageFormatter::Builder::setBidiIsolationStyle | ( | UMFBidiIsolationStyle | style | ) |
Set the bidi isolation style for this formatter.
"CONTROL" means that bidi control characters will be inserted into the formatted result. "HTML_SPAN" means that HTML markup will be inserted into the formatted result.
| style | An enum with type UMFBidiIsolationStyle that specifies how bidi isolation is applied to the formatting result. The default is U_MF_BIDI_STYLE_CONTROL. |
References Builder(), and U_I18N_API.
| U_I18N_API Builder & icu::message2::MessageFormatter::Builder::setDataModel | ( | MFDataModel && | dataModel | ) |
Sets a data model.
If a pattern was previously set, it is removed.
| dataModel | Data model to format. Passed by move. |
References Builder(), and U_I18N_API.
| U_I18N_API Builder & icu::message2::MessageFormatter::Builder::setErrorHandlingBehavior | ( | UMFErrorHandlingBehavior | type | ) |
Set the error handling behavior for this formatter.
"Strict" error behavior means that that formatting methods will set their UErrorCode arguments to signal MessageFormat data model, resolution, and runtime errors. Syntax errors are always signaled.
"Best effort" error behavior means that MessageFormat errors are suppressed: formatting methods will not set their UErrorCode arguments to signal MessageFormat data model, resolution, or runtime errors. Best-effort output will be returned. Syntax errors are always signaled. This is the default behavior.
| type | An enum with type UMFErrorHandlingBehavior; if type == U_MF_STRICT, then errors are handled strictly. If type == U_MF_BEST_EFFORT, then best-effort output is returned. |
The default is to suppress all MessageFormat errors and return best-effort output.
References Builder(), and U_I18N_API.
| U_I18N_API Builder & icu::message2::MessageFormatter::Builder::setFunctionRegistry | ( | const MFFunctionRegistry & | functionRegistry | ) |
Sets a custom function registry.
| functionRegistry | Reference to the function registry to use. functionRegistry is not copied, and the caller must ensure its lifetime contains the lifetime of the MessageFormatter object built by this builder. Functions with the same name as standard functions will override the standard functions. |
References Builder(), and U_I18N_API.
| U_I18N_API Builder & icu::message2::MessageFormatter::Builder::setLocale | ( | const Locale & | locale | ) |
Sets the locale to use for formatting.
| locale | The desired locale. |
References Builder(), and U_I18N_API.
| U_I18N_API Builder & icu::message2::MessageFormatter::Builder::setPattern | ( | const UnicodeString & | pattern, |
| UParseError & | parseError, | ||
| UErrorCode & | status ) |
Sets the pattern (contents of the message) and parses it into a data model.
If a data model was previously set, it is removed.
| pattern | A string in MessageFormat 2.0 syntax. |
| parseError | Struct to receive information on the position of an error within the pattern. |
| status | Input/output error code. If the pattern cannot be parsed, set to failure code. |
References Builder(), and U_I18N_API.
|
friend |
Definition at line 216 of file messageformat2.h.