]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
b75a7d8f A |
3 | /* |
4 | ******************************************************************************* | |
5 | * | |
57a6839d | 6 | * Copyright (C) 1998-2014, International Business Machines |
b75a7d8f A |
7 | * Corporation and others. All Rights Reserved. |
8 | * | |
9 | ******************************************************************************* | |
10 | * | |
11 | * Private implementation header for C collation | |
12 | * file name: ucol_imp.h | |
f3c0d7a5 | 13 | * encoding: UTF-8 |
b75a7d8f A |
14 | * tab size: 8 (not used) |
15 | * indentation:4 | |
16 | * | |
17 | * created on: 2000dec11 | |
18 | * created by: Vladimir Weinstein | |
19 | * | |
20 | * Modification history | |
21 | * Date Name Comments | |
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. | |
26 | */ | |
27 | ||
28 | #ifndef UCOL_IMP_H | |
29 | #define UCOL_IMP_H | |
30 | ||
31 | #include "unicode/utypes.h" | |
374ca955 | 32 | |
b75a7d8f A |
33 | #if !UCONFIG_NO_COLLATION |
34 | ||
b331163b A |
35 | // This part needs to compile as plain C code, for cintltst. |
36 | ||
b75a7d8f | 37 | #include "unicode/ucol.h" |
729e4ab9 | 38 | |
57a6839d A |
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 | |
45 | * @internal ICU 3.0 | |
b75a7d8f | 46 | */ |
57a6839d A |
47 | U_INTERNAL UBool U_EXPORT2 |
48 | ucol_equals(const UCollator *source, const UCollator *target); | |
b75a7d8f A |
49 | |
50 | /** | |
57a6839d | 51 | * Convenience string denoting the Collation data tree |
b75a7d8f | 52 | */ |
57a6839d | 53 | #define U_ICUDATA_COLL U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "coll" |
4388f060 A |
54 | |
55 | #ifdef __cplusplus | |
56 | ||
b331163b A |
57 | #include "unicode/locid.h" |
58 | #include "unicode/ures.h" | |
59 | ||
4388f060 A |
60 | U_NAMESPACE_BEGIN |
61 | ||
b331163b | 62 | struct CollationCacheEntry; |
b75a7d8f | 63 | |
57a6839d A |
64 | class Locale; |
65 | class UnicodeString; | |
b331163b | 66 | class UnifiedCache; |
b75a7d8f | 67 | |
57a6839d A |
68 | /** Implemented in ucol_res.cpp. */ |
69 | class CollationLoader { | |
70 | public: | |
71 | static void appendRootRules(UnicodeString &s); | |
b331163b A |
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); | |
76 | ||
77 | // Cache callback. Adds a reference to returned value. | |
78 | const CollationCacheEntry *createCacheEntry(UErrorCode &errorCode); | |
b75a7d8f | 79 | |
57a6839d | 80 | private: |
f3c0d7a5 | 81 | static void U_CALLCONV loadRootRules(UErrorCode &errorCode); |
b331163b A |
82 | |
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; | |
88 | ||
89 | CollationLoader(const CollationCacheEntry *re, const Locale &requested, UErrorCode &errorCode); | |
90 | ~CollationLoader(); | |
91 | ||
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); | |
97 | ||
98 | // Adds a reference to returned value. | |
99 | const CollationCacheEntry *getCacheEntry(UErrorCode &errorCode); | |
100 | ||
101 | /** | |
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. | |
105 | */ | |
106 | const CollationCacheEntry *makeCacheEntryFromRoot( | |
107 | const Locale &loc, UErrorCode &errorCode) const; | |
108 | ||
109 | /** | |
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 | |
113 | * entryFromCache. | |
114 | */ | |
115 | static const CollationCacheEntry *makeCacheEntry( | |
116 | const Locale &loc, | |
117 | const CollationCacheEntry *entryFromCache, | |
118 | UErrorCode &errorCode); | |
119 | ||
120 | const UnifiedCache *cache; | |
121 | const CollationCacheEntry *rootEntry; | |
122 | Locale validLocale; | |
123 | Locale locale; | |
124 | char type[16]; | |
125 | char defaultType[16]; | |
126 | uint32_t typesTried; | |
127 | UBool typeFallback; | |
128 | UResourceBundle *bundle; | |
129 | UResourceBundle *collations; | |
130 | UResourceBundle *data; | |
b75a7d8f A |
131 | }; |
132 | ||
57a6839d | 133 | U_NAMESPACE_END |
b75a7d8f | 134 | |
57a6839d | 135 | #endif /* __cplusplus */ |
b75a7d8f A |
136 | |
137 | #endif /* #if !UCONFIG_NO_COLLATION */ | |
138 | ||
139 | #endif |