ICU 58.2 58.2

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

- File List
- Globals

ucharstriebuilder.h
Go to the documentation of this file.
1 // Copyright (C) 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: ucharstriebuilder.h
9 * encoding: US-ASCII
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 2010nov14
14 * created by: Markus W. Scherer
15 */
16
17 #ifndef __UCHARSTRIEBUILDER_H__
18 #define __UCHARSTRIEBUILDER_H__
19
20 #include "unicode/utypes.h"
21 #include "unicode/stringtriebuilder.h"
22 #include "unicode/ucharstrie.h"
23 #include "unicode/unistr.h"
24
30 U_NAMESPACE_BEGIN
31
32 class UCharsTrieElement;
33
40 class U_COMMON_API UCharsTrieBuilder : public StringTrieBuilder {
41 public:
47 UCharsTrieBuilder(UErrorCode &errorCode);
48
53 virtual ~UCharsTrieBuilder();
54
69 UCharsTrieBuilder &add(const UnicodeString &s, int32_t value, UErrorCode &errorCode);
70
89 UCharsTrie *build(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
90
115 UnicodeString &buildUnicodeString(UStringTrieBuildOption buildOption, UnicodeString &result,
116 UErrorCode &errorCode);
117
124 UCharsTrieBuilder &clear() {
125 strings.remove();
126 elementsLength=0;
127 ucharsLength=0;
128 return *this;
129 }
130
131 private:
132 UCharsTrieBuilder(const UCharsTrieBuilder &other); // no copy constructor
133 UCharsTrieBuilder &operator=(const UCharsTrieBuilder &other); // no assignment operator
134
135 void buildUChars(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
136
137 virtual int32_t getElementStringLength(int32_t i) const;
138 virtual UChar getElementUnit(int32_t i, int32_t unitIndex) const;
139 virtual int32_t getElementValue(int32_t i) const;
140
141 virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t unitIndex) const;
142
143 virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t unitIndex) const;
144 virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const;
145 virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, UChar unit) const;
146
147 virtual UBool matchNodesCanHaveValues() const { return TRUE; }
148
149 virtual int32_t getMaxBranchLinearSubNodeLength() const { return UCharsTrie::kMaxBranchLinearSubNodeLength; }
150 virtual int32_t getMinLinearMatch() const { return UCharsTrie::kMinLinearMatch; }
151 virtual int32_t getMaxLinearMatchLength() const { return UCharsTrie::kMaxLinearMatchLength; }
152
153 class UCTLinearMatchNode : public LinearMatchNode {
154 public:
155 UCTLinearMatchNode(const UChar *units, int32_t len, Node *nextNode);
156 virtual UBool operator==(const Node &other) const;
157 virtual void write(StringTrieBuilder &builder);
158 private:
159 const UChar *s;
160 };
161
162 virtual Node *createLinearMatchNode(int32_t i, int32_t unitIndex, int32_t length,
163 Node *nextNode) const;
164
165 UBool ensureCapacity(int32_t length);
166 virtual int32_t write(int32_t unit);
167 int32_t write(const UChar *s, int32_t length);
168 virtual int32_t writeElementUnits(int32_t i, int32_t unitIndex, int32_t length);
169 virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal);
170 virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node);
171 virtual int32_t writeDeltaTo(int32_t jumpTarget);
172
173 UnicodeString strings;
174 UCharsTrieElement *elements;
175 int32_t elementsCapacity;
176 int32_t elementsLength;
177
178 // UChar serialization of the trie.
179 // Grows from the back: ucharsLength measures from the end of the buffer!
180 UChar *uchars;
181 int32_t ucharsCapacity;
182 int32_t ucharsLength;
183 };
184
185 U_NAMESPACE_END
186
187 #endif // __UCHARSTRIEBUILDER_H__
stringtriebuilder.h
C++ API: Builder API for trie builders.
icu::StringTrieBuilder::getMinLinearMatch
virtual int32_t getMinLinearMatch() const =0
icu::StringTrieBuilder::indexOfElementWithNextUnit
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, UChar unit) const =0
icu::StringTrieBuilder
Base class for string trie builder classes.
Definition: stringtriebuilder.h:63
icu::StringTrieBuilder::getMaxLinearMatchLength
virtual int32_t getMaxLinearMatchLength() const =0
icu::UCharsTrieBuilder::clear
UCharsTrieBuilder & clear()
Removes all (string, value) pairs.
Definition: ucharstriebuilder.h:124
icu::StringTrieBuilder::Node
Definition: stringtriebuilder.h:192
unistr.h
C++ API: Unicode String.
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 UChar getElementUnit(int32_t i, int32_t unitIndex) const =0
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::UCharsTrieBuilder
Builder class for UCharsTrie.
Definition: ucharstriebuilder.h:40
TRUE
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:263
icu::StringTrieBuilder::getLimitOfLinearMatch
virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, 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:337
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
ucharstrie.h
C++ API: Trie for mapping Unicode strings (or 16-bit-unit sequences) to integer values.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
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::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
icu::UCharsTrie
Light-weight, non-const reader class for a UCharsTrie.
Definition: ucharstrie.h:50
icu::StringTrieBuilder::matchNodesCanHaveValues
virtual UBool matchNodesCanHaveValues() const =0
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:259