ICU 50.2 50.2
coleitr.h
Go to the documentation of this file.
1/*
2 ******************************************************************************
3 * Copyright (C) 1997-2008, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ******************************************************************************
6 */
7
12
31
32#ifndef COLEITR_H
33#define COLEITR_H
34
35#include "unicode/utypes.h"
36
37
38#if !UCONFIG_NO_COLLATION
39
40#include "unicode/uobject.h"
41#include "unicode/tblcoll.h"
42#include "unicode/ucoleitr.h"
43
50
52
121public:
122
123 // CollationElementIterator public data member ------------------------------
124
125 enum {
130 NULLORDER = (int32_t)0xffffffff
131 };
132
133 // CollationElementIterator public constructor/destructor -------------------
134
142
148
149 // CollationElementIterator public methods ----------------------------------
150
159
168
173 void reset(void);
174
182 int32_t next(UErrorCode& status);
183
191 int32_t previous(UErrorCode& status);
192
199 static inline int32_t primaryOrder(int32_t order);
200
207 static inline int32_t secondaryOrder(int32_t order);
208
215 static inline int32_t tertiaryOrder(int32_t order);
216
226 int32_t getMaxExpansion(int32_t order) const;
227
234 int32_t strengthOrder(int32_t order) const;
235
242 void setText(const UnicodeString& str, UErrorCode& status);
243
251
258 static inline UBool isIgnorable(int32_t order);
259
265 int32_t getOffset(void) const;
266
274 void setOffset(int32_t newOffset, UErrorCode& status);
275
282
288 static UClassID U_EXPORT2 getStaticClassID();
289
290protected:
291
292 // CollationElementIterator protected constructors --------------------------
296 friend class RuleBasedCollator;
297
309 const RuleBasedCollator* order, UErrorCode& status);
310
322 const RuleBasedCollator* order, UErrorCode& status);
323
324 // CollationElementIterator protected methods -------------------------------
325
334
335private:
336 CollationElementIterator(); // default constructor not implemented
337
338 // CollationElementIterator private data members ----------------------------
339
343 UCollationElements *m_data_;
344
348 UBool isDataOwned_;
349
350};
351
352// CollationElementIterator inline method defination --------------------------
353
359inline int32_t CollationElementIterator::primaryOrder(int32_t order)
360{
361 order &= RuleBasedCollator::PRIMARYORDERMASK;
362 return (order >> RuleBasedCollator::PRIMARYORDERSHIFT);
363}
364
370inline int32_t CollationElementIterator::secondaryOrder(int32_t order)
371{
372 order = order & RuleBasedCollator::SECONDARYORDERMASK;
373 return (order >> RuleBasedCollator::SECONDARYORDERSHIFT);
374}
375
381inline int32_t CollationElementIterator::tertiaryOrder(int32_t order)
382{
383 return (order &= RuleBasedCollator::TERTIARYORDERMASK);
384}
385
386inline int32_t CollationElementIterator::getMaxExpansion(int32_t order) const
387{
388 return ucol_getMaxExpansion(m_data_, (uint32_t)order);
389}
390
392{
393 return (primaryOrder(order) == RuleBasedCollator::PRIMIGNORABLE);
394}
395
397
398#endif /* #if !UCONFIG_NO_COLLATION */
399
400#endif
Abstract class that defines an API for iteration on text objects.
Definition chariter.h:356
int32_t previous(UErrorCode &status)
Get the ordering priority of the previous collation element in the string.
virtual ~CollationElementIterator()
Destructor.
friend class RuleBasedCollator
Definition coleitr.h:296
CollationElementIterator(const UnicodeString &sourceText, const RuleBasedCollator *order, UErrorCode &status)
CollationElementIterator constructor.
int32_t next(UErrorCode &status)
Gets the ordering priority of the next character in the string.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
@ NULLORDER
NULLORDER indicates that an error has occured while processing.
Definition coleitr.h:130
int32_t getOffset(void) const
Gets the offset of the currently processed character in the source string.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
void reset(void)
Resets the cursor to the beginning of the string.
void setOffset(int32_t newOffset, UErrorCode &status)
Sets the offset of the currently processed character in the source string.
UBool operator!=(const CollationElementIterator &other) const
Returns true if "other" is not the same as "this".
static UBool isIgnorable(int32_t order)
Checks if a comparison order is ignorable.
Definition coleitr.h:391
int32_t strengthOrder(int32_t order) const
Gets the comparison order in the desired strength.
CollationElementIterator(const CharacterIterator &sourceText, const RuleBasedCollator *order, UErrorCode &status)
CollationElementIterator constructor.
CollationElementIterator(const CollationElementIterator &other)
Copy constructor.
static int32_t tertiaryOrder(int32_t order)
Gets the tertiary order of a collation order.
Definition coleitr.h:381
static int32_t primaryOrder(int32_t order)
Gets the primary order of a collation order.
Definition coleitr.h:359
void setText(CharacterIterator &str, UErrorCode &status)
Sets the source string.
UBool operator==(const CollationElementIterator &other) const
Returns true if "other" is the same as "this".
int32_t getMaxExpansion(int32_t order) const
Return the maximum length of any expansion sequences that end with the specified comparison order.
Definition coleitr.h:386
static int32_t secondaryOrder(int32_t order)
Gets the secondary order of a collation order.
Definition coleitr.h:370
void setText(const UnicodeString &str, UErrorCode &status)
Sets the source string.
const CollationElementIterator & operator=(const CollationElementIterator &other)
Assignment operator.
UObject is the common ICU "boilerplate" class.
Definition uobject.h:229
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:247
struct UCollationElements UCollationElements
File coleitr.h.
Definition coleitr.h:49
C++ API: RuleBasedCollator class provides the simple implementation of Collator.
C API: UCollationElements.
int32_t ucol_getMaxExpansion(const UCollationElements *elems, int32_t order)
Get the maximum length of any expansion sequences that end with the specified comparison order.
int8_t UBool
The ICU boolean type.
Definition umachine.h:200
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
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:476
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:358
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129