ICU 60.2 60.2

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

- File List
- Globals

bytestriebuilder.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 * Copyright (C) 2010-2016, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: bytestriebuilder.h
9 * encoding: UTF-8
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 2010sep25
14 * created by: Markus W. Scherer
15 */
16
22 #ifndef __BYTESTRIEBUILDER_H__
23 #define __BYTESTRIEBUILDER_H__
24
25 #include "unicode/utypes.h"
26 #include "unicode/bytestrie.h"
27 #include "unicode/stringpiece.h"
28 #include "unicode/stringtriebuilder.h"
29
30 U_NAMESPACE_BEGIN
31
32 class BytesTrieElement;
33 class CharString;
40 class U_COMMON_API BytesTrieBuilder : public StringTrieBuilder {
41 public:
47 BytesTrieBuilder(UErrorCode &errorCode);
48
53 virtual ~BytesTrieBuilder();
54
69 BytesTrieBuilder &add(StringPiece s, int32_t value, UErrorCode &errorCode);
70
89 BytesTrie *build(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
90
113 StringPiece buildStringPiece(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
114
121 BytesTrieBuilder &clear();
122
123 private:
124 BytesTrieBuilder(const BytesTrieBuilder &other); // no copy constructor
125 BytesTrieBuilder &operator=(const BytesTrieBuilder &other); // no assignment operator
126
127 void buildBytes(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
128
129 virtual int32_t getElementStringLength(int32_t i) const;
130 virtual char16_t getElementUnit(int32_t i, int32_t byteIndex) const;
131 virtual int32_t getElementValue(int32_t i) const;
132
133 virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t byteIndex) const;
134
135 virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t byteIndex) const;
136 virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t byteIndex, int32_t count) const;
137 virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t byteIndex, char16_t byte) const;
138
139 virtual UBool matchNodesCanHaveValues() const { return FALSE; }
140
141 virtual int32_t getMaxBranchLinearSubNodeLength() const { return BytesTrie::kMaxBranchLinearSubNodeLength; }
142 virtual int32_t getMinLinearMatch() const { return BytesTrie::kMinLinearMatch; }
143 virtual int32_t getMaxLinearMatchLength() const { return BytesTrie::kMaxLinearMatchLength; }
144
148 class BTLinearMatchNode : public LinearMatchNode {
149 public:
150 BTLinearMatchNode(const char *units, int32_t len, Node *nextNode);
151 virtual UBool operator==(const Node &other) const;
152 virtual void write(StringTrieBuilder &builder);
153 private:
154 const char *s;
155 };
156
157 // don't use #ifndef U_HIDE_INTERNAL_API with private class members or virtual methods.
158 virtual Node *createLinearMatchNode(int32_t i, int32_t byteIndex, int32_t length,
159 Node *nextNode) const;
160
161 UBool ensureCapacity(int32_t length);
162 virtual int32_t write(int32_t byte);
163 int32_t write(const char *b, int32_t length);
164 virtual int32_t writeElementUnits(int32_t i, int32_t byteIndex, int32_t length);
165 virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal);
166 virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node);
167 virtual int32_t writeDeltaTo(int32_t jumpTarget);
168
169 CharString *strings; // Pointer not object so we need not #include internal charstr.h.
170 BytesTrieElement *elements;
171 int32_t elementsCapacity;
172 int32_t elementsLength;
173
174 // Byte serialization of the trie.
175 // Grows from the back: bytesLength measures from the end of the buffer!
176 char *bytes;
177 int32_t bytesCapacity;
178 int32_t bytesLength;
179 };
180
181 U_NAMESPACE_END
182
183 #endif // __BYTESTRIEBUILDER_H__
stringtriebuilder.h
C++ API: Builder API for trie builders.
icu::StringTrieBuilder::getMinLinearMatch
virtual int32_t getMinLinearMatch() const =0
icu::StringTrieBuilder
Base class for string trie builder classes.
Definition: stringtriebuilder.h:63
icu::StringTrieBuilder::getMaxLinearMatchLength
virtual int32_t getMaxLinearMatchLength() const =0
bytestrie.h
C++ API: Trie for mapping byte sequences to integer values.
icu::BytesTrieBuilder
Builder class for BytesTrie.
Definition: bytestriebuilder.h:40
icu::StringTrieBuilder::Node
Definition: stringtriebuilder.h:192
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::StringTrieBuilder::skipElementsBySomeUnits
virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const =0
icu::StringTrieBuilder::getMaxBranchLinearSubNodeLength
virtual int32_t getMaxBranchLinearSubNodeLength() const =0
icu::StringTrieBuilder::getElementStringLength
virtual int32_t getElementStringLength(int32_t i) const =0
icu::StringTrieBuilder::getElementUnit
virtual char16_t getElementUnit(int32_t i, int32_t unitIndex) const =0
icu::BytesTrie
Light-weight, non-const reader class for a BytesTrie.
Definition: bytestrie.h:50
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:131
icu::StringTrieBuilder::getElementValue
virtual int32_t getElementValue(int32_t i) const =0
icu::StringTrieBuilder::indexOfElementWithNextUnit
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, char16_t unit) const =0
icu::StringTrieBuilder::getLimitOfLinearMatch
virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t unitIndex) const =0
UStringTrieBuildOption
UStringTrieBuildOption
Build options for BytesTrieBuilder and CharsTrieBuilder.
Definition: stringtriebuilder.h:36
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
icu::StringTrieBuilder::build
void build(UStringTrieBuildOption buildOption, int32_t elementsLength, UErrorCode &errorCode)
icu::StringTrieBuilder::LinearMatchNode
Definition: stringtriebuilder.h:307
icu::StringTrieBuilder::countElementUnits
virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t unitIndex) const =0
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
FALSE
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:244
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:359
icu::StringPiece
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:54
icu::StringTrieBuilder::matchNodesCanHaveValues
virtual UBool matchNodesCanHaveValues() const =0
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236