]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/ucol_imp.h
ICU-57131.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / ucol_imp.h
1 /*
2 *******************************************************************************
3 *
4 * Copyright (C) 1998-2014, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 *******************************************************************************
8 *
9 * Private implementation header for C collation
10 * file name: ucol_imp.h
11 * encoding: US-ASCII
12 * tab size: 8 (not used)
13 * indentation:4
14 *
15 * created on: 2000dec11
16 * created by: Vladimir Weinstein
17 *
18 * Modification history
19 * Date Name Comments
20 * 02/16/2001 synwee Added UCOL_GETPREVCE for the use in ucoleitr
21 * 02/27/2001 synwee Added getMaxExpansion data structure in UCollator
22 * 03/02/2001 synwee Added UCOL_IMPLICIT_CE
23 * 03/12/2001 synwee Added pointer start to collIterate.
24 */
25
26 #ifndef UCOL_IMP_H
27 #define UCOL_IMP_H
28
29 #include "unicode/utypes.h"
30
31 #if !UCONFIG_NO_COLLATION
32
33 // This part needs to compile as plain C code, for cintltst.
34
35 #include "unicode/ucol.h"
36
37 /** Check whether two collators are equal. Collators are considered equal if they
38 * will sort strings the same. This means that both the current attributes and the
39 * rules must be equivalent.
40 * @param source first collator
41 * @param target second collator
42 * @return TRUE or FALSE
43 * @internal ICU 3.0
44 */
45 U_INTERNAL UBool U_EXPORT2
46 ucol_equals(const UCollator *source, const UCollator *target);
47
48 /**
49 * Convenience string denoting the Collation data tree
50 */
51 #define U_ICUDATA_COLL U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "coll"
52
53 #ifdef __cplusplus
54
55 #include "unicode/locid.h"
56 #include "unicode/ures.h"
57
58 U_NAMESPACE_BEGIN
59
60 struct CollationCacheEntry;
61
62 class Locale;
63 class UnicodeString;
64 class UnifiedCache;
65
66 /** Implemented in ucol_res.cpp. */
67 class CollationLoader {
68 public:
69 static void appendRootRules(UnicodeString &s);
70 static void loadRules(const char *localeID, const char *collationType,
71 UnicodeString &rules, UErrorCode &errorCode);
72 // Adds a reference to returned value.
73 static const CollationCacheEntry *loadTailoring(const Locale &locale, UErrorCode &errorCode);
74
75 // Cache callback. Adds a reference to returned value.
76 const CollationCacheEntry *createCacheEntry(UErrorCode &errorCode);
77
78 private:
79 static void loadRootRules(UErrorCode &errorCode);
80
81 // The following members are used by loadTailoring()
82 // and the cache callback.
83 static const uint32_t TRIED_SEARCH = 1;
84 static const uint32_t TRIED_DEFAULT = 2;
85 static const uint32_t TRIED_STANDARD = 4;
86
87 CollationLoader(const CollationCacheEntry *re, const Locale &requested, UErrorCode &errorCode);
88 ~CollationLoader();
89
90 // All loadFromXXX methods add a reference to the returned value.
91 const CollationCacheEntry *loadFromLocale(UErrorCode &errorCode);
92 const CollationCacheEntry *loadFromBundle(UErrorCode &errorCode);
93 const CollationCacheEntry *loadFromCollations(UErrorCode &errorCode);
94 const CollationCacheEntry *loadFromData(UErrorCode &errorCode);
95
96 // Adds a reference to returned value.
97 const CollationCacheEntry *getCacheEntry(UErrorCode &errorCode);
98
99 /**
100 * Returns the rootEntry (with one addRef()) if loc==root,
101 * or else returns a new cache entry with ref count 1 for the loc and
102 * the root tailoring.
103 */
104 const CollationCacheEntry *makeCacheEntryFromRoot(
105 const Locale &loc, UErrorCode &errorCode) const;
106
107 /**
108 * Returns the entryFromCache as is if loc==validLocale,
109 * or else returns a new cache entry with ref count 1 for the loc and
110 * the same tailoring. In the latter case, a ref count is removed from
111 * entryFromCache.
112 */
113 static const CollationCacheEntry *makeCacheEntry(
114 const Locale &loc,
115 const CollationCacheEntry *entryFromCache,
116 UErrorCode &errorCode);
117
118 const UnifiedCache *cache;
119 const CollationCacheEntry *rootEntry;
120 Locale validLocale;
121 Locale locale;
122 char type[16];
123 char defaultType[16];
124 uint32_t typesTried;
125 UBool typeFallback;
126 UResourceBundle *bundle;
127 UResourceBundle *collations;
128 UResourceBundle *data;
129 };
130
131 U_NAMESPACE_END
132
133 #endif /* __cplusplus */
134
135 #endif /* #if !UCONFIG_NO_COLLATION */
136
137 #endif