ICU 58.2 58.2

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

- File List
- Globals

coleitr.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) 1997-2014, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
8 */
9
33 #ifndef COLEITR_H
34 #define COLEITR_H
35
36 #include "unicode/utypes.h"
37
38 #if !UCONFIG_NO_COLLATION
39
40 #include "unicode/unistr.h"
41 #include "unicode/uobject.h"
42
43 struct UCollationElements;
44 struct UHashtable;
45
46 U_NAMESPACE_BEGIN
47
48 struct CollationData;
49
50 class CollationIterator;
51 class RuleBasedCollator;
52 class UCollationPCE;
53 class UVector32;
54
118 class U_I18N_API CollationElementIterator U_FINAL : public UObject {
119 public:
120
121 // CollationElementIterator public data member ------------------------------
122
123 enum {
128 NULLORDER = (int32_t)0xffffffff
129 };
130
131 // CollationElementIterator public constructor/destructor -------------------
132
139 CollationElementIterator(const CollationElementIterator& other);
140
145 virtual ~CollationElementIterator();
146
147 // CollationElementIterator public methods ----------------------------------
148
156 UBool operator==(const CollationElementIterator& other) const;
157
165 UBool operator!=(const CollationElementIterator& other) const;
166
171 void reset(void);
172
180 int32_t next(UErrorCode& status);
181
189 int32_t previous(UErrorCode& status);
190
197 static inline int32_t primaryOrder(int32_t order);
198
205 static inline int32_t secondaryOrder(int32_t order);
206
213 static inline int32_t tertiaryOrder(int32_t order);
214
224 int32_t getMaxExpansion(int32_t order) const;
225
232 int32_t strengthOrder(int32_t order) const;
233
240 void setText(const UnicodeString& str, UErrorCode& status);
241
248 void setText(CharacterIterator& str, UErrorCode& status);
249
256 static inline UBool isIgnorable(int32_t order);
257
263 int32_t getOffset(void) const;
264
272 void setOffset(int32_t newOffset, UErrorCode& status);
273
279 virtual UClassID getDynamicClassID() const;
280
286 static UClassID U_EXPORT2 getStaticClassID();
287
288 #ifndef U_HIDE_INTERNAL_API
289
290 static inline CollationElementIterator *fromUCollationElements(UCollationElements *uc) {
291 return reinterpret_cast<CollationElementIterator *>(uc);
292 }
294 static inline const CollationElementIterator *fromUCollationElements(const UCollationElements *uc) {
295 return reinterpret_cast<const CollationElementIterator *>(uc);
296 }
298 inline UCollationElements *toUCollationElements() {
299 return reinterpret_cast<UCollationElements *>(this);
300 }
302 inline const UCollationElements *toUCollationElements() const {
303 return reinterpret_cast<const UCollationElements *>(this);
304 }
305 #endif // U_HIDE_INTERNAL_API
306
307 private:
308 friend class RuleBasedCollator;
309 friend class UCollationPCE;
310
320 CollationElementIterator(const UnicodeString& sourceText,
321 const RuleBasedCollator* order, UErrorCode& status);
322 // Note: The constructors should take settings & tailoring, not a collator,
323 // to avoid circular dependencies.
324 // However, for operator==() we would need to be able to compare tailoring data for equality
325 // without making CollationData or CollationTailoring depend on TailoredSet.
326 // (See the implementation of RuleBasedCollator::operator==().)
327 // That might require creating an intermediate class that would be used
328 // by both CollationElementIterator and RuleBasedCollator
329 // but only contain the part of RBC== related to data and rules.
330
340 CollationElementIterator(const CharacterIterator& sourceText,
341 const RuleBasedCollator* order, UErrorCode& status);
342
348 const CollationElementIterator&
349 operator=(const CollationElementIterator& other);
350
351 CollationElementIterator(); // default constructor not implemented
352
354 inline int8_t normalizeDir() const { return dir_ == 1 ? 0 : dir_; }
355
356 static UHashtable *computeMaxExpansions(const CollationData *data, UErrorCode &errorCode);
357
358 static int32_t getMaxExpansion(const UHashtable *maxExpansions, int32_t order);
359
360 // CollationElementIterator private data members ----------------------------
361
362 CollationIterator *iter_; // owned
363 const RuleBasedCollator *rbc_; // aliased
364 uint32_t otherHalf_;
369 int8_t dir_;
375 UVector32 *offsets_;
376
377 UnicodeString string_;
378 };
379
380 // CollationElementIterator inline method definitions --------------------------
381
382 inline int32_t CollationElementIterator::primaryOrder(int32_t order)
383 {
384 return (order >> 16) & 0xffff;
385 }
386
387 inline int32_t CollationElementIterator::secondaryOrder(int32_t order)
388 {
389 return (order >> 8) & 0xff;
390 }
391
392 inline int32_t CollationElementIterator::tertiaryOrder(int32_t order)
393 {
394 return order & 0xff;
395 }
396
397 inline UBool CollationElementIterator::isIgnorable(int32_t order)
398 {
399 return (order & 0xffff0000) == 0;
400 }
401
402 U_NAMESPACE_END
403
404 #endif /* #if !UCONFIG_NO_COLLATION */
405
406 #endif
icu::CollationElementIterator::fromUCollationElements
static CollationElementIterator * fromUCollationElements(UCollationElements *uc)
Definition: coleitr.h:290
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man&#39;s RTTI", returns a UClassID for the actual ICU class.
unistr.h
C++ API: Unicode String.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:93
icu::CollationElementIterator::primaryOrder
static int32_t primaryOrder(int32_t order)
Gets the primary order of a collation order.
Definition: coleitr.h:382
UCollationElements
struct UCollationElements UCollationElements
The UCollationElements struct.
Definition: ucoleitr.h:39
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:360
icu::CollationElementIterator::secondaryOrder
static int32_t secondaryOrder(int32_t order)
Gets the secondary order of a collation order.
Definition: coleitr.h:387
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::RuleBasedCollator
The RuleBasedCollator class provides the implementation of Collator, using data-driven tables...
Definition: tblcoll.h:113
icu::CollationElementIterator::fromUCollationElements
static const CollationElementIterator * fromUCollationElements(const UCollationElements *uc)
Definition: coleitr.h:294
icu::CharacterIterator
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:358
icu::CollationElementIterator::tertiaryOrder
static int32_t tertiaryOrder(int32_t order)
Gets the tertiary order of a collation order.
Definition: coleitr.h:392
icu::operator!=
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:220
icu::CollationElementIterator
The CollationElementIterator class is used as an iterator to walk through each character of an intern...
Definition: coleitr.h:118
icu::CollationElementIterator::toUCollationElements
UCollationElements * toUCollationElements()
Definition: coleitr.h:298
uobject.h
C++ API: Common ICU base class UObject.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
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.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
icu::CollationElementIterator::toUCollationElements
const UCollationElements * toUCollationElements() const
Definition: coleitr.h:302
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:259
icu::CollationElementIterator::isIgnorable
static UBool isIgnorable(int32_t order)
Checks if a comparison order is ignorable.
Definition: coleitr.h:397