ICU 54.1 54.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Data Structure Index
- Class Hierarchy
- Data Fields

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Public Member Functions
icu::BytesTrieBuilder Class Reference

Builder class for BytesTrie. More...

`#include <bytestriebuilder.h>`

Inheritance diagram for icu::BytesTrieBuilder:

## Data Structures
class | BTLinearMatchNode

## Public Member Functions
| BytesTrieBuilder (UErrorCode &errorCode)
| Constructs an empty builder.
virtual | ~BytesTrieBuilder ()
| Destructor.
BytesTrieBuilder & | add (const StringPiece &s, int32_t value, UErrorCode &errorCode)
| Adds a (byte sequence, value) pair.
BytesTrie * | build (UStringTrieBuildOption buildOption, UErrorCode &errorCode)
| Builds a BytesTrie for the add()ed data.
StringPiece | buildStringPiece (UStringTrieBuildOption buildOption, UErrorCode &errorCode)
| Builds a BytesTrie for the add()ed data and byte-serializes it.
BytesTrieBuilder & | clear ()
| Removes all (byte sequence, value) pairs.

## Additional Inherited Members
Static Public Member Functions inherited from icu::StringTrieBuilder
static UBool | hashNode (const void *node)
static UBool | equalNodes (const void *left, const void *right)
Protected Member Functions inherited from icu::StringTrieBuilder
| StringTrieBuilder ()
virtual | ~StringTrieBuilder ()
void | createCompactBuilder (int32_t sizeGuess, UErrorCode &errorCode)
void | deleteCompactBuilder ()
void | build (UStringTrieBuildOption buildOption, int32_t elementsLength, UErrorCode &errorCode)
int32_t | writeNode (int32_t start, int32_t limit, int32_t unitIndex)
int32_t | writeBranchSubNode (int32_t start, int32_t limit, int32_t unitIndex, int32_t length)
Node * | makeNode (int32_t start, int32_t limit, int32_t unitIndex, UErrorCode &errorCode)
Node * | makeBranchSubNode (int32_t start, int32_t limit, int32_t unitIndex, int32_t length, UErrorCode &errorCode)
virtual int32_t | getElementStringLength (int32_t i) const =0
virtual UChar | getElementUnit (int32_t i, int32_t unitIndex) const =0
virtual int32_t | getElementValue (int32_t i) const =0
virtual int32_t | getLimitOfLinearMatch (int32_t first, int32_t last, int32_t unitIndex) const =0
virtual int32_t | countElementUnits (int32_t start, int32_t limit, int32_t unitIndex) const =0
virtual int32_t | skipElementsBySomeUnits (int32_t i, int32_t unitIndex, int32_t count) const =0
virtual int32_t | indexOfElementWithNextUnit (int32_t i, int32_t unitIndex, UChar unit) const =0
virtual UBool | matchNodesCanHaveValues () const =0
virtual int32_t | getMaxBranchLinearSubNodeLength () const =0
virtual int32_t | getMinLinearMatch () const =0
virtual int32_t | getMaxLinearMatchLength () const =0
Node * | registerNode (Node *newNode, UErrorCode &errorCode)
| Makes sure that there is only one unique node registered that is equivalent to newNode.
Node * | registerFinalValue (int32_t value, UErrorCode &errorCode)
| Makes sure that there is only one unique FinalValueNode registered with this value.
virtual Node * | createLinearMatchNode (int32_t i, int32_t unitIndex, int32_t length, Node *nextNode) const =0
virtual int32_t | write (int32_t unit)=0
virtual int32_t | writeElementUnits (int32_t i, int32_t unitIndex, int32_t length)=0
virtual int32_t | writeValueAndFinal (int32_t i, UBool isFinal)=0
virtual int32_t | writeValueAndType (UBool hasValue, int32_t value, int32_t node)=0
virtual int32_t | writeDeltaTo (int32_t jumpTarget)=0
Protected Attributes inherited from icu::StringTrieBuilder
UHashtable * | nodes
Static Protected Attributes inherited from icu::StringTrieBuilder
static const int32_t | kMaxBranchLinearSubNodeLength = 5
static const int32_t | kMaxSplitBranchLevels = 14

## Detailed Description

Builder class for BytesTrie.

This class is not intended for public subclassing.

Stable:
  ICU 4.8

Definition at line 39 of file bytestriebuilder.h.

## Constructor & Destructor Documentation

icu::BytesTrieBuilder::BytesTrieBuilder | ( | UErrorCode & | errorCode | ) |

Constructs an empty builder.

Parameters

  errorCode | Standard ICU error code.

Stable:
  ICU 4.8

virtual icu::BytesTrieBuilder::~BytesTrieBuilder | ( |  | ) |
| virtual

Destructor.

Stable:
  ICU 4.8

## Member Function Documentation

BytesTrieBuilder& icu::BytesTrieBuilder::add | ( | const StringPiece & | s,
|  | int32_t | value,
|  | UErrorCode & | errorCode
| ) |  |

Adds a (byte sequence, value) pair.

The byte sequence must be unique. The bytes will be copied; the builder does not keep a reference to the input StringPiece or its data().

Parameters

  s | The input byte sequence.
  value | The value associated with this byte sequence.
  errorCode | Standard ICU error code. Its input value must pass the U_SUCCESS() test, or else the function returns immediately. Check for U_FAILURE() on output or use with function chaining. (See User Guide for details.)

Returns
  *this

Stable:
  ICU 4.8

BytesTrie* icu::BytesTrieBuilder::build | ( | UStringTrieBuildOption | buildOption,
|  | UErrorCode & | errorCode
| ) |  |

Builds a BytesTrie for the add()ed data.

Once built, no further data can be add()ed until clear() is called.

A BytesTrie cannot be empty. At least one (byte sequence, value) pair must have been add()ed.

This method passes ownership of the builder's internal result array to the new trie object. Another call to any build() variant will re-serialize the trie. After clear() has been called, a new array will be used as well.

Parameters

  buildOption | Build option, see UStringTrieBuildOption.
  errorCode | Standard ICU error code. Its input value must pass the U_SUCCESS() test, or else the function returns immediately. Check for U_FAILURE() on output or use with function chaining. (See User Guide for details.)

Returns
  A new BytesTrie for the add()ed data.

Stable:
  ICU 4.8

StringPiece icu::BytesTrieBuilder::buildStringPiece | ( | UStringTrieBuildOption | buildOption,
|  | UErrorCode & | errorCode
| ) |  |

Builds a BytesTrie for the add()ed data and byte-serializes it.

Once built, no further data can be add()ed until clear() is called.

A BytesTrie cannot be empty. At least one (byte sequence, value) pair must have been add()ed.

Multiple calls to buildStringPiece() return StringPieces referring to the builder's same byte array, without rebuilding. If buildStringPiece() is called after build(), the trie will be re-serialized into a new array. If build() is called after buildStringPiece(), the trie object will become the owner of the previously returned array. After clear() has been called, a new array will be used as well.

Parameters

  buildOption | Build option, see UStringTrieBuildOption.
  errorCode | Standard ICU error code. Its input value must pass the U_SUCCESS() test, or else the function returns immediately. Check for U_FAILURE() on output or use with function chaining. (See User Guide for details.)

Returns
  A StringPiece which refers to the byte-serialized BytesTrie for the add()ed data.

Stable:
  ICU 4.8

BytesTrieBuilder& icu::BytesTrieBuilder::clear | ( |  | ) |

Removes all (byte sequence, value) pairs.

New data can then be add()ed and a new trie can be built.

Returns
  *this

Stable:
  ICU 4.8

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

- bytestriebuilder.h