Loading...
Searching...
No Matches
coleitr.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
* Copyright (C) 1997-2014, International Business Machines
* Corporation and others. All Rights Reserved.
******************************************************************************
*/
#ifndef COLEITR_H
#define COLEITR_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_COLLATION
#include "unicode/unistr.h"
#include "unicode/uobject.h"
struct UCollationElements;
struct UHashtable;
U_NAMESPACE_BEGIN
struct CollationData;
class CharacterIterator;
class CollationIterator;
class RuleBasedCollator;
class UCollationPCE;
class UVector32;
class U_I18N_API CollationElementIterator final : public UObject {
public:
// CollationElementIterator public data member ------------------------------
enum {
NULLORDER = static_cast<int32_t>(0xffffffff)
};
// CollationElementIterator public constructor/destructor -------------------
CollationElementIterator(const CollationElementIterator& other);
virtual ~CollationElementIterator();
// CollationElementIterator public methods ----------------------------------
bool operator==(const CollationElementIterator& other) const;
bool operator!=(const CollationElementIterator& other) const;
void reset();
int32_t next(UErrorCode& status);
int32_t previous(UErrorCode& status);
static inline int32_t primaryOrder(int32_t order);
static inline int32_t secondaryOrder(int32_t order);
static inline int32_t tertiaryOrder(int32_t order);
int32_t getMaxExpansion(int32_t order) const;
int32_t strengthOrder(int32_t order) const;
void setText(const UnicodeString& str, UErrorCode& status);
void setText(CharacterIterator& str, UErrorCode& status);
static inline UBool isIgnorable(int32_t order);
int32_t getOffset() const;
void setOffset(int32_t newOffset, UErrorCode& status);
virtual UClassID getDynamicClassID() const override;
static UClassID U_EXPORT2 getStaticClassID();
#ifndef U_HIDE_INTERNAL_API
static inline CollationElementIterator *fromUCollationElements(UCollationElements *uc) {
return reinterpret_cast<CollationElementIterator *>(uc);
}
static inline const CollationElementIterator *fromUCollationElements(const UCollationElements *uc) {
return reinterpret_cast<const CollationElementIterator *>(uc);
}
inline UCollationElements *toUCollationElements() {
return reinterpret_cast<UCollationElements *>(this);
}
inline const UCollationElements *toUCollationElements() const {
return reinterpret_cast<const UCollationElements *>(this);
}
#endif // U_HIDE_INTERNAL_API
private:
friend class RuleBasedCollator;
friend class UCollationPCE;
CollationElementIterator(const UnicodeString& sourceText,
const RuleBasedCollator* order, UErrorCode& status);
// Note: The constructors should take settings & tailoring, not a collator,
// to avoid circular dependencies.
// However, for operator==() we would need to be able to compare tailoring data for equality
// without making CollationData or CollationTailoring depend on TailoredSet.
// (See the implementation of RuleBasedCollator::operator==().)
// That might require creating an intermediate class that would be used
// by both CollationElementIterator and RuleBasedCollator
// but only contain the part of RBC== related to data and rules.
CollationElementIterator(const CharacterIterator& sourceText,
const RuleBasedCollator* order, UErrorCode& status);
const CollationElementIterator&
operator=(const CollationElementIterator& other);
CollationElementIterator() = delete; // default constructor not implemented
inline int8_t normalizeDir() const { return dir_ == 1 ? 0 : dir_; }
static UHashtable *computeMaxExpansions(const CollationData *data, UErrorCode &errorCode);
static int32_t getMaxExpansion(const UHashtable *maxExpansions, int32_t order);
// CollationElementIterator private data members ----------------------------
CollationIterator *iter_; // owned
const RuleBasedCollator *rbc_; // aliased
uint32_t otherHalf_;
int8_t dir_;
UVector32 *offsets_;
UnicodeString string_;
};
// CollationElementIterator inline method definitions --------------------------
inline int32_t CollationElementIterator::primaryOrder(int32_t order)
{
return (order >> 16) & 0xffff;
}
inline int32_t CollationElementIterator::secondaryOrder(int32_t order)
{
return (order >> 8) & 0xff;
}
inline int32_t CollationElementIterator::tertiaryOrder(int32_t order)
{
return order & 0xff;
}
inline UBool CollationElementIterator::isIgnorable(int32_t order)
{
return (order & 0xffff0000) == 0;
}
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_COLLATION */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif
icu::CharacterIterator
Abstract class that defines an API for iteration on text objects.
Definition chariter.h:361
icu::CollationElementIterator
The CollationElementIterator class is used as an iterator to walk through each character of an inte...
Definition coleitr.h:121
icu::CollationElementIterator::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::CollationElementIterator::strengthOrder
int32_t strengthOrder(int32_t order) const
Gets the comparison order in the desired strength.
icu::CollationElementIterator::toUCollationElements
const UCollationElements * toUCollationElements() const
Definition coleitr.h:305
icu::CollationElementIterator::primaryOrder
static int32_t primaryOrder(int32_t order)
Gets the primary order of a collation order.
Definition coleitr.h:385
icu::CollationElementIterator::secondaryOrder
static int32_t secondaryOrder(int32_t order)
Gets the secondary order of a collation order.
Definition coleitr.h:390
icu::CollationElementIterator::previous
int32_t previous(UErrorCode &status)
Get the ordering priority of the previous collation element in the string.
icu::CollationElementIterator::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::CollationElementIterator::isIgnorable
static UBool isIgnorable(int32_t order)
Checks if a comparison order is ignorable.
Definition coleitr.h:400
icu::CollationElementIterator::operator==
bool operator==(const CollationElementIterator &other) const
Returns true if "other" is the same as "this".
icu::CollationElementIterator::fromUCollationElements
static CollationElementIterator * fromUCollationElements(UCollationElements *uc)
Definition coleitr.h:293
icu::CollationElementIterator::toUCollationElements
UCollationElements * toUCollationElements()
Definition coleitr.h:301
icu::CollationElementIterator::setText
void setText(CharacterIterator &str, UErrorCode &status)
Sets the source string.
icu::CollationElementIterator::operator!=
bool operator!=(const CollationElementIterator &other) const
Returns true if "other" is not the same as "this".
icu::CollationElementIterator::getOffset
int32_t getOffset() const
Gets the offset of the currently processed character in the source string.
icu::CollationElementIterator::fromUCollationElements
static const CollationElementIterator * fromUCollationElements(const UCollationElements *uc)
Definition coleitr.h:297
icu::CollationElementIterator::tertiaryOrder
static int32_t tertiaryOrder(int32_t order)
Gets the tertiary order of a collation order.
Definition coleitr.h:395
icu::CollationElementIterator::CollationElementIterator
CollationElementIterator(const CollationElementIterator &other)
Copy constructor.
icu::CollationElementIterator::setText
void setText(const UnicodeString &str, UErrorCode &status)
Sets the source string.
icu::CollationElementIterator::getMaxExpansion
int32_t getMaxExpansion(int32_t order) const
Return the maximum length of any expansion sequences that end with the specified comparison order.
icu::CollationElementIterator::next
int32_t next(UErrorCode &status)
Gets the ordering priority of the next character in the string.
icu::CollationElementIterator::NULLORDER
@ NULLORDER
NULLORDER indicates that an error has occurred while processing.
Definition coleitr.h:131
icu::CollationElementIterator::reset
void reset()
Resets the cursor to the beginning of the string.
icu::CollationElementIterator::setOffset
void setOffset(int32_t newOffset, UErrorCode &status)
Sets the offset of the currently processed character in the source string.
icu::CollationElementIterator::~CollationElementIterator
virtual ~CollationElementIterator()
Destructor.
icu::RuleBasedCollator
The RuleBasedCollator class provides the implementation of Collator, using data-driven tables.
Definition tblcoll.h:115
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition uobject.h:222
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
UHashtable
struct UHashtable UHashtable
Definition msgfmt.h:43
UCollationElements
struct UCollationElements UCollationElements
The UCollationElements struct.
Definition ucoleitr.h:39
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
unistr.h
C++ API: Unicode String.
uobject.h
C++ API: Common ICU base class UObject.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
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:316