ICU 76.1 76.1

Public Member Functions
icu::message2::MFFunctionRegistry::Builder Class Reference

The mutable Builder class allows each formatter and selector factory to be initialized separately; calling its `build()` method yields an immutable MFFunctionRegistry object. More...

`#include <messageformat2_function_registry.h>`

Inheritance diagram for icu::message2::MFFunctionRegistry::Builder:

## Public Member Functions
Builder & | adoptFormatter (const data_model::FunctionName &formatterName, FormatterFactory *formatterFactory, UErrorCode &errorCode)
| Registers a formatter factory to a given formatter name. More...
Builder & | setDefaultFormatterNameByType (const UnicodeString &type, const data_model::FunctionName &functionName, UErrorCode &errorCode)
| Registers a formatter factory to a given type tag. More...
Builder & | adoptSelector (const data_model::FunctionName &selectorName, SelectorFactory *selectorFactory, UErrorCode &errorCode)
| Registers a selector factory to a given selector name. More...
MFFunctionRegistry | build ()
| Creates an immutable `MFFunctionRegistry` object with the selectors and formatters that were previously registered. More...
| Builder (UErrorCode &errorCode)
| Default constructor. More...
virtual | ~Builder ()
| Destructor. More...
Public Member Functions inherited from icu::UObject
virtual | ~UObject ()
| Destructor. More...
virtual UClassID | getDynamicClassID () const
| ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class. More...

## Detailed Description

The mutable Builder class allows each formatter and selector factory to be initialized separately; calling its `build()` method yields an immutable MFFunctionRegistry object.

Builder is not copyable or movable.

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 174 of file messageformat2_function_registry.h.

## Constructor & Destructor Documentation

## ◆ Builder()

icu::message2::MFFunctionRegistry::Builder::Builder | ( | UErrorCode & | errorCode | ) |

Default constructor.

Returns a Builder with no functions registered.

Parameters

  errorCode | Input/output error code

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

Deprecated:
  This API is for technology preview only.

## ◆ ~Builder()

virtual icu::message2::MFFunctionRegistry::Builder::~Builder | ( |  | ) |
| 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

## ◆ adoptFormatter()

Builder& icu::message2::MFFunctionRegistry::Builder::adoptFormatter | ( | const data_model::FunctionName & | formatterName,
|  | FormatterFactory * | formatterFactory,
|  | UErrorCode & | errorCode
| ) |  |

Registers a formatter factory to a given formatter name.

Parameters

  formatterName | Name of the formatter being registered.
  formatterFactory | A pointer to a FormatterFactory object to use for creating `formatterName` formatters. This argument is adopted.
  errorCode | Input/output error code

Returns
  A reference to the builder.

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

Deprecated:
  This API is for technology preview only.

## ◆ adoptSelector()

Builder& icu::message2::MFFunctionRegistry::Builder::adoptSelector | ( | const data_model::FunctionName & | selectorName,
|  | SelectorFactory * | selectorFactory,
|  | UErrorCode & | errorCode
| ) |  |

Registers a selector factory to a given selector name.

Adopts `selectorFactory`.

Parameters

  selectorName | Name of the selector being registered.
  selectorFactory | A SelectorFactory object to use for creating `selectorName` selectors.
  errorCode | Input/output error code

Returns
  A reference to the builder.

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

Deprecated:
  This API is for technology preview only.

## ◆ build()

MFFunctionRegistry icu::message2::MFFunctionRegistry::Builder::build | ( |  | ) |

Creates an immutable `MFFunctionRegistry` object with the selectors and formatters that were previously registered.

The builder cannot be used after this call. The `build()` method is destructive to avoid the need for a deep copy of the `FormatterFactory` and `SelectorFactory` objects (this would be necessary because `FormatterFactory` can have mutable state), which in turn would require implementors of those interfaces to implement a `clone()` method.

Returns
  The new MFFunctionRegistry

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

Deprecated:
  This API is for technology preview only.

## ◆ setDefaultFormatterNameByType()

Builder& icu::message2::MFFunctionRegistry::Builder::setDefaultFormatterNameByType | ( | const UnicodeString & | type,
|  | const data_model::FunctionName & | functionName,
|  | UErrorCode & | errorCode
| ) |  |

Registers a formatter factory to a given type tag.

(See `FormattableObject` for details on type tags.)

Parameters

  type | Tag for objects to be formatted with this formatter.
  functionName | A reference to the name of the function to use for creating formatters for `formatterType` objects.
  errorCode | Input/output error code

Returns
  A reference to the builder.

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

Deprecated:
  This API is for technology preview only.

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

- i18n/unicode/messageformat2_function_registry.h