1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
6 * Copyright (C) 1998-2014, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 *******************************************************************************
11 * Private implementation header for C collation
12 * file name: ucol_imp.h
14 * tab size: 8 (not used)
17 * created on: 2000dec11
18 * created by: Vladimir Weinstein
20 * Modification history
22 * 02/16/2001 synwee Added UCOL_GETPREVCE for the use in ucoleitr
23 * 02/27/2001 synwee Added getMaxExpansion data structure in UCollator
24 * 03/02/2001 synwee Added UCOL_IMPLICIT_CE
25 * 03/12/2001 synwee Added pointer start to collIterate.
31 #include "unicode/utypes.h"
33 #if !UCONFIG_NO_COLLATION
35 // This part needs to compile as plain C code, for cintltst.
37 #include "unicode/ucol.h"
39 /** Check whether two collators are equal. Collators are considered equal if they
40 * will sort strings the same. This means that both the current attributes and the
41 * rules must be equivalent.
42 * @param source first collator
43 * @param target second collator
44 * @return TRUE or FALSE
47 U_INTERNAL UBool U_EXPORT2
48 ucol_equals(const UCollator *source, const UCollator *target);
51 * Convenience string denoting the Collation data tree
53 #define U_ICUDATA_COLL U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "coll"
57 #include "unicode/locid.h"
58 #include "unicode/ures.h"
62 struct CollationCacheEntry;
68 /** Implemented in ucol_res.cpp. */
69 class CollationLoader {
71 static void appendRootRules(UnicodeString &s);
72 static void loadRules(const char *localeID, const char *collationType,
73 UnicodeString &rules, UErrorCode &errorCode);
74 // Adds a reference to returned value.
75 static const CollationCacheEntry *loadTailoring(const Locale &locale, UErrorCode &errorCode);
77 // Cache callback. Adds a reference to returned value.
78 const CollationCacheEntry *createCacheEntry(UErrorCode &errorCode);
81 static void U_CALLCONV loadRootRules(UErrorCode &errorCode);
83 // The following members are used by loadTailoring()
84 // and the cache callback.
85 static const uint32_t TRIED_SEARCH = 1;
86 static const uint32_t TRIED_DEFAULT = 2;
87 static const uint32_t TRIED_STANDARD = 4;
89 CollationLoader(const CollationCacheEntry *re, const Locale &requested, UErrorCode &errorCode);
92 // All loadFromXXX methods add a reference to the returned value.
93 const CollationCacheEntry *loadFromLocale(UErrorCode &errorCode);
94 const CollationCacheEntry *loadFromBundle(UErrorCode &errorCode);
95 const CollationCacheEntry *loadFromCollations(UErrorCode &errorCode);
96 const CollationCacheEntry *loadFromData(UErrorCode &errorCode);
98 // Adds a reference to returned value.
99 const CollationCacheEntry *getCacheEntry(UErrorCode &errorCode);
102 * Returns the rootEntry (with one addRef()) if loc==root,
103 * or else returns a new cache entry with ref count 1 for the loc and
104 * the root tailoring.
106 const CollationCacheEntry *makeCacheEntryFromRoot(
107 const Locale &loc, UErrorCode &errorCode) const;
110 * Returns the entryFromCache as is if loc==validLocale,
111 * or else returns a new cache entry with ref count 1 for the loc and
112 * the same tailoring. In the latter case, a ref count is removed from
115 static const CollationCacheEntry *makeCacheEntry(
117 const CollationCacheEntry *entryFromCache,
118 UErrorCode &errorCode);
120 const UnifiedCache *cache;
121 const CollationCacheEntry *rootEntry;
125 char defaultType[16];
128 UResourceBundle *bundle;
129 UResourceBundle *collations;
130 UResourceBundle *data;
135 #endif /* __cplusplus */
137 #endif /* #if !UCONFIG_NO_COLLATION */