Go to the documentation of this file.
65 #if !UCONFIG_NO_COLLATION
74 struct CollationCacheEntry;
76 struct CollationSettings;
77 struct CollationTailoring;
85 class CollationElementIterator;
87 class SortKeyByteSink;
164 #ifndef U_HIDE_INTERNAL_API
310 const UChar* target, int32_t targetLength,
379 int32_t sourceLength,
416 #ifndef U_HIDE_DEPRECATED_API
461 #ifndef U_HIDE_DEPRECATED_API
629 int32_t resultLength)
const;
648 uint8_t *result, int32_t resultLength)
const;
664 int32_t destCapacity,
679 int32_t reorderCodesLength,
687 const char *left, int32_t leftLength,
688 const char *right, int32_t rightLength,
725 uint8_t *dest, int32_t count,
UErrorCode &errorCode)
const;
733 #ifndef U_HIDE_INTERNAL_API
790 #endif // U_HIDE_INTERNAL_API
818 void adoptTailoring(CollationTailoring *t,
UErrorCode &errorCode);
822 const UChar *right, int32_t rightLength,
825 const uint8_t *right, int32_t rightLength,
828 void writeSortKey(
const UChar *s, int32_t length,
829 SortKeyByteSink &sink,
UErrorCode &errorCode)
const;
831 void writeIdenticalLevel(
const UChar *s,
const UChar *limit,
832 SortKeyByteSink &sink,
UErrorCode &errorCode)
const;
834 const CollationSettings &getDefaultSettings()
const;
836 void setAttributeDefault(int32_t attribute) {
837 explicitlySetAttributes &= ~((uint32_t)1 << attribute);
839 void setAttributeExplicitly(int32_t attribute) {
840 explicitlySetAttributes |= (uint32_t)1 << attribute;
842 UBool attributeHasBeenSetExplicitly(int32_t attribute)
const {
844 return (
UBool)((explicitlySetAttributes & ((uint32_t)1 << attribute)) != 0);
856 static void computeMaxExpansions(
const CollationTailoring *t,
UErrorCode &errorCode);
859 void setFastLatinOptions(CollationSettings &ownedSettings)
const;
861 const CollationData *data;
862 const CollationSettings *settings;
863 const CollationTailoring *tailoring;
864 const CollationCacheEntry *cacheEntry;
866 uint32_t explicitlySetAttributes;
868 UBool actualLocaleIsSameAsValid;
873 #endif // !UCONFIG_NO_COLLATION
void internalGetCEs(const UnicodeString &str, UVector64 &ces, UErrorCode &errorCode) const
Appends the CEs for the string to the vector.
C++ API: Collation Service.
virtual void setVariableTop(uint32_t varTop, UErrorCode &status)
Sets the variable top to the specified primary weight.
static RuleBasedCollator * rbcFromUCollator(UCollator *uc)
virtual CollationElementIterator * createCollationElementIterator(const UnicodeString &source) const
Creates a collation element iterator for the source string.
virtual UBool operator==(const Collator &other) const
Returns true if argument is the same as this object.
Collation keys are generated by the Collator class.
UColAttribute
Attributes that collation service understands.
int32_t cloneBinary(uint8_t *buffer, int32_t capacity, UErrorCode &status) const
Creates a binary image of a collator.
virtual int32_t getSortKey(const UnicodeString &source, uint8_t *result, int32_t resultLength) const
Get the sort key as an array of bytes from a UnicodeString.
Basic definitions for ICU, for both C and C++ APIs.
A mutable set of Unicode characters and multicharacter strings.
ECollationStrength
Base letter represents a primary difference.
virtual int32_t internalNextSortKeyPart(UCharIterator *iter, uint32_t state[2], uint8_t *dest, int32_t count, UErrorCode &errorCode) const
Implements ucol_nextSortKeyPart().
virtual UCollationResult compareUTF8(const StringPiece &source, const StringPiece &target, UErrorCode &status) const
Compares two UTF-8 strings using the Collator.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
int8_t UBool
The ICU boolean type.
virtual UColReorderCode getMaxVariable() const
Returns the maximum reordering group whose characters are affected by UCOL_ALTERNATE_HANDLING.
RuleBasedCollator(const RuleBasedCollator &other)
Copy constructor.
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
virtual int32_t getReorderCodes(int32_t *dest, int32_t destCapacity, UErrorCode &status) const
Retrieves the reordering codes for this collator.
@ UCOL_ATTRIBUTE_COUNT
The number of UColAttribute constants.
UColRuleOption
Options for retrieving the rule string.
virtual UnicodeSet * getTailoredSet(UErrorCode &status) const
Get a UnicodeSet that contains all the characters and sequences tailored in this collator.
virtual int32_t hashCode() const
Generates the hash code for the rule-based collation object.
The Collator class performs locale-sensitive string comparison.
RuleBasedCollator(const UnicodeString &rules, UColAttributeValue decompositionMode, UErrorCode &status)
RuleBasedCollator constructor.
virtual void setReorderCodes(const int32_t *reorderCodes, int32_t reorderCodesLength, UErrorCode &status)
Sets the ordering of scripts for this collator.
UColAttributeValue
Enum containing attribute values for controling collation behavior.
UCollationResult
UCOL_LESS is returned if source string is compared to be less than target string in the ucol_strcoll(...
RuleBasedCollator(const UnicodeString &rules, ECollationStrength collationStrength, UErrorCode &status)
RuleBasedCollator constructor.
A UParseError struct is used to returned detailed information about parsing errors.
virtual uint32_t getVariableTop(UErrorCode &status) const
Gets the variable top value of a Collator.
virtual int32_t internalGetShortDefinitionString(const char *locale, char *buffer, int32_t capacity, UErrorCode &status) const
Get the short definition string for a collator.
virtual UCollationResult compare(UCharIterator &sIter, UCharIterator &tIter, UErrorCode &status) const
Compares two strings using the Collator.
virtual CollationKey & getCollationKey(const UnicodeString &source, CollationKey &key, UErrorCode &status) const
Transforms the string into a series of characters that can be compared with CollationKey....
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
virtual CollationKey & getCollationKey(const UChar *source, int32_t sourceLength, CollationKey &key, UErrorCode &status) const
Transforms a specified region of the string into a series of characters that can be compared with Col...
RuleBasedCollator(const UnicodeString &rules, ECollationStrength collationStrength, UColAttributeValue decompositionMode, UErrorCode &status)
RuleBasedCollator constructor.
virtual Collator & setMaxVariable(UColReorderCode group, UErrorCode &errorCode)
Sets the variable top to the top of the specified reordering group.
virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status)
Sets the variable top to the primary weight of the specified string.
virtual UCollationResult compare(const UnicodeString &source, const UnicodeString &target, int32_t length, UErrorCode &status) const
Does the same thing as compare but limits the comparison to a specified length.
The RuleBasedCollator class provides the implementation of Collator, using data-driven tables.
struct UCollator UCollator
structure representing a collator object instance
virtual Collator * clone(void) const
Makes a copy of this object.
RuleBasedCollator(const UnicodeString &rules, UParseError &parseError, UnicodeString &reason, UErrorCode &errorCode)
TODO: document & propose as public API.
virtual void setLocales(const Locale &requestedLocale, const Locale &validLocale, const Locale &actualLocale)
Used internally by registration to define the requested and valid locales.
virtual int32_t getSortKey(const UChar *source, int32_t sourceLength, uint8_t *result, int32_t resultLength) const
Get the sort key as an array of bytes from a UChar buffer.
const char * internalGetLocaleID(ULocDataLocaleType type, UErrorCode &errorCode) const
Implements ucol_getLocaleByType().
Abstract class that defines an API for iteration on text objects.
void getRules(UColRuleOption delta, UnicodeString &buffer) const
Returns current rules.
RuleBasedCollator(const uint8_t *bin, int32_t length, const RuleBasedCollator *base, UErrorCode &status)
Opens a collator from a collator binary image created using cloneBinary.
RuleBasedCollator & operator=(const RuleBasedCollator &other)
Assignment operator.
virtual ~RuleBasedCollator()
Destructor.
C API for code unit iteration.
virtual UCollationResult compare(const UnicodeString &source, const UnicodeString &target, UErrorCode &status) const
The comparison function compares the character data stored in two different strings.
virtual void getVersion(UVersionInfo info) const
Gets the version information for a Collator.
void internalAddContractions(UChar32 c, UnicodeSet &set, UErrorCode &errorCode) const
Adds the contractions that start with character c to the set.
int32_t getMaxExpansion(int32_t order) const
Returns the maximum length of any expansion sequences that end with the specified comparison order.
C API: Unicode Character Iteration.
virtual UCollationResult internalCompareUTF8(const char *left, int32_t leftLength, const char *right, int32_t rightLength, UErrorCode &errorCode) const
Implements ucol_strcollUTF8().
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
static Collator * fromUCollator(UCollator *uc)
uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]
The binary form of a version on ICU APIs is an array of 4 uint8_t.
void internalGetContractionsAndExpansions(UnicodeSet *contractions, UnicodeSet *expansions, UBool addPrefixes, UErrorCode &errorCode) const
Implements ucol_getContractionsAndExpansions().
C++ API: Locale ID object.
virtual Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Gets the locale of the Collator.
void internalBuildTailoring(const UnicodeString &rules, int32_t strength, UColAttributeValue decompositionMode, UParseError *outParseError, UnicodeString *outReason, UErrorCode &errorCode)
Implements from-rule constructors, and ucol_openRules().
virtual UColAttributeValue getAttribute(UColAttribute attr, UErrorCode &status) const
Universal attribute getter.
uint8_t * cloneRuleData(int32_t &length, UErrorCode &status) const
Do not use this method: The caller and the ICU library might use different heaps.
const UnicodeString & getRules() const
Gets the tailoring rules for this collator.
virtual EComparisonResult compare(const UnicodeString &source, const UnicodeString &target) const
The comparison function compares the character data stored in two different strings.
RuleBasedCollator()
Only for use in ucol_openRules().
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
The CollationElementIterator class is used as an iterator to walk through each character of an inte...
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
A string-like object that points to a sized piece of memory.
RuleBasedCollator(const UnicodeString &rules, UErrorCode &status)
RuleBasedCollator constructor.
A Locale object represents a specific geographical, political, or cultural region.
virtual CollationElementIterator * createCollationElementIterator(const CharacterIterator &source) const
Creates a collation element iterator for the source.
static const RuleBasedCollator * rbcFromUCollator(const UCollator *uc)
virtual UCollationResult compare(const UChar *source, int32_t sourceLength, const UChar *target, int32_t targetLength, UErrorCode &status) const
The comparison function compares the character data stored in two different string arrays.
UColReorderCode
Enum containing the codes for reordering segments of the collation table that are not script codes.
virtual uint32_t setVariableTop(const UnicodeString &varTop, UErrorCode &status)
Sets the variable top to the primary weight of the specified string.
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
virtual void setAttribute(UColAttribute attr, UColAttributeValue value, UErrorCode &status)
Universal attribute setter.
static UClassID getStaticClassID(void)
Returns the class ID for this class.