ICU 66.0.1
66.0.1
|
Builder class for BytesTrie. More...
#include <bytestriebuilder.h>
Public Member Functions | |
BytesTrieBuilder (UErrorCode &errorCode) | |
Constructs an empty builder. More... | |
virtual | ~BytesTrieBuilder () |
Destructor. More... | |
BytesTrieBuilder & | add (StringPiece s, int32_t value, UErrorCode &errorCode) |
Adds a (byte sequence, value) pair. More... | |
BytesTrie * | build (UStringTrieBuildOption buildOption, UErrorCode &errorCode) |
Builds a BytesTrie for the add()ed data. More... | |
StringPiece | buildStringPiece (UStringTrieBuildOption buildOption, UErrorCode &errorCode) |
Builds a BytesTrie for the add()ed data and byte-serializes it. More... | |
BytesTrieBuilder & | clear () |
Removes all (byte sequence, value) pairs. More... | |
Builder class for BytesTrie.
This class is not intended for public subclassing.
Definition at line 43 of file bytestriebuilder.h.
icu::BytesTrieBuilder::BytesTrieBuilder | ( | UErrorCode & | errorCode | ) |
|
virtual |
Destructor.
BytesTrieBuilder& icu::BytesTrieBuilder::add | ( | 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().
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.) |
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.
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.) |
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.
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.) |
BytesTrieBuilder& icu::BytesTrieBuilder::clear | ( | ) |