22#ifndef __BYTESTRIEBUILDER_H__
23#define __BYTESTRIEBUILDER_H__
27#if U_SHOW_CPLUSPLUS_API
37class BytesTrieElement;
131 friend class ::BytesTrieTest;
138 virtual int32_t getElementStringLength(int32_t i) const override;
139 virtual
char16_t getElementUnit(int32_t i, int32_t byteIndex) const override;
140 virtual int32_t getElementValue(int32_t i) const override;
142 virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t byteIndex) const override;
144 virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t byteIndex) const override;
145 virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t byteIndex, int32_t count) const override;
146 virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t byteIndex,
char16_t byte) const override;
148 virtual
UBool matchNodesCanHaveValues()
const override {
return false; }
151 virtual int32_t
getMinLinearMatch()
const override {
return BytesTrie::kMinLinearMatch; }
154 class BTLinearMatchNode :
public LinearMatchNode {
156 BTLinearMatchNode(
const char *units, int32_t len, Node *nextNode);
157 virtual bool operator==(
const Node &other)
const override;
158 virtual void write(StringTrieBuilder &builder)
override;
164 Node *nextNode)
const override;
166 UBool ensureCapacity(int32_t length);
167 virtual int32_t
write(int32_t
byte)
override;
168 int32_t
write(
const char *b, int32_t length);
169 virtual int32_t
writeElementUnits(int32_t i, int32_t byteIndex, int32_t length)
override;
172 virtual int32_t
writeDeltaTo(int32_t jumpTarget)
override;
173 static int32_t internalEncodeDelta(int32_t i,
char intBytes[]);
176 BytesTrieElement *elements;
177 int32_t elementsCapacity;
178 int32_t elementsLength;
183 int32_t bytesCapacity;
C++ API: Trie for mapping byte sequences to integer values.
Builder class for BytesTrie.
BytesTrieBuilder & add(StringPiece s, int32_t value, UErrorCode &errorCode)
Adds a (byte sequence, value) pair.
StringPiece buildStringPiece(UStringTrieBuildOption buildOption, UErrorCode &errorCode)
Builds a BytesTrie for the add()ed data and byte-serializes it.
BytesTrie * build(UStringTrieBuildOption buildOption, UErrorCode &errorCode)
Builds a BytesTrie for the add()ed data.
BytesTrieBuilder(UErrorCode &errorCode)
Constructs an empty builder.
virtual ~BytesTrieBuilder()
Destructor.
BytesTrieBuilder & clear()
Removes all (byte sequence, value) pairs.
Light-weight, non-const reader class for a BytesTrie.
A string-like object that points to a sized piece of memory.
Base class for string trie builder classes.
virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal)=0
virtual int32_t getMaxBranchLinearSubNodeLength() const =0
virtual int32_t writeDeltaTo(int32_t jumpTarget)=0
virtual int32_t getMinLinearMatch() const =0
virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node)=0
virtual int32_t write(int32_t unit)=0
virtual Node * createLinearMatchNode(int32_t i, int32_t unitIndex, int32_t length, Node *nextNode) const =0
virtual int32_t getMaxLinearMatchLength() const =0
virtual int32_t writeElementUnits(int32_t i, int32_t unitIndex, int32_t length)=0
U_COMMON_API UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
C++ API: StringPiece: Read-only byte string wrapper class.
C++ API: Builder API for trie builders.
UStringTrieBuildOption
Build options for BytesTrieBuilder and CharsTrieBuilder.
int8_t UBool
The ICU boolean type, a signed-byte integer.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.