ICU 55.1 55.1

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

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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