]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/ucol_imp.h
ICU-62107.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / ucol_imp.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 *
6 * Copyright (C) 1998-2014, International Business Machines
7 * Corporation and others. All Rights Reserved.
8 *
9 *******************************************************************************
10 *
11 * Private implementation header for C collation
12 * file name: ucol_imp.h
13 * encoding: UTF-8
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"
32
33 #if !UCONFIG_NO_COLLATION
34
35 // This part needs to compile as plain C code, for cintltst.
36
37 #include "unicode/ucol.h"
38
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
46 */
47 U_INTERNAL UBool U_EXPORT2
48 ucol_equals(const UCollator *source, const UCollator *target);
49
50 /**
51 * Convenience string denoting the Collation data tree
52 */
53 #define U_ICUDATA_COLL U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "coll"
54
55 #ifdef __cplusplus
56
57 #include "unicode/locid.h"
58 #include "unicode/ures.h"
59
60 U_NAMESPACE_BEGIN
61
62 struct CollationCacheEntry;
63
64 class Locale;
65 class UnicodeString;
66 class UnifiedCache;
67
68 /** Implemented in ucol_res.cpp. */
69 class CollationLoader {
70 public:
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);
76
77 // Cache callback. Adds a reference to returned value.
78 const CollationCacheEntry *createCacheEntry(UErrorCode &errorCode);
79
80 private:
81 static void U_CALLCONV loadRootRules(UErrorCode &errorCode);
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;
131 };
132
133 U_NAMESPACE_END
134
135 #endif /* __cplusplus */
136
137 #endif /* #if !UCONFIG_NO_COLLATION */
138
139 #endif