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
597 #ifndef U_HIDE_DRAFT_API
604 inline auto equal_to()
const {
return Predicate<std::equal_to, UCOL_EQUAL>(*this); }
611 inline auto greater()
const {
return Predicate<std::equal_to, UCOL_GREATER>(*this); }
618 inline auto less()
const {
return Predicate<std::equal_to, UCOL_LESS>(*this); }
625 inline auto not_equal_to()
const {
return Predicate<std::not_equal_to, UCOL_EQUAL>(*this); }
632 inline auto greater_equal()
const {
return Predicate<std::not_equal_to, UCOL_LESS>(*this); }
639 inline auto less_equal()
const {
return Predicate<std::not_equal_to, UCOL_GREATER>(*this); }
641 #endif // U_HIDE_DRAFT_API
643 #ifndef U_FORCE_HIDE_DEPRECATED_API
654 virtual ECollationStrength getStrength()
const;
674 virtual void setStrength(ECollationStrength newStrength);
675 #endif // U_FORCE_HIDE_DEPRECATED_API
692 virtual int32_t getReorderCodes(int32_t *dest,
693 int32_t destCapacity,
711 virtual void setReorderCodes(
const int32_t* reorderCodes,
712 int32_t reorderCodesLength,
735 static int32_t U_EXPORT2 getEquivalentReorderCodes(int32_t reorderCode,
737 int32_t destCapacity,
750 const Locale& displayLocale,
775 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
857 static Locale U_EXPORT2 getFunctionalEquivalent(
const char* keyword,
const Locale& locale,
860 #if !UCONFIG_NO_SERVICE
973 #ifndef U_FORCE_HIDE_DEPRECATED_API
990 virtual uint32_t setVariableTop(
const char16_t *varTop, int32_t len,
UErrorCode &status) = 0;
1020 virtual void setVariableTop(uint32_t varTop,
UErrorCode &status) = 0;
1021 #endif // U_FORCE_HIDE_DEPRECATED_API
1030 virtual uint32_t getVariableTop(
UErrorCode &status)
const = 0;
1043 #ifndef U_FORCE_HIDE_DEPRECATED_API
1051 virtual Collator* safeClone()
const;
1052 #endif // U_FORCE_HIDE_DEPRECATED_API
1072 int32_t resultLength)
const = 0;
1093 virtual int32_t getSortKey(
const char16_t*source, int32_t sourceLength,
1094 uint8_t*result, int32_t resultLength)
const = 0;
1133 static int32_t U_EXPORT2 getBound(
const uint8_t *source,
1134 int32_t sourceLength,
1136 uint32_t noOfLevels,
1138 int32_t resultLength,
1155 #ifndef U_HIDE_DEPRECATED_API
1186 virtual void setLocales(
const Locale& requestedLocale,
const Locale& validLocale,
const Locale& actualLocale);
1211 virtual int32_t internalGetShortDefinitionString(
const char *locale,
1221 const char *left, int32_t leftLength,
1222 const char *right, int32_t rightLength,
1230 internalNextSortKeyPart(
1232 uint8_t *dest, int32_t count,
UErrorCode &errorCode)
const;
1234 #ifndef U_HIDE_INTERNAL_API
1237 return reinterpret_cast<Collator *
>(uc);
1241 return reinterpret_cast<const Collator *
>(uc);
1245 return reinterpret_cast<UCollator *
>(
this);
1249 return reinterpret_cast<const UCollator *
>(
this);
1251 #endif // U_HIDE_INTERNAL_API
1259 friend class CFactory;
1260 friend class SimpleCFactory;
1261 friend class ICUCollatorFactory;
1262 friend class ICUCollatorService;
1266 #ifndef U_HIDE_DRAFT_API
1271 template <
template <
typename...>
typename Compare,
UCollationResult result>
1274 explicit Predicate(
const Collator& parent) : collator(parent) {}
1277 typename T,
typename U,
1278 typename = std::enable_if_t<ConvertibleToU16StringView<T> && ConvertibleToU16StringView<U>>>
1279 bool operator()(
const T& lhs,
const U& rhs)
const {
1283 UnicodeString::readOnlyAlias(lhs),
1284 UnicodeString::readOnlyAlias(rhs),
1289 bool operator()(std::string_view lhs, std::string_view rhs)
const {
1291 return compare(collator.compareUTF8(lhs, rhs, status), result);
1294 #if defined(__cpp_char8_t)
1295 bool operator()(std::u8string_view lhs, std::u8string_view rhs)
const {
1297 return compare(collator.compareUTF8(lhs, rhs, status), result);
1302 const Collator& collator;
1303 static constexpr Compare<UCollationResult> compare{};
1305 #endif // U_HIDE_DRAFT_API
1308 #if !UCONFIG_NO_SERVICE
1341 virtual UBool visible()
const;
1363 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.
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
UCollationResult
UCOL_LESS is returned if source string is compared to be less than target string in the ucol_strcoll(...
const UCollator * toUCollator() const
UNormalizationMode
Constants for normalization modes.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
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.
auto equal_to() const
Creates a comparison function object that uses this collator.
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...
auto less_equal() const
Creates a comparison function object that uses this collator.
UColAttribute
Attributes that collation service understands.
#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.
C API: Unicode Normalization.
auto greater_equal() const
Creates a comparison function object that uses this collator.
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 less() 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 t...
C++ API: Locale ID object.
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.
auto not_equal_to() const
Creates a comparison function object that uses this collator.
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.
auto greater() const
Creates a comparison function object that uses this collator.
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.