X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/57a6839dcb3bba09e8228b822b290604668416fe..a01113dcd0f39d5da295ef82785beff9ed86fe38:/icuSources/i18n/ucol_imp.h diff --git a/icuSources/i18n/ucol_imp.h b/icuSources/i18n/ucol_imp.h index 39d1b28c..a251fc46 100644 --- a/icuSources/i18n/ucol_imp.h +++ b/icuSources/i18n/ucol_imp.h @@ -1,3 +1,5 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* * @@ -8,7 +10,7 @@ * * Private implementation header for C collation * file name: ucol_imp.h -* encoding: US-ASCII +* encoding: UTF-8 * tab size: 8 (not used) * indentation:4 * @@ -30,6 +32,8 @@ #if !UCONFIG_NO_COLLATION +// This part needs to compile as plain C code, for cintltst. + #include "unicode/ucol.h" /** Check whether two collators are equal. Collators are considered equal if they @@ -50,25 +54,80 @@ ucol_equals(const UCollator *source, const UCollator *target); #ifdef __cplusplus +#include "unicode/locid.h" +#include "unicode/ures.h" + U_NAMESPACE_BEGIN -struct CollationTailoring; +struct CollationCacheEntry; class Locale; class UnicodeString; +class UnifiedCache; /** Implemented in ucol_res.cpp. */ class CollationLoader { public: static void appendRootRules(UnicodeString &s); - static UnicodeString *loadRules(const char *localeID, const char *collationType, - UErrorCode &errorCode); - static const CollationTailoring *loadTailoring(const Locale &locale, Locale &validLocale, - UErrorCode &errorCode); + static void loadRules(const char *localeID, const char *collationType, + UnicodeString &rules, UErrorCode &errorCode); + // Adds a reference to returned value. + static const CollationCacheEntry *loadTailoring(const Locale &locale, UErrorCode &errorCode); + + // Cache callback. Adds a reference to returned value. + const CollationCacheEntry *createCacheEntry(UErrorCode &errorCode); private: - CollationLoader(); // not implemented, all methods are static - static void loadRootRules(UErrorCode &errorCode); + static void U_CALLCONV loadRootRules(UErrorCode &errorCode); + + // The following members are used by loadTailoring() + // and the cache callback. + static const uint32_t TRIED_SEARCH = 1; + static const uint32_t TRIED_DEFAULT = 2; + static const uint32_t TRIED_STANDARD = 4; + + CollationLoader(const CollationCacheEntry *re, const Locale &requested, UErrorCode &errorCode); + ~CollationLoader(); + + // All loadFromXXX methods add a reference to the returned value. + const CollationCacheEntry *loadFromLocale(UErrorCode &errorCode); + const CollationCacheEntry *loadFromBundle(UErrorCode &errorCode); + const CollationCacheEntry *loadFromCollations(UErrorCode &errorCode); + const CollationCacheEntry *loadFromData(UErrorCode &errorCode); + + // Adds a reference to returned value. + const CollationCacheEntry *getCacheEntry(UErrorCode &errorCode); + + /** + * Returns the rootEntry (with one addRef()) if loc==root, + * or else returns a new cache entry with ref count 1 for the loc and + * the root tailoring. + */ + const CollationCacheEntry *makeCacheEntryFromRoot( + const Locale &loc, UErrorCode &errorCode) const; + + /** + * Returns the entryFromCache as is if loc==validLocale, + * or else returns a new cache entry with ref count 1 for the loc and + * the same tailoring. In the latter case, a ref count is removed from + * entryFromCache. + */ + static const CollationCacheEntry *makeCacheEntry( + const Locale &loc, + const CollationCacheEntry *entryFromCache, + UErrorCode &errorCode); + + const UnifiedCache *cache; + const CollationCacheEntry *rootEntry; + Locale validLocale; + Locale locale; + char type[16]; + char defaultType[16]; + uint32_t typesTried; + UBool typeFallback; + UResourceBundle *bundle; + UResourceBundle *collations; + UResourceBundle *data; }; U_NAMESPACE_END