57 #if U_SHOW_CPLUSPLUS_API 59 #if !UCONFIG_NO_COLLATION 62 #include <string_view> 63 #include <type_traits> 78 class StringEnumeration;
80 #if !UCONFIG_NO_SERVICE 84 class CollatorFactory;
215 #ifndef U_FORCE_HIDE_DEPRECATED_API 232 #endif // U_FORCE_HIDE_DEPRECATED_API 278 virtual Collator* clone()
const = 0;
336 #ifndef U_FORCE_HIDE_DEPRECATED_API 348 virtual EComparisonResult compare(
const UnicodeString& source,
350 #endif // U_FORCE_HIDE_DEPRECATED_API 368 #ifndef U_FORCE_HIDE_DEPRECATED_API 381 virtual EComparisonResult compare(
const UnicodeString& source,
383 int32_t length)
const;
384 #endif // U_FORCE_HIDE_DEPRECATED_API 404 #ifndef U_FORCE_HIDE_DEPRECATED_API 438 virtual EComparisonResult compare(
const char16_t* source, int32_t sourceLength,
439 const char16_t* target, int32_t targetLength)
441 #endif // U_FORCE_HIDE_DEPRECATED_API 459 virtual UCollationResult compare(
const char16_t* source, int32_t sourceLength,
460 const char16_t* target, int32_t targetLength,
536 virtual CollationKey& getCollationKey(
const char16_t*source,
537 int32_t sourceLength,
544 virtual int32_t hashCode()
const = 0;
546 #ifndef U_FORCE_HIDE_DEPRECATED_API 560 #endif // U_FORCE_HIDE_DEPRECATED_API 602 inline auto equal_to()
const {
return Predicate<std::equal_to, UCOL_EQUAL>(*this); }
609 inline auto greater()
const {
return Predicate<std::equal_to, UCOL_GREATER>(*this); }
616 inline auto less()
const {
return Predicate<std::equal_to, UCOL_LESS>(*this); }
623 inline auto not_equal_to()
const {
return Predicate<std::not_equal_to, UCOL_EQUAL>(*this); }
630 inline auto greater_equal()
const {
return Predicate<std::not_equal_to, UCOL_LESS>(*this); }
637 inline auto less_equal()
const {
return Predicate<std::not_equal_to, UCOL_GREATER>(*this); }
639 #ifndef U_FORCE_HIDE_DEPRECATED_API 650 virtual ECollationStrength getStrength()
const;
670 virtual void setStrength(ECollationStrength newStrength);
671 #endif // U_FORCE_HIDE_DEPRECATED_API 688 virtual int32_t getReorderCodes(int32_t *dest,
689 int32_t destCapacity,
707 virtual void setReorderCodes(
const int32_t* reorderCodes,
708 int32_t reorderCodesLength,
731 static int32_t U_EXPORT2 getEquivalentReorderCodes(int32_t reorderCode,
733 int32_t destCapacity,
746 const Locale& displayLocale,
771 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
853 static Locale U_EXPORT2 getFunctionalEquivalent(
const char* keyword,
const Locale& locale,
856 #if !UCONFIG_NO_SERVICE 969 #ifndef U_FORCE_HIDE_DEPRECATED_API 986 virtual uint32_t setVariableTop(
const char16_t *varTop, int32_t len,
UErrorCode &status) = 0;
1016 virtual void setVariableTop(uint32_t varTop,
UErrorCode &status) = 0;
1017 #endif // U_FORCE_HIDE_DEPRECATED_API 1026 virtual uint32_t getVariableTop(
UErrorCode &status)
const = 0;
1039 #ifndef U_FORCE_HIDE_DEPRECATED_API 1047 virtual Collator* safeClone()
const;
1048 #endif // U_FORCE_HIDE_DEPRECATED_API 1068 int32_t resultLength)
const = 0;
1089 virtual int32_t getSortKey(
const char16_t*source, int32_t sourceLength,
1090 uint8_t*result, int32_t resultLength)
const = 0;
1129 static int32_t U_EXPORT2 getBound(
const uint8_t *source,
1130 int32_t sourceLength,
1132 uint32_t noOfLevels,
1134 int32_t resultLength,
1151 #ifndef U_HIDE_DEPRECATED_API 1182 virtual void setLocales(
const Locale& requestedLocale,
const Locale& validLocale,
const Locale& actualLocale);
1207 virtual int32_t internalGetShortDefinitionString(
const char *locale,
1217 const char *left, int32_t leftLength,
1218 const char *right, int32_t rightLength,
1226 internalNextSortKeyPart(
1228 uint8_t *dest, int32_t count,
UErrorCode &errorCode)
const;
1230 #ifndef U_HIDE_INTERNAL_API 1233 return reinterpret_cast<Collator *
>(uc);
1237 return reinterpret_cast<const Collator *
>(uc);
1241 return reinterpret_cast<UCollator *
>(
this);
1245 return reinterpret_cast<const UCollator *
>(
this);
1247 #endif // U_HIDE_INTERNAL_API 1255 friend class CFactory;
1256 friend class SimpleCFactory;
1257 friend class ICUCollatorFactory;
1258 friend class ICUCollatorService;
1266 template <
template <
typename...>
typename Compare,
UCollationResult result>
1269 explicit Predicate(
const Collator& parent) : collator(parent) {}
1272 typename T,
typename U,
1273 typename = std::enable_if_t<ConvertibleToU16StringView<T> && ConvertibleToU16StringView<U>>>
1274 bool operator()(
const T& lhs,
const U& rhs)
const {
1278 UnicodeString::readOnlyAlias(lhs),
1279 UnicodeString::readOnlyAlias(rhs),
1284 bool operator()(std::string_view lhs, std::string_view rhs)
const {
1286 return compare(collator.compareUTF8(lhs, rhs, status), result);
1289 #if defined(__cpp_char8_t) 1290 bool operator()(std::u8string_view lhs, std::u8string_view rhs)
const {
1292 return compare(collator.compareUTF8(lhs, rhs, status), result);
1297 const Collator& collator;
1298 static constexpr Compare<UCollationResult> compare{};
1302 #if !UCONFIG_NO_SERVICE 1335 virtual UBool visible()
const;
1357 const Locale& displayLocale,
uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]
The binary form of a version on ICU APIs is an array of 4 uint8_t.
The Collator class performs locale-sensitive string comparison.
const UCollator * toUCollator() const
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
U_COMMON_API UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UCollationResult
UCOL_LESS is returned if source string is compared to be less than target string in the ucol_strcoll(...
UNormalizationMode
Constants for normalization modes.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
A factory, used with registerFactory, the creates multiple collators and provides display names for t...
C API: Miscellaneous definitions.
C API for code unit iteration.
Base class for 'pure' C++ implementations of uenum api.
static const Collator * fromUCollator(const UCollator *uc)
ECollationStrength
Base letter represents a primary difference.
UColReorderCode
Enum containing the codes for reordering segments of the collation table that are not script codes...
UColAttribute
Attributes that collation service understands.
auto less_equal() const
Creates a comparison function object that uses this collator.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
UCollator * toUCollator()
C++ API: StringPiece: Read-only byte string wrapper class.
Secondary collation strength.
auto not_equal_to() const
Creates a comparison function object that uses this collator.
C API: Unicode Normalization.
auto less() const
Creates a comparison function object that uses this collator.
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
EComparisonResult
LESS is returned if source string is compared to be less than target string in the compare() method...
Collation keys are generated by the Collator class.
Tertiary collation strength.
A mutable set of Unicode characters and multicharacter strings.
C API: Unicode Character Iteration.
C++ API: Common ICU base class UObject.
const void * URegistryKey
Opaque type returned by registerInstance, registerFactory and unregister for service registration...
auto equal_to() const
Creates a comparison function object that uses this collator.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
UColBoundMode
enum that is taken by ucol_getBound API See below for explanation do not change the values assigned ...
C++ API: Locale ID object.
auto greater_equal() const
Creates a comparison function object that uses this collator.
auto greater() const
Creates a comparison function object that uses this collator.
struct UCollator UCollator
structure representing a collator object instance
Basic definitions for ICU, for both C and C++ APIs.
static Collator * fromUCollator(UCollator *uc)
Identical collation strength.
Quaternary collation strength.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
UColAttributeValue
Enum containing attribute values for controlling collation behavior.
A string-like object that points to a sized piece of memory.
UObject is the common ICU "boilerplate" class.
Primary collation strength.
int8_t UBool
The ICU boolean type, a signed-byte integer.
C++ API: char16_t pointer wrappers with implicit conversion from bit-compatible raw pointer types...
A Locale object represents a specific geographical, political, or cultural region.