ICU 56.1: coleitr.h Source File

ICU 56.1 56.1

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

- File List
- Globals

coleitr.h
Go to the documentation of this file.
1 /*
2 ******************************************************************************
3 * Copyright (C) 1997-2014, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ******************************************************************************
6 */
7
31 #ifndef COLEITR_H
32 #define COLEITR_H
33
34 #include "unicode/utypes.h"
35
36 #if !UCONFIG_NO_COLLATION
37
38 #include "unicode/unistr.h"
39 #include "unicode/uobject.h"
40
41 struct UCollationElements;
42 struct UHashtable;
43
44 U_NAMESPACE_BEGIN
45
46 struct CollationData;
47
48 class CollationIterator;
49 class RuleBasedCollator;
50 class UCollationPCE;
51 class UVector32;
52
116 class U_I18N_API CollationElementIterator U_FINAL : public UObject {
117 public:
118
119 // CollationElementIterator public data member ------------------------------
120
121 enum {
126 NULLORDER = (int32_t)0xffffffff
127 };
128
129 // CollationElementIterator public constructor/destructor -------------------
130
137 CollationElementIterator(const CollationElementIterator& other);
138
143 virtual ~CollationElementIterator();
144
145 // CollationElementIterator public methods ----------------------------------
146
154 UBool operator==(const CollationElementIterator& other) const;
155
163 UBool operator!=(const CollationElementIterator& other) const;
164
169 void reset(void);
170
178 int32_t next(UErrorCode& status);
179
187 int32_t previous(UErrorCode& status);
188
195 static inline int32_t primaryOrder(int32_t order);
196
203 static inline int32_t secondaryOrder(int32_t order);
204
211 static inline int32_t tertiaryOrder(int32_t order);
212
222 int32_t getMaxExpansion(int32_t order) const;
223
230 int32_t strengthOrder(int32_t order) const;
231
238 void setText(const UnicodeString& str, UErrorCode& status);
239
246 void setText(CharacterIterator& str, UErrorCode& status);
247
254 static inline UBool isIgnorable(int32_t order);
255
261 int32_t getOffset(void) const;
262
270 void setOffset(int32_t newOffset, UErrorCode& status);
271
277 virtual UClassID getDynamicClassID() const;
278
284 static UClassID U_EXPORT2 getStaticClassID();
285
286 #ifndef U_HIDE_INTERNAL_API
287
288 static inline CollationElementIterator *fromUCollationElements(UCollationElements *uc) {
289 return reinterpret_cast<CollationElementIterator *>(uc);
290 }
292 static inline const CollationElementIterator *fromUCollationElements(const UCollationElements *uc) {
293 return reinterpret_cast<const CollationElementIterator *>(uc);
294 }
296 inline UCollationElements *toUCollationElements() {
297 return reinterpret_cast<UCollationElements *>(this);
298 }
300 inline const UCollationElements *toUCollationElements() const {
301 return reinterpret_cast<const UCollationElements *>(this);
302 }
303 #endif // U_HIDE_INTERNAL_API
304
305 private:
306 friend class RuleBasedCollator;
307 friend class UCollationPCE;
308
318 CollationElementIterator(const UnicodeString& sourceText,
319 const RuleBasedCollator* order, UErrorCode& status);
320 // Note: The constructors should take settings & tailoring, not a collator,
321 // to avoid circular dependencies.
322 // However, for operator==() we would need to be able to compare tailoring data for equality
323 // without making CollationData or CollationTailoring depend on TailoredSet.
324 // (See the implementation of RuleBasedCollator::operator==().)
325 // That might require creating an intermediate class that would be used
326 // by both CollationElementIterator and RuleBasedCollator
327 // but only contain the part of RBC== related to data and rules.
328
338 CollationElementIterator(const CharacterIterator& sourceText,
339 const RuleBasedCollator* order, UErrorCode& status);
340
346 const CollationElementIterator&
347 operator=(const CollationElementIterator& other);
348
349 CollationElementIterator(); // default constructor not implemented
350
352 inline int8_t normalizeDir() const { return dir_ == 1 ? 0 : dir_; }
353
354 static UHashtable *computeMaxExpansions(const CollationData *data, UErrorCode &errorCode);
355
356 static int32_t getMaxExpansion(const UHashtable *maxExpansions, int32_t order);
357
358 // CollationElementIterator private data members ----------------------------
359
360 CollationIterator *iter_; // owned
361 const RuleBasedCollator *rbc_; // aliased
362 uint32_t otherHalf_;
367 int8_t dir_;
373 UVector32 *offsets_;
374
375 UnicodeString string_;
376 };
377
378 // CollationElementIterator inline method definitions --------------------------
379
380 inline int32_t CollationElementIterator::primaryOrder(int32_t order)
381 {
382 return (order >> 16) & 0xffff;
383 }
384
385 inline int32_t CollationElementIterator::secondaryOrder(int32_t order)
386 {
387 return (order >> 8) & 0xff;
388 }
389
390 inline int32_t CollationElementIterator::tertiaryOrder(int32_t order)
391 {
392 return order & 0xff;
393 }
394
395 inline UBool CollationElementIterator::isIgnorable(int32_t order)
396 {
397 return (order & 0xffff0000) == 0;
398 }
399
400 U_NAMESPACE_END
401
402 #endif /* #if !UCONFIG_NO_COLLATION */
403
404 #endif
icu::CollationElementIterator::fromUCollationElements
static CollationElementIterator * fromUCollationElements(UCollationElements *uc)
Definition: coleitr.h:288
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man'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's RTTI.
Definition: uobject.h:91
icu::CollationElementIterator::primaryOrder
static int32_t primaryOrder(int32_t order)
Gets the primary order of a collation order.
Definition: coleitr.h:380
UCollationElements
struct UCollationElements UCollationElements
The UCollationElements struct.
Definition: ucoleitr.h:37
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:358
icu::CollationElementIterator::secondaryOrder
static int32_t secondaryOrder(int32_t order)
Gets the secondary order of a collation order.
Definition: coleitr.h:385
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::RuleBasedCollator
The RuleBasedCollator class provides the implementation of Collator, using data-driven tables...
Definition: tblcoll.h:111
icu::CollationElementIterator::fromUCollationElements
static const CollationElementIterator * fromUCollationElements(const UCollationElements *uc)
Definition: coleitr.h:292
icu::CharacterIterator
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:356
icu::CollationElementIterator::tertiaryOrder
static int32_t tertiaryOrder(int32_t order)
Gets the tertiary order of a collation order.
Definition: coleitr.h:390
icu::operator!=
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
icu::CollationElementIterator
The CollationElementIterator class is used as an iterator to walk through each character of an intern...
Definition: coleitr.h:116
icu::CollationElementIterator::toUCollationElements
UCollationElements * toUCollationElements()
Definition: coleitr.h:296
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:130
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
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:293
icu::CollationElementIterator::toUCollationElements
const UCollationElements * toUCollationElements() const
Definition: coleitr.h:300
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
icu::CollationElementIterator::isIgnorable
static UBool isIgnorable(int32_t order)
Checks if a comparison order is ignorable.
Definition: coleitr.h:395