ICU 75.1 75.1

Public Member Functions | Friends
icu::message2::MFDataModel::Builder Class Reference

The mutable `MFDataModel::Builder` class allows the data model to be constructed incrementally. More...

`#include <messageformat2_data_model.h>`

Inheritance diagram for icu::message2::MFDataModel::Builder:

## Public Member Functions
Builder & | addBinding (Binding &&b, UErrorCode &status)
| Adds a binding, There must not already be a binding with the same name. More...
Builder & | addUnsupportedStatement (UnsupportedStatement &&s, UErrorCode &status)
| Adds an unsupported statement. More...
Builder & | addSelector (Expression &&selector, UErrorCode &errorCode) noexcept
| Adds a selector expression. More...
Builder & | addVariant (SelectorKeys &&keys, Pattern &&pattern, UErrorCode &errorCode) noexcept
| Adds a single variant. More...
Builder & | setPattern (Pattern &&pattern)
| Sets the body of the message as a pattern. More...
MFDataModel | build (UErrorCode &status) const noexcept
| Constructs a new immutable data model. More...
| Builder (UErrorCode &status)
| Default constructor. More...
virtual | ~Builder ()
| Destructor. More...
| Builder (const Builder &)=delete
Builder & | operator= (const Builder &)=delete
| Builder (Builder &&)=delete
Builder & | operator= (Builder &&)=delete

## Friends
class | MFDataModel

## Detailed Description

The mutable `MFDataModel::Builder` class allows the data model to be constructed incrementally.

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 2908 of file messageformat2_data_model.h.

## Constructor & Destructor Documentation

## ◆ Builder()

icu::message2::MFDataModel::Builder::Builder | ( | UErrorCode & | status | ) |

Default constructor.

Returns a Builder with no pattern or selectors set. Either `setPattern()` or both `addSelector()` and `addVariant()` must be called before calling `build()` on the resulting builder.

Parameters

  status | 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::MFDataModel::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

## ◆ addBinding()

Builder& icu::message2::MFDataModel::Builder::addBinding | ( | Binding && | b,
|  | UErrorCode & | status
| ) |  |

Adds a binding, There must not already be a binding with the same name.

Parameters

  b | The binding. Passed by move.
  status | Input/output error code. Set to U_DUPLICATE_DECLARATION_ERROR if `addBinding()` was previously called with a binding with the same variable name as `b`.

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

Deprecated:
  This API is for technology preview only.

## ◆ addSelector()

Builder& icu::message2::MFDataModel::Builder::addSelector | ( | Expression && | selector,
|  | UErrorCode & | errorCode
| ) |  |
| noexcept

Adds a selector expression.

Copies `expression`. If a pattern was previously set, clears the pattern.

Parameters

  selector | Expression to add as a selector. Passed by move.
  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.

## ◆ addUnsupportedStatement()

Builder& icu::message2::MFDataModel::Builder::addUnsupportedStatement | ( | UnsupportedStatement && | s,
|  | UErrorCode & | status
| ) |  |

Adds an unsupported statement.

Parameters

  s | The statement. Passed by move.
  status | 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.

## ◆ addVariant()

Builder& icu::message2::MFDataModel::Builder::addVariant | ( | SelectorKeys && | keys,
|  | Pattern && | pattern,
|  | UErrorCode & | errorCode
| ) |  |
| noexcept

Adds a single variant.

If a pattern was previously set using `setPattern()`, clears the pattern.

Parameters

  keys | Keys for the variant. Passed by move.
  pattern | Pattern for the variant. Passed by move.
  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()

MFDataModel icu::message2::MFDataModel::Builder::build | ( | UErrorCode & | status | ) | const
| noexcept

Constructs a new immutable data model.

If `setPattern()` has not been called and if `addSelector()` and `addVariant()` were not each called at least once, `status` is set to `U_INVALID_STATE_ERROR`. If `addSelector()` was called and `addVariant()` was never called, or vice versa, then `status` is set to U_INVALID_STATE_ERROR. Otherwise, either a Pattern or Selectors message is constructed based on the pattern that was previously set, or selectors and variants that were previously set.

The builder object (`this`) can still be used after calling `build()`.

Parameters

  status | Input/output error code.

Returns
  The new MFDataModel

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

Deprecated:
  This API is for technology preview only.

## ◆ setPattern()

Builder& icu::message2::MFDataModel::Builder::setPattern | ( | Pattern && | pattern | ) |

Sets the body of the message as a pattern.

If selectors and/or variants were previously set, clears them.

Parameters

  pattern | Pattern to represent the body of the message. Passed by move.

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_data_model.h