2 *******************************************************************************
4 * Copyright (C) 1998-2014, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
9 * Private implementation header for C collation
10 * file name: ucol_imp.h
12 * tab size: 8 (not used)
15 * created on: 2000dec11
16 * created by: Vladimir Weinstein
18 * Modification history
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.
29 #include "unicode/utypes.h"
31 #if !UCONFIG_NO_COLLATION
33 // This part needs to compile as plain C code, for cintltst.
35 #include "unicode/ucol.h"
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
45 U_INTERNAL UBool U_EXPORT2
46 ucol_equals(const UCollator
*source
, const UCollator
*target
);
49 * Convenience string denoting the Collation data tree
51 #define U_ICUDATA_COLL U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "coll"
55 #include "unicode/locid.h"
56 #include "unicode/ures.h"
60 struct CollationCacheEntry
;
66 /** Implemented in ucol_res.cpp. */
67 class CollationLoader
{
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
);
75 // Cache callback. Adds a reference to returned value.
76 const CollationCacheEntry
*createCacheEntry(UErrorCode
&errorCode
);
79 static void loadRootRules(UErrorCode
&errorCode
);
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;
87 CollationLoader(const CollationCacheEntry
*re
, const Locale
&requested
, UErrorCode
&errorCode
);
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
);
96 // Adds a reference to returned value.
97 const CollationCacheEntry
*getCacheEntry(UErrorCode
&errorCode
);
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.
104 const CollationCacheEntry
*makeCacheEntryFromRoot(
105 const Locale
&loc
, UErrorCode
&errorCode
) const;
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
113 static const CollationCacheEntry
*makeCacheEntry(
115 const CollationCacheEntry
*entryFromCache
,
116 UErrorCode
&errorCode
);
118 const UnifiedCache
*cache
;
119 const CollationCacheEntry
*rootEntry
;
123 char defaultType
[16];
126 UResourceBundle
*bundle
;
127 UResourceBundle
*collations
;
128 UResourceBundle
*data
;
133 #endif /* __cplusplus */
135 #endif /* #if !UCONFIG_NO_COLLATION */