ICU 56.1: bytestriebuilder.h Source File

ICU 56.1 56.1

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

- File List
- Globals

bytestriebuilder.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 * Copyright (C) 2010-2014, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 *******************************************************************************
6 * file name: bytestriebuilder.h
7 * encoding: US-ASCII
8 * tab size: 8 (not used)
9 * indentation:4
10 *
11 * created on: 2010sep25
12 * created by: Markus W. Scherer
13 */
14
20 #ifndef __BYTESTRIEBUILDER_H__
21 #define __BYTESTRIEBUILDER_H__
22
23 #include "unicode/utypes.h"
24 #include "unicode/bytestrie.h"
25 #include "unicode/stringpiece.h"
26 #include "unicode/stringtriebuilder.h"
27
28 U_NAMESPACE_BEGIN
29
30 class BytesTrieElement;
31 class CharString;
32
39 class U_COMMON_API BytesTrieBuilder : public StringTrieBuilder {
40 public:
46 BytesTrieBuilder(UErrorCode &errorCode);
47
52 virtual ~BytesTrieBuilder();
53
68 BytesTrieBuilder &add(const StringPiece &s, int32_t value, UErrorCode &errorCode);
69
88 BytesTrie *build(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
89
112 StringPiece buildStringPiece(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
113
120 BytesTrieBuilder &clear();
121
122 private:
123 BytesTrieBuilder(const BytesTrieBuilder &other); // no copy constructor
124 BytesTrieBuilder &operator=(const BytesTrieBuilder &other); // no assignment operator
125
126 void buildBytes(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
127
128 virtual int32_t getElementStringLength(int32_t i) const;
129 virtual UChar getElementUnit(int32_t i, int32_t byteIndex) const;
130 virtual int32_t getElementValue(int32_t i) const;
131
132 virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t byteIndex) const;
133
134 virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t byteIndex) const;
135 virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t byteIndex, int32_t count) const;
136 virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t byteIndex, UChar byte) const;
137
138 virtual UBool matchNodesCanHaveValues() const { return FALSE; }
139
140 virtual int32_t getMaxBranchLinearSubNodeLength() const { return BytesTrie::kMaxBranchLinearSubNodeLength; }
141 virtual int32_t getMinLinearMatch() const { return BytesTrie::kMinLinearMatch; }
142 virtual int32_t getMaxLinearMatchLength() const { return BytesTrie::kMaxLinearMatchLength; }
143
147 class BTLinearMatchNode : public LinearMatchNode {
148 public:
149 BTLinearMatchNode(const char *units, int32_t len, Node *nextNode);
150 virtual UBool operator==(const Node &other) const;
151 virtual void write(StringTrieBuilder &builder);
152 private:
153 const char *s;
154 };
155
156 virtual Node *createLinearMatchNode(int32_t i, int32_t byteIndex, int32_t length,
157 Node *nextNode) const;
158
159 UBool ensureCapacity(int32_t length);
160 virtual int32_t write(int32_t byte);
161 int32_t write(const char *b, int32_t length);
162 virtual int32_t writeElementUnits(int32_t i, int32_t byteIndex, int32_t length);
163 virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal);
164 virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node);
165 virtual int32_t writeDeltaTo(int32_t jumpTarget);
166
167 CharString *strings; // Pointer not object so we need not #include internal charstr.h.
168 BytesTrieElement *elements;
169 int32_t elementsCapacity;
170 int32_t elementsLength;
171
172 // Byte serialization of the trie.
173 // Grows from the back: bytesLength measures from the end of the buffer!
174 char *bytes;
175 int32_t bytesCapacity;
176 int32_t bytesLength;
177 };
178
179 U_NAMESPACE_END
180
181 #endif // __BYTESTRIEBUILDER_H__
stringtriebuilder.h
C++ API: Builder API for trie builders.
icu::StringTrieBuilder
Base class for string trie builder classes.
Definition: stringtriebuilder.h:61
bytestrie.h
C++ API: Trie for mapping byte sequences to integer values.
icu::BytesTrieBuilder
Builder class for BytesTrie.
Definition: bytestriebuilder.h:39
icu::StringTrieBuilder::Node
Definition: stringtriebuilder.h:189
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::StringTrieBuilder::getMaxBranchLinearSubNodeLength
virtual int32_t getMaxBranchLinearSubNodeLength() const =0
icu::StringTrieBuilder::writeValueAndType
virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node)=0
icu::StringTrieBuilder::getLimitOfLinearMatch
virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t unitIndex) const =0
icu::StringTrieBuilder::writeElementUnits
virtual int32_t writeElementUnits(int32_t i, int32_t unitIndex, int32_t length)=0
icu::BytesTrie
Light-weight, non-const reader class for a BytesTrie.
Definition: bytestrie.h:48
icu::StringTrieBuilder::getMinLinearMatch
virtual int32_t getMinLinearMatch() const =0
icu::StringTrieBuilder::skipElementsBySomeUnits
virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const =0
stringpiece.h
C++ API: StringPiece: Read-only byte string wrapper class.
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
icu::StringTrieBuilder::writeDeltaTo
virtual int32_t writeDeltaTo(int32_t jumpTarget)=0
icu::StringTrieBuilder::countElementUnits
virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t unitIndex) const =0
icu::StringTrieBuilder::getElementValue
virtual int32_t getElementValue(int32_t i) const =0
icu::StringTrieBuilder::getElementStringLength
virtual int32_t getElementStringLength(int32_t i) const =0
icu::StringTrieBuilder::getElementUnit
virtual UChar getElementUnit(int32_t i, int32_t unitIndex) const =0
UChar
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:312
UStringTrieBuildOption
UStringTrieBuildOption
Build options for BytesTrieBuilder and CharsTrieBuilder.
Definition: stringtriebuilder.h:34
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
icu::StringTrieBuilder::indexOfElementWithNextUnit
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, UChar unit) const =0
icu::StringTrieBuilder::build
void build(UStringTrieBuildOption buildOption, int32_t elementsLength, UErrorCode &errorCode)
icu::StringTrieBuilder::writeValueAndFinal
virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal)=0
icu::StringTrieBuilder::LinearMatchNode
Definition: stringtriebuilder.h:296
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
icu::StringTrieBuilder::getMaxLinearMatchLength
virtual int32_t getMaxLinearMatchLength() const =0
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
FALSE
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:242
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:357
icu::StringTrieBuilder::createLinearMatchNode
virtual Node * createLinearMatchNode(int32_t i, int32_t unitIndex, int32_t length, Node *nextNode) const =0
icu::StringTrieBuilder::matchNodesCanHaveValues
virtual UBool matchNodesCanHaveValues() const =0
icu::StringPiece
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:52
icu::StringTrieBuilder::write
virtual int32_t write(int32_t unit)=0
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234