]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/ucol_imp.h
ICU-57131.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / ucol_imp.h
CommitLineData
b75a7d8f
A
1/*
2*******************************************************************************
3*
57a6839d 4* Copyright (C) 1998-2014, International Business Machines
b75a7d8f
A
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"
374ca955 30
b75a7d8f
A
31#if !UCONFIG_NO_COLLATION
32
b331163b
A
33// This part needs to compile as plain C code, for cintltst.
34
b75a7d8f 35#include "unicode/ucol.h"
729e4ab9 36
57a6839d
A
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
b75a7d8f 44 */
57a6839d
A
45U_INTERNAL UBool U_EXPORT2
46ucol_equals(const UCollator *source, const UCollator *target);
b75a7d8f
A
47
48/**
57a6839d 49 * Convenience string denoting the Collation data tree
b75a7d8f 50 */
57a6839d 51#define U_ICUDATA_COLL U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "coll"
4388f060
A
52
53#ifdef __cplusplus
54
b331163b
A
55#include "unicode/locid.h"
56#include "unicode/ures.h"
57
4388f060
A
58U_NAMESPACE_BEGIN
59
b331163b 60struct CollationCacheEntry;
b75a7d8f 61
57a6839d
A
62class Locale;
63class UnicodeString;
b331163b 64class UnifiedCache;
b75a7d8f 65
57a6839d
A
66/** Implemented in ucol_res.cpp. */
67class CollationLoader {
68public:
69 static void appendRootRules(UnicodeString &s);
b331163b
A
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);
b75a7d8f 77
57a6839d 78private:
57a6839d 79 static void loadRootRules(UErrorCode &errorCode);
b331163b
A
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;
b75a7d8f
A
129};
130
57a6839d 131U_NAMESPACE_END
b75a7d8f 132
57a6839d 133#endif /* __cplusplus */
b75a7d8f
A
134
135#endif /* #if !UCONFIG_NO_COLLATION */
136
137#endif