ICU 4.8.1.1  4.8.1.1
Data Structures | Public Member Functions
BytesTrieBuilder Class Reference

Builder class for BytesTrie. More...

#include <bytestriebuilder.h>

Inheritance diagram for BytesTrieBuilder:
StringTrieBuilder UObject UMemory

Data Structures

class  BTLinearMatchNode

Public Member Functions

 BytesTrieBuilder (UErrorCode &errorCode)
 Constructs an empty builder.
virtual ~BytesTrieBuilder ()
 Destructor.
BytesTrieBuilderadd (const StringPiece &s, int32_t value, UErrorCode &errorCode)
 Adds a (byte sequence, value) pair.
BytesTriebuild (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.
BytesTrieBuilderclear ()
 Removes all (byte sequence, value) pairs.

Detailed Description

Builder class for BytesTrie.

This class is not intended for public subclassing.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 34 of file bytestriebuilder.h.


Constructor & Destructor Documentation

Constructs an empty builder.

Parameters:
errorCodeStandard ICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
virtual BytesTrieBuilder::~BytesTrieBuilder ( ) [virtual]

Destructor.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Member Function Documentation

BytesTrieBuilder& 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:
sThe input byte sequence.
valueThe value associated with this byte sequence.
errorCodeStandard 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
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
BytesTrie* 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.

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:
buildOptionBuild option, see UStringTrieBuildOption.
errorCodeStandard 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.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
StringPiece 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.

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:
buildOptionBuild option, see UStringTrieBuildOption.
errorCodeStandard 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.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Removes all (byte sequence, value) pairs.

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

Returns:
*this
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines