ICU 62.1 62.1
coleitr.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) 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
44struct UHashtable;
45
47
48struct CollationData;
49
50class CharacterIterator;
51class CollationIterator;
52class RuleBasedCollator;
53class UCollationPCE;
54class UVector32;
55
120public:
121
122 // CollationElementIterator public data member ------------------------------
123
124 enum {
129 NULLORDER = (int32_t)0xffffffff
130 };
131
132 // CollationElementIterator public constructor/destructor -------------------
133
141
147
148 // CollationElementIterator public methods ----------------------------------
149
158
167
172 void reset(void);
173
182
191
198 static inline int32_t primaryOrder(int32_t order);
199
206 static inline int32_t secondaryOrder(int32_t order);
207
214 static inline int32_t tertiaryOrder(int32_t order);
215
225 int32_t getMaxExpansion(int32_t order) const;
226
233 int32_t strengthOrder(int32_t order) const;
234
242
250
257 static inline UBool isIgnorable(int32_t order);
258
264 int32_t getOffset(void) const;
265
274
281
288
289#ifndef U_HIDE_INTERNAL_API
292 return reinterpret_cast<CollationElementIterator *>(uc);
293 }
296 return reinterpret_cast<const CollationElementIterator *>(uc);
297 }
300 return reinterpret_cast<UCollationElements *>(this);
301 }
304 return reinterpret_cast<const UCollationElements *>(this);
305 }
306#endif // U_HIDE_INTERNAL_API
307
308private:
309 friend class RuleBasedCollator;
310 friend class UCollationPCE;
311
323 // Note: The constructors should take settings & tailoring, not a collator,
324 // to avoid circular dependencies.
325 // However, for operator==() we would need to be able to compare tailoring data for equality
326 // without making CollationData or CollationTailoring depend on TailoredSet.
327 // (See the implementation of RuleBasedCollator::operator==().)
328 // That might require creating an intermediate class that would be used
329 // by both CollationElementIterator and RuleBasedCollator
330 // but only contain the part of RBC== related to data and rules.
331
343
350 operator=(const CollationElementIterator& other);
351
352 CollationElementIterator(); // default constructor not implemented
353
355 inline int8_t normalizeDir() const { return dir_ == 1 ? 0 : dir_; }
356
357 static UHashtable *computeMaxExpansions(const CollationData *data, UErrorCode &errorCode);
358
359 static int32_t getMaxExpansion(const UHashtable *maxExpansions, int32_t order);
360
361 // CollationElementIterator private data members ----------------------------
362
363 CollationIterator *iter_; // owned
364 const RuleBasedCollator *rbc_; // aliased
365 uint32_t otherHalf_;
370 int8_t dir_;
376 UVector32 *offsets_;
377
378 UnicodeString string_;
379};
380
381// CollationElementIterator inline method definitions --------------------------
382
383inline int32_t CollationElementIterator::primaryOrder(int32_t order)
384{
385 return (order >> 16) & 0xffff;
386}
387
388inline int32_t CollationElementIterator::secondaryOrder(int32_t order)
389{
390 return (order >> 8) & 0xff;
391}
392
393inline int32_t CollationElementIterator::tertiaryOrder(int32_t order)
394{
395 return order & 0xff;
396}
397
398inline UBool CollationElementIterator::isIgnorable(int32_t order)
399{
400 return (order & 0xffff0000) == 0;
401}
402
404
405#endif /* #if !UCONFIG_NO_COLLATION */
406
407#endif
Abstract class that defines an API for iteration on text objects.
Definition chariter.h:358
The CollationElementIterator class is used as an iterator to walk through each character of an inte...
Definition coleitr.h:119
UBool operator!=(const CollationElementIterator &other) const
Returns true if "other" is not the same as "this".
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
int32_t strengthOrder(int32_t order) const
Gets the comparison order in the desired strength.
const UCollationElements * toUCollationElements() const
Definition coleitr.h:303
void reset(void)
Resets the cursor to the beginning of the string.
int32_t previous(UErrorCode &status)
Get the ordering priority of the previous collation element in the string.
UBool operator==(const CollationElementIterator &other) const
Returns true if "other" is the same as "this".
static CollationElementIterator * fromUCollationElements(UCollationElements *uc)
Definition coleitr.h:291
UCollationElements * toUCollationElements()
Definition coleitr.h:299
void setText(CharacterIterator &str, UErrorCode &status)
Sets the source string.
static const CollationElementIterator * fromUCollationElements(const UCollationElements *uc)
Definition coleitr.h:295
CollationElementIterator(const CollationElementIterator &other)
Copy constructor.
void setText(const UnicodeString &str, UErrorCode &status)
Sets the source string.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
int32_t getMaxExpansion(int32_t order) const
Return the maximum length of any expansion sequences that end with the specified comparison order.
int32_t next(UErrorCode &status)
Gets the ordering priority of the next character in the string.
int32_t getOffset(void) const
Gets the offset of the currently processed character in the source string.
void setOffset(int32_t newOffset, UErrorCode &status)
Sets the offset of the currently processed character in the source string.
virtual ~CollationElementIterator()
Destructor.
"Smart pointer" base class; do not use directly: use LocalPointer etc.
The RuleBasedCollator class provides the implementation of Collator, using data-driven tables.
Definition tblcoll.h:113
UObject is the common ICU "boilerplate" class.
Definition uobject.h:223
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:287
struct UCollationElements UCollationElements
The UCollationElements struct.
Definition ucoleitr.h:39
int8_t UBool
The ICU boolean type.
Definition umachine.h:236
C++ API: Unicode String.
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:93
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:396
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:360
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:138
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:137