ICU 56.1: ucharstriebuilder.h Source File

ICU 56.1 56.1

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

- File List
- Globals

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