jpayne@69
|
1 // © 2016 and later: Unicode, Inc. and others.
|
jpayne@69
|
2 // License & terms of use: http://www.unicode.org/copyright.html
|
jpayne@69
|
3 /*
|
jpayne@69
|
4 ******************************************************************************
|
jpayne@69
|
5 * Copyright (C) 1996-2016, International Business Machines Corporation and
|
jpayne@69
|
6 * others. All Rights Reserved.
|
jpayne@69
|
7 ******************************************************************************
|
jpayne@69
|
8 */
|
jpayne@69
|
9
|
jpayne@69
|
10 /**
|
jpayne@69
|
11 * \file
|
jpayne@69
|
12 * \brief C++ API: The RuleBasedCollator class implements the Collator abstract base class.
|
jpayne@69
|
13 */
|
jpayne@69
|
14
|
jpayne@69
|
15 /**
|
jpayne@69
|
16 * File tblcoll.h
|
jpayne@69
|
17 *
|
jpayne@69
|
18 * Created by: Helena Shih
|
jpayne@69
|
19 *
|
jpayne@69
|
20 * Modification History:
|
jpayne@69
|
21 *
|
jpayne@69
|
22 * Date Name Description
|
jpayne@69
|
23 * 2/5/97 aliu Added streamIn and streamOut methods. Added
|
jpayne@69
|
24 * constructor which reads RuleBasedCollator object from
|
jpayne@69
|
25 * a binary file. Added writeToFile method which streams
|
jpayne@69
|
26 * RuleBasedCollator out to a binary file. The streamIn
|
jpayne@69
|
27 * and streamOut methods use istream and ostream objects
|
jpayne@69
|
28 * in binary mode.
|
jpayne@69
|
29 * 2/12/97 aliu Modified to use TableCollationData sub-object to
|
jpayne@69
|
30 * hold invariant data.
|
jpayne@69
|
31 * 2/13/97 aliu Moved several methods into this class from Collation.
|
jpayne@69
|
32 * Added a private RuleBasedCollator(Locale&) constructor,
|
jpayne@69
|
33 * to be used by Collator::createDefault(). General
|
jpayne@69
|
34 * clean up.
|
jpayne@69
|
35 * 2/20/97 helena Added clone, operator==, operator!=, operator=, and copy
|
jpayne@69
|
36 * constructor and getDynamicClassID.
|
jpayne@69
|
37 * 3/5/97 aliu Modified constructFromFile() to add parameter
|
jpayne@69
|
38 * specifying whether or not binary loading is to be
|
jpayne@69
|
39 * attempted. This is required for dynamic rule loading.
|
jpayne@69
|
40 * 05/07/97 helena Added memory allocation error detection.
|
jpayne@69
|
41 * 6/17/97 helena Added IDENTICAL strength for compare, changed getRules to
|
jpayne@69
|
42 * use MergeCollation::getPattern.
|
jpayne@69
|
43 * 6/20/97 helena Java class name change.
|
jpayne@69
|
44 * 8/18/97 helena Added internal API documentation.
|
jpayne@69
|
45 * 09/03/97 helena Added createCollationKeyValues().
|
jpayne@69
|
46 * 02/10/98 damiba Added compare with "length" parameter
|
jpayne@69
|
47 * 08/05/98 erm Synched with 1.2 version of RuleBasedCollator.java
|
jpayne@69
|
48 * 04/23/99 stephen Removed EDecompositionMode, merged with
|
jpayne@69
|
49 * Normalizer::EMode
|
jpayne@69
|
50 * 06/14/99 stephen Removed kResourceBundleSuffix
|
jpayne@69
|
51 * 11/02/99 helena Collator performance enhancements. Eliminates the
|
jpayne@69
|
52 * UnicodeString construction and special case for NO_OP.
|
jpayne@69
|
53 * 11/23/99 srl More performance enhancements. Updates to NormalizerIterator
|
jpayne@69
|
54 * internal state management.
|
jpayne@69
|
55 * 12/15/99 aliu Update to support Thai collation. Move NormalizerIterator
|
jpayne@69
|
56 * to implementation file.
|
jpayne@69
|
57 * 01/29/01 synwee Modified into a C++ wrapper which calls C API
|
jpayne@69
|
58 * (ucol.h)
|
jpayne@69
|
59 * 2012-2014 markus Rewritten in C++ again.
|
jpayne@69
|
60 */
|
jpayne@69
|
61
|
jpayne@69
|
62 #ifndef TBLCOLL_H
|
jpayne@69
|
63 #define TBLCOLL_H
|
jpayne@69
|
64
|
jpayne@69
|
65 #include "unicode/utypes.h"
|
jpayne@69
|
66
|
jpayne@69
|
67 #if U_SHOW_CPLUSPLUS_API
|
jpayne@69
|
68
|
jpayne@69
|
69 #if !UCONFIG_NO_COLLATION
|
jpayne@69
|
70
|
jpayne@69
|
71 #include "unicode/coll.h"
|
jpayne@69
|
72 #include "unicode/locid.h"
|
jpayne@69
|
73 #include "unicode/uiter.h"
|
jpayne@69
|
74 #include "unicode/ucol.h"
|
jpayne@69
|
75
|
jpayne@69
|
76 U_NAMESPACE_BEGIN
|
jpayne@69
|
77
|
jpayne@69
|
78 struct CollationCacheEntry;
|
jpayne@69
|
79 struct CollationData;
|
jpayne@69
|
80 struct CollationSettings;
|
jpayne@69
|
81 struct CollationTailoring;
|
jpayne@69
|
82 /**
|
jpayne@69
|
83 * @stable ICU 2.0
|
jpayne@69
|
84 */
|
jpayne@69
|
85 class StringSearch;
|
jpayne@69
|
86 /**
|
jpayne@69
|
87 * @stable ICU 2.0
|
jpayne@69
|
88 */
|
jpayne@69
|
89 class CollationElementIterator;
|
jpayne@69
|
90 class CollationKey;
|
jpayne@69
|
91 class SortKeyByteSink;
|
jpayne@69
|
92 class UnicodeSet;
|
jpayne@69
|
93 class UnicodeString;
|
jpayne@69
|
94 class UVector64;
|
jpayne@69
|
95
|
jpayne@69
|
96 /**
|
jpayne@69
|
97 * The RuleBasedCollator class provides the implementation of
|
jpayne@69
|
98 * Collator, using data-driven tables. The user can create a customized
|
jpayne@69
|
99 * table-based collation.
|
jpayne@69
|
100 * <p>
|
jpayne@69
|
101 * For more information about the collation service see
|
jpayne@69
|
102 * <a href="http://userguide.icu-project.org/collation">the User Guide</a>.
|
jpayne@69
|
103 * <p>
|
jpayne@69
|
104 * Collation service provides correct sorting orders for most locales supported in ICU.
|
jpayne@69
|
105 * If specific data for a locale is not available, the orders eventually falls back
|
jpayne@69
|
106 * to the <a href="http://www.unicode.org/reports/tr35/tr35-collation.html#Root_Collation">CLDR root sort order</a>.
|
jpayne@69
|
107 * <p>
|
jpayne@69
|
108 * Sort ordering may be customized by providing your own set of rules. For more on
|
jpayne@69
|
109 * this subject see the <a href="http://userguide.icu-project.org/collation/customization">
|
jpayne@69
|
110 * Collation Customization</a> section of the User Guide.
|
jpayne@69
|
111 * <p>
|
jpayne@69
|
112 * Note, RuleBasedCollator is not to be subclassed.
|
jpayne@69
|
113 * @see Collator
|
jpayne@69
|
114 */
|
jpayne@69
|
115 class U_I18N_API RuleBasedCollator : public Collator {
|
jpayne@69
|
116 public:
|
jpayne@69
|
117 /**
|
jpayne@69
|
118 * RuleBasedCollator constructor. This takes the table rules and builds a
|
jpayne@69
|
119 * collation table out of them. Please see RuleBasedCollator class
|
jpayne@69
|
120 * description for more details on the collation rule syntax.
|
jpayne@69
|
121 * @param rules the collation rules to build the collation table from.
|
jpayne@69
|
122 * @param status reporting a success or an error.
|
jpayne@69
|
123 * @stable ICU 2.0
|
jpayne@69
|
124 */
|
jpayne@69
|
125 RuleBasedCollator(const UnicodeString& rules, UErrorCode& status);
|
jpayne@69
|
126
|
jpayne@69
|
127 /**
|
jpayne@69
|
128 * RuleBasedCollator constructor. This takes the table rules and builds a
|
jpayne@69
|
129 * collation table out of them. Please see RuleBasedCollator class
|
jpayne@69
|
130 * description for more details on the collation rule syntax.
|
jpayne@69
|
131 * @param rules the collation rules to build the collation table from.
|
jpayne@69
|
132 * @param collationStrength strength for comparison
|
jpayne@69
|
133 * @param status reporting a success or an error.
|
jpayne@69
|
134 * @stable ICU 2.0
|
jpayne@69
|
135 */
|
jpayne@69
|
136 RuleBasedCollator(const UnicodeString& rules,
|
jpayne@69
|
137 ECollationStrength collationStrength,
|
jpayne@69
|
138 UErrorCode& status);
|
jpayne@69
|
139
|
jpayne@69
|
140 /**
|
jpayne@69
|
141 * RuleBasedCollator constructor. This takes the table rules and builds a
|
jpayne@69
|
142 * collation table out of them. Please see RuleBasedCollator class
|
jpayne@69
|
143 * description for more details on the collation rule syntax.
|
jpayne@69
|
144 * @param rules the collation rules to build the collation table from.
|
jpayne@69
|
145 * @param decompositionMode the normalisation mode
|
jpayne@69
|
146 * @param status reporting a success or an error.
|
jpayne@69
|
147 * @stable ICU 2.0
|
jpayne@69
|
148 */
|
jpayne@69
|
149 RuleBasedCollator(const UnicodeString& rules,
|
jpayne@69
|
150 UColAttributeValue decompositionMode,
|
jpayne@69
|
151 UErrorCode& status);
|
jpayne@69
|
152
|
jpayne@69
|
153 /**
|
jpayne@69
|
154 * RuleBasedCollator constructor. This takes the table rules and builds a
|
jpayne@69
|
155 * collation table out of them. Please see RuleBasedCollator class
|
jpayne@69
|
156 * description for more details on the collation rule syntax.
|
jpayne@69
|
157 * @param rules the collation rules to build the collation table from.
|
jpayne@69
|
158 * @param collationStrength strength for comparison
|
jpayne@69
|
159 * @param decompositionMode the normalisation mode
|
jpayne@69
|
160 * @param status reporting a success or an error.
|
jpayne@69
|
161 * @stable ICU 2.0
|
jpayne@69
|
162 */
|
jpayne@69
|
163 RuleBasedCollator(const UnicodeString& rules,
|
jpayne@69
|
164 ECollationStrength collationStrength,
|
jpayne@69
|
165 UColAttributeValue decompositionMode,
|
jpayne@69
|
166 UErrorCode& status);
|
jpayne@69
|
167
|
jpayne@69
|
168 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
169 /**
|
jpayne@69
|
170 * TODO: document & propose as public API
|
jpayne@69
|
171 * @internal
|
jpayne@69
|
172 */
|
jpayne@69
|
173 RuleBasedCollator(const UnicodeString &rules,
|
jpayne@69
|
174 UParseError &parseError, UnicodeString &reason,
|
jpayne@69
|
175 UErrorCode &errorCode);
|
jpayne@69
|
176 #endif /* U_HIDE_INTERNAL_API */
|
jpayne@69
|
177
|
jpayne@69
|
178 /**
|
jpayne@69
|
179 * Copy constructor.
|
jpayne@69
|
180 * @param other the RuleBasedCollator object to be copied
|
jpayne@69
|
181 * @stable ICU 2.0
|
jpayne@69
|
182 */
|
jpayne@69
|
183 RuleBasedCollator(const RuleBasedCollator& other);
|
jpayne@69
|
184
|
jpayne@69
|
185
|
jpayne@69
|
186 /** Opens a collator from a collator binary image created using
|
jpayne@69
|
187 * cloneBinary. Binary image used in instantiation of the
|
jpayne@69
|
188 * collator remains owned by the user and should stay around for
|
jpayne@69
|
189 * the lifetime of the collator. The API also takes a base collator
|
jpayne@69
|
190 * which must be the root collator.
|
jpayne@69
|
191 * @param bin binary image owned by the user and required through the
|
jpayne@69
|
192 * lifetime of the collator
|
jpayne@69
|
193 * @param length size of the image. If negative, the API will try to
|
jpayne@69
|
194 * figure out the length of the image
|
jpayne@69
|
195 * @param base Base collator, for lookup of untailored characters.
|
jpayne@69
|
196 * Must be the root collator, must not be NULL.
|
jpayne@69
|
197 * The base is required to be present through the lifetime of the collator.
|
jpayne@69
|
198 * @param status for catching errors
|
jpayne@69
|
199 * @return newly created collator
|
jpayne@69
|
200 * @see cloneBinary
|
jpayne@69
|
201 * @stable ICU 3.4
|
jpayne@69
|
202 */
|
jpayne@69
|
203 RuleBasedCollator(const uint8_t *bin, int32_t length,
|
jpayne@69
|
204 const RuleBasedCollator *base,
|
jpayne@69
|
205 UErrorCode &status);
|
jpayne@69
|
206
|
jpayne@69
|
207 /**
|
jpayne@69
|
208 * Destructor.
|
jpayne@69
|
209 * @stable ICU 2.0
|
jpayne@69
|
210 */
|
jpayne@69
|
211 virtual ~RuleBasedCollator();
|
jpayne@69
|
212
|
jpayne@69
|
213 /**
|
jpayne@69
|
214 * Assignment operator.
|
jpayne@69
|
215 * @param other other RuleBasedCollator object to copy from.
|
jpayne@69
|
216 * @stable ICU 2.0
|
jpayne@69
|
217 */
|
jpayne@69
|
218 RuleBasedCollator& operator=(const RuleBasedCollator& other);
|
jpayne@69
|
219
|
jpayne@69
|
220 /**
|
jpayne@69
|
221 * Returns true if argument is the same as this object.
|
jpayne@69
|
222 * @param other Collator object to be compared.
|
jpayne@69
|
223 * @return true if arguments is the same as this object.
|
jpayne@69
|
224 * @stable ICU 2.0
|
jpayne@69
|
225 */
|
jpayne@69
|
226 virtual UBool operator==(const Collator& other) const;
|
jpayne@69
|
227
|
jpayne@69
|
228 /**
|
jpayne@69
|
229 * Makes a copy of this object.
|
jpayne@69
|
230 * @return a copy of this object, owned by the caller
|
jpayne@69
|
231 * @stable ICU 2.0
|
jpayne@69
|
232 */
|
jpayne@69
|
233 virtual RuleBasedCollator* clone() const;
|
jpayne@69
|
234
|
jpayne@69
|
235 /**
|
jpayne@69
|
236 * Creates a collation element iterator for the source string. The caller of
|
jpayne@69
|
237 * this method is responsible for the memory management of the return
|
jpayne@69
|
238 * pointer.
|
jpayne@69
|
239 * @param source the string over which the CollationElementIterator will
|
jpayne@69
|
240 * iterate.
|
jpayne@69
|
241 * @return the collation element iterator of the source string using this as
|
jpayne@69
|
242 * the based Collator.
|
jpayne@69
|
243 * @stable ICU 2.2
|
jpayne@69
|
244 */
|
jpayne@69
|
245 virtual CollationElementIterator* createCollationElementIterator(
|
jpayne@69
|
246 const UnicodeString& source) const;
|
jpayne@69
|
247
|
jpayne@69
|
248 /**
|
jpayne@69
|
249 * Creates a collation element iterator for the source. The caller of this
|
jpayne@69
|
250 * method is responsible for the memory management of the returned pointer.
|
jpayne@69
|
251 * @param source the CharacterIterator which produces the characters over
|
jpayne@69
|
252 * which the CollationElementItgerator will iterate.
|
jpayne@69
|
253 * @return the collation element iterator of the source using this as the
|
jpayne@69
|
254 * based Collator.
|
jpayne@69
|
255 * @stable ICU 2.2
|
jpayne@69
|
256 */
|
jpayne@69
|
257 virtual CollationElementIterator* createCollationElementIterator(
|
jpayne@69
|
258 const CharacterIterator& source) const;
|
jpayne@69
|
259
|
jpayne@69
|
260 // Make deprecated versions of Collator::compare() visible.
|
jpayne@69
|
261 using Collator::compare;
|
jpayne@69
|
262
|
jpayne@69
|
263 /**
|
jpayne@69
|
264 * The comparison function compares the character data stored in two
|
jpayne@69
|
265 * different strings. Returns information about whether a string is less
|
jpayne@69
|
266 * than, greater than or equal to another string.
|
jpayne@69
|
267 * @param source the source string to be compared with.
|
jpayne@69
|
268 * @param target the string that is to be compared with the source string.
|
jpayne@69
|
269 * @param status possible error code
|
jpayne@69
|
270 * @return Returns an enum value. UCOL_GREATER if source is greater
|
jpayne@69
|
271 * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less
|
jpayne@69
|
272 * than target
|
jpayne@69
|
273 * @stable ICU 2.6
|
jpayne@69
|
274 **/
|
jpayne@69
|
275 virtual UCollationResult compare(const UnicodeString& source,
|
jpayne@69
|
276 const UnicodeString& target,
|
jpayne@69
|
277 UErrorCode &status) const;
|
jpayne@69
|
278
|
jpayne@69
|
279 /**
|
jpayne@69
|
280 * Does the same thing as compare but limits the comparison to a specified
|
jpayne@69
|
281 * length
|
jpayne@69
|
282 * @param source the source string to be compared with.
|
jpayne@69
|
283 * @param target the string that is to be compared with the source string.
|
jpayne@69
|
284 * @param length the length the comparison is limited to
|
jpayne@69
|
285 * @param status possible error code
|
jpayne@69
|
286 * @return Returns an enum value. UCOL_GREATER if source (up to the specified
|
jpayne@69
|
287 * length) is greater than target; UCOL_EQUAL if source (up to specified
|
jpayne@69
|
288 * length) is equal to target; UCOL_LESS if source (up to the specified
|
jpayne@69
|
289 * length) is less than target.
|
jpayne@69
|
290 * @stable ICU 2.6
|
jpayne@69
|
291 */
|
jpayne@69
|
292 virtual UCollationResult compare(const UnicodeString& source,
|
jpayne@69
|
293 const UnicodeString& target,
|
jpayne@69
|
294 int32_t length,
|
jpayne@69
|
295 UErrorCode &status) const;
|
jpayne@69
|
296
|
jpayne@69
|
297 /**
|
jpayne@69
|
298 * The comparison function compares the character data stored in two
|
jpayne@69
|
299 * different string arrays. Returns information about whether a string array
|
jpayne@69
|
300 * is less than, greater than or equal to another string array.
|
jpayne@69
|
301 * @param source the source string array to be compared with.
|
jpayne@69
|
302 * @param sourceLength the length of the source string array. If this value
|
jpayne@69
|
303 * is equal to -1, the string array is null-terminated.
|
jpayne@69
|
304 * @param target the string that is to be compared with the source string.
|
jpayne@69
|
305 * @param targetLength the length of the target string array. If this value
|
jpayne@69
|
306 * is equal to -1, the string array is null-terminated.
|
jpayne@69
|
307 * @param status possible error code
|
jpayne@69
|
308 * @return Returns an enum value. UCOL_GREATER if source is greater
|
jpayne@69
|
309 * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less
|
jpayne@69
|
310 * than target
|
jpayne@69
|
311 * @stable ICU 2.6
|
jpayne@69
|
312 */
|
jpayne@69
|
313 virtual UCollationResult compare(const char16_t* source, int32_t sourceLength,
|
jpayne@69
|
314 const char16_t* target, int32_t targetLength,
|
jpayne@69
|
315 UErrorCode &status) const;
|
jpayne@69
|
316
|
jpayne@69
|
317 /**
|
jpayne@69
|
318 * Compares two strings using the Collator.
|
jpayne@69
|
319 * Returns whether the first one compares less than/equal to/greater than
|
jpayne@69
|
320 * the second one.
|
jpayne@69
|
321 * This version takes UCharIterator input.
|
jpayne@69
|
322 * @param sIter the first ("source") string iterator
|
jpayne@69
|
323 * @param tIter the second ("target") string iterator
|
jpayne@69
|
324 * @param status ICU status
|
jpayne@69
|
325 * @return UCOL_LESS, UCOL_EQUAL or UCOL_GREATER
|
jpayne@69
|
326 * @stable ICU 4.2
|
jpayne@69
|
327 */
|
jpayne@69
|
328 virtual UCollationResult compare(UCharIterator &sIter,
|
jpayne@69
|
329 UCharIterator &tIter,
|
jpayne@69
|
330 UErrorCode &status) const;
|
jpayne@69
|
331
|
jpayne@69
|
332 /**
|
jpayne@69
|
333 * Compares two UTF-8 strings using the Collator.
|
jpayne@69
|
334 * Returns whether the first one compares less than/equal to/greater than
|
jpayne@69
|
335 * the second one.
|
jpayne@69
|
336 * This version takes UTF-8 input.
|
jpayne@69
|
337 * Note that a StringPiece can be implicitly constructed
|
jpayne@69
|
338 * from a std::string or a NUL-terminated const char * string.
|
jpayne@69
|
339 * @param source the first UTF-8 string
|
jpayne@69
|
340 * @param target the second UTF-8 string
|
jpayne@69
|
341 * @param status ICU status
|
jpayne@69
|
342 * @return UCOL_LESS, UCOL_EQUAL or UCOL_GREATER
|
jpayne@69
|
343 * @stable ICU 51
|
jpayne@69
|
344 */
|
jpayne@69
|
345 virtual UCollationResult compareUTF8(const StringPiece &source,
|
jpayne@69
|
346 const StringPiece &target,
|
jpayne@69
|
347 UErrorCode &status) const;
|
jpayne@69
|
348
|
jpayne@69
|
349 /**
|
jpayne@69
|
350 * Transforms the string into a series of characters
|
jpayne@69
|
351 * that can be compared with CollationKey.compare().
|
jpayne@69
|
352 *
|
jpayne@69
|
353 * Note that sort keys are often less efficient than simply doing comparison.
|
jpayne@69
|
354 * For more details, see the ICU User Guide.
|
jpayne@69
|
355 *
|
jpayne@69
|
356 * @param source the source string.
|
jpayne@69
|
357 * @param key the transformed key of the source string.
|
jpayne@69
|
358 * @param status the error code status.
|
jpayne@69
|
359 * @return the transformed key.
|
jpayne@69
|
360 * @see CollationKey
|
jpayne@69
|
361 * @stable ICU 2.0
|
jpayne@69
|
362 */
|
jpayne@69
|
363 virtual CollationKey& getCollationKey(const UnicodeString& source,
|
jpayne@69
|
364 CollationKey& key,
|
jpayne@69
|
365 UErrorCode& status) const;
|
jpayne@69
|
366
|
jpayne@69
|
367 /**
|
jpayne@69
|
368 * Transforms a specified region of the string into a series of characters
|
jpayne@69
|
369 * that can be compared with CollationKey.compare.
|
jpayne@69
|
370 *
|
jpayne@69
|
371 * Note that sort keys are often less efficient than simply doing comparison.
|
jpayne@69
|
372 * For more details, see the ICU User Guide.
|
jpayne@69
|
373 *
|
jpayne@69
|
374 * @param source the source string.
|
jpayne@69
|
375 * @param sourceLength the length of the source string.
|
jpayne@69
|
376 * @param key the transformed key of the source string.
|
jpayne@69
|
377 * @param status the error code status.
|
jpayne@69
|
378 * @return the transformed key.
|
jpayne@69
|
379 * @see CollationKey
|
jpayne@69
|
380 * @stable ICU 2.0
|
jpayne@69
|
381 */
|
jpayne@69
|
382 virtual CollationKey& getCollationKey(const char16_t *source,
|
jpayne@69
|
383 int32_t sourceLength,
|
jpayne@69
|
384 CollationKey& key,
|
jpayne@69
|
385 UErrorCode& status) const;
|
jpayne@69
|
386
|
jpayne@69
|
387 /**
|
jpayne@69
|
388 * Generates the hash code for the rule-based collation object.
|
jpayne@69
|
389 * @return the hash code.
|
jpayne@69
|
390 * @stable ICU 2.0
|
jpayne@69
|
391 */
|
jpayne@69
|
392 virtual int32_t hashCode() const;
|
jpayne@69
|
393
|
jpayne@69
|
394 #ifndef U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
395 /**
|
jpayne@69
|
396 * Gets the locale of the Collator
|
jpayne@69
|
397 * @param type can be either requested, valid or actual locale. For more
|
jpayne@69
|
398 * information see the definition of ULocDataLocaleType in
|
jpayne@69
|
399 * uloc.h
|
jpayne@69
|
400 * @param status the error code status.
|
jpayne@69
|
401 * @return locale where the collation data lives. If the collator
|
jpayne@69
|
402 * was instantiated from rules, locale is empty.
|
jpayne@69
|
403 * @deprecated ICU 2.8 likely to change in ICU 3.0, based on feedback
|
jpayne@69
|
404 */
|
jpayne@69
|
405 virtual Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
|
jpayne@69
|
406 #endif // U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
407
|
jpayne@69
|
408 /**
|
jpayne@69
|
409 * Gets the tailoring rules for this collator.
|
jpayne@69
|
410 * @return the collation tailoring from which this collator was created
|
jpayne@69
|
411 * @stable ICU 2.0
|
jpayne@69
|
412 */
|
jpayne@69
|
413 const UnicodeString& getRules() const;
|
jpayne@69
|
414
|
jpayne@69
|
415 /**
|
jpayne@69
|
416 * Gets the version information for a Collator.
|
jpayne@69
|
417 * @param info the version # information, the result will be filled in
|
jpayne@69
|
418 * @stable ICU 2.0
|
jpayne@69
|
419 */
|
jpayne@69
|
420 virtual void getVersion(UVersionInfo info) const;
|
jpayne@69
|
421
|
jpayne@69
|
422 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
423 /**
|
jpayne@69
|
424 * Returns the maximum length of any expansion sequences that end with the
|
jpayne@69
|
425 * specified comparison order.
|
jpayne@69
|
426 *
|
jpayne@69
|
427 * This is specific to the kind of collation element values and sequences
|
jpayne@69
|
428 * returned by the CollationElementIterator.
|
jpayne@69
|
429 * Call CollationElementIterator::getMaxExpansion() instead.
|
jpayne@69
|
430 *
|
jpayne@69
|
431 * @param order a collation order returned by CollationElementIterator::previous
|
jpayne@69
|
432 * or CollationElementIterator::next.
|
jpayne@69
|
433 * @return maximum size of the expansion sequences ending with the collation
|
jpayne@69
|
434 * element, or 1 if the collation element does not occur at the end of
|
jpayne@69
|
435 * any expansion sequence
|
jpayne@69
|
436 * @see CollationElementIterator#getMaxExpansion
|
jpayne@69
|
437 * @deprecated ICU 51 Use CollationElementIterator::getMaxExpansion() instead.
|
jpayne@69
|
438 */
|
jpayne@69
|
439 int32_t getMaxExpansion(int32_t order) const;
|
jpayne@69
|
440 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
441
|
jpayne@69
|
442 /**
|
jpayne@69
|
443 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
jpayne@69
|
444 * method is to implement a simple version of RTTI, since not all C++
|
jpayne@69
|
445 * compilers support genuine RTTI. Polymorphic operator==() and clone()
|
jpayne@69
|
446 * methods call this method.
|
jpayne@69
|
447 * @return The class ID for this object. All objects of a given class have
|
jpayne@69
|
448 * the same class ID. Objects of other classes have different class
|
jpayne@69
|
449 * IDs.
|
jpayne@69
|
450 * @stable ICU 2.0
|
jpayne@69
|
451 */
|
jpayne@69
|
452 virtual UClassID getDynamicClassID(void) const;
|
jpayne@69
|
453
|
jpayne@69
|
454 /**
|
jpayne@69
|
455 * Returns the class ID for this class. This is useful only for comparing to
|
jpayne@69
|
456 * a return value from getDynamicClassID(). For example:
|
jpayne@69
|
457 * <pre>
|
jpayne@69
|
458 * Base* polymorphic_pointer = createPolymorphicObject();
|
jpayne@69
|
459 * if (polymorphic_pointer->getDynamicClassID() ==
|
jpayne@69
|
460 * Derived::getStaticClassID()) ...
|
jpayne@69
|
461 * </pre>
|
jpayne@69
|
462 * @return The class ID for all objects of this class.
|
jpayne@69
|
463 * @stable ICU 2.0
|
jpayne@69
|
464 */
|
jpayne@69
|
465 static UClassID U_EXPORT2 getStaticClassID(void);
|
jpayne@69
|
466
|
jpayne@69
|
467 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
468 /**
|
jpayne@69
|
469 * Do not use this method: The caller and the ICU library might use different heaps.
|
jpayne@69
|
470 * Use cloneBinary() instead which writes to caller-provided memory.
|
jpayne@69
|
471 *
|
jpayne@69
|
472 * Returns a binary format of this collator.
|
jpayne@69
|
473 * @param length Returns the length of the data, in bytes
|
jpayne@69
|
474 * @param status the error code status.
|
jpayne@69
|
475 * @return memory, owned by the caller, of size 'length' bytes.
|
jpayne@69
|
476 * @deprecated ICU 52. Use cloneBinary() instead.
|
jpayne@69
|
477 */
|
jpayne@69
|
478 uint8_t *cloneRuleData(int32_t &length, UErrorCode &status) const;
|
jpayne@69
|
479 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
480
|
jpayne@69
|
481 /** Creates a binary image of a collator. This binary image can be stored and
|
jpayne@69
|
482 * later used to instantiate a collator using ucol_openBinary.
|
jpayne@69
|
483 * This API supports preflighting.
|
jpayne@69
|
484 * @param buffer a fill-in buffer to receive the binary image
|
jpayne@69
|
485 * @param capacity capacity of the destination buffer
|
jpayne@69
|
486 * @param status for catching errors
|
jpayne@69
|
487 * @return size of the image
|
jpayne@69
|
488 * @see ucol_openBinary
|
jpayne@69
|
489 * @stable ICU 3.4
|
jpayne@69
|
490 */
|
jpayne@69
|
491 int32_t cloneBinary(uint8_t *buffer, int32_t capacity, UErrorCode &status) const;
|
jpayne@69
|
492
|
jpayne@69
|
493 /**
|
jpayne@69
|
494 * Returns current rules. Delta defines whether full rules are returned or
|
jpayne@69
|
495 * just the tailoring.
|
jpayne@69
|
496 *
|
jpayne@69
|
497 * getRules(void) should normally be used instead.
|
jpayne@69
|
498 * See http://userguide.icu-project.org/collation/customization#TOC-Building-on-Existing-Locales
|
jpayne@69
|
499 * @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES.
|
jpayne@69
|
500 * @param buffer UnicodeString to store the result rules
|
jpayne@69
|
501 * @stable ICU 2.2
|
jpayne@69
|
502 * @see UCOL_FULL_RULES
|
jpayne@69
|
503 */
|
jpayne@69
|
504 void getRules(UColRuleOption delta, UnicodeString &buffer) const;
|
jpayne@69
|
505
|
jpayne@69
|
506 /**
|
jpayne@69
|
507 * Universal attribute setter
|
jpayne@69
|
508 * @param attr attribute type
|
jpayne@69
|
509 * @param value attribute value
|
jpayne@69
|
510 * @param status to indicate whether the operation went on smoothly or there were errors
|
jpayne@69
|
511 * @stable ICU 2.2
|
jpayne@69
|
512 */
|
jpayne@69
|
513 virtual void setAttribute(UColAttribute attr, UColAttributeValue value,
|
jpayne@69
|
514 UErrorCode &status);
|
jpayne@69
|
515
|
jpayne@69
|
516 /**
|
jpayne@69
|
517 * Universal attribute getter.
|
jpayne@69
|
518 * @param attr attribute type
|
jpayne@69
|
519 * @param status to indicate whether the operation went on smoothly or there were errors
|
jpayne@69
|
520 * @return attribute value
|
jpayne@69
|
521 * @stable ICU 2.2
|
jpayne@69
|
522 */
|
jpayne@69
|
523 virtual UColAttributeValue getAttribute(UColAttribute attr,
|
jpayne@69
|
524 UErrorCode &status) const;
|
jpayne@69
|
525
|
jpayne@69
|
526 /**
|
jpayne@69
|
527 * Sets the variable top to the top of the specified reordering group.
|
jpayne@69
|
528 * The variable top determines the highest-sorting character
|
jpayne@69
|
529 * which is affected by UCOL_ALTERNATE_HANDLING.
|
jpayne@69
|
530 * If that attribute is set to UCOL_NON_IGNORABLE, then the variable top has no effect.
|
jpayne@69
|
531 * @param group one of UCOL_REORDER_CODE_SPACE, UCOL_REORDER_CODE_PUNCTUATION,
|
jpayne@69
|
532 * UCOL_REORDER_CODE_SYMBOL, UCOL_REORDER_CODE_CURRENCY;
|
jpayne@69
|
533 * or UCOL_REORDER_CODE_DEFAULT to restore the default max variable group
|
jpayne@69
|
534 * @param errorCode Standard ICU error code. Its input value must
|
jpayne@69
|
535 * pass the U_SUCCESS() test, or else the function returns
|
jpayne@69
|
536 * immediately. Check for U_FAILURE() on output or use with
|
jpayne@69
|
537 * function chaining. (See User Guide for details.)
|
jpayne@69
|
538 * @return *this
|
jpayne@69
|
539 * @see getMaxVariable
|
jpayne@69
|
540 * @stable ICU 53
|
jpayne@69
|
541 */
|
jpayne@69
|
542 virtual Collator &setMaxVariable(UColReorderCode group, UErrorCode &errorCode);
|
jpayne@69
|
543
|
jpayne@69
|
544 /**
|
jpayne@69
|
545 * Returns the maximum reordering group whose characters are affected by UCOL_ALTERNATE_HANDLING.
|
jpayne@69
|
546 * @return the maximum variable reordering group.
|
jpayne@69
|
547 * @see setMaxVariable
|
jpayne@69
|
548 * @stable ICU 53
|
jpayne@69
|
549 */
|
jpayne@69
|
550 virtual UColReorderCode getMaxVariable() const;
|
jpayne@69
|
551
|
jpayne@69
|
552 #ifndef U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
553 /**
|
jpayne@69
|
554 * Sets the variable top to the primary weight of the specified string.
|
jpayne@69
|
555 *
|
jpayne@69
|
556 * Beginning with ICU 53, the variable top is pinned to
|
jpayne@69
|
557 * the top of one of the supported reordering groups,
|
jpayne@69
|
558 * and it must not be beyond the last of those groups.
|
jpayne@69
|
559 * See setMaxVariable().
|
jpayne@69
|
560 * @param varTop one or more (if contraction) char16_ts to which the variable top should be set
|
jpayne@69
|
561 * @param len length of variable top string. If -1 it is considered to be zero terminated.
|
jpayne@69
|
562 * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
|
jpayne@69
|
563 * U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
|
jpayne@69
|
564 * U_ILLEGAL_ARGUMENT_ERROR if the variable top is beyond
|
jpayne@69
|
565 * the last reordering group supported by setMaxVariable()
|
jpayne@69
|
566 * @return variable top primary weight
|
jpayne@69
|
567 * @deprecated ICU 53 Call setMaxVariable() instead.
|
jpayne@69
|
568 */
|
jpayne@69
|
569 virtual uint32_t setVariableTop(const char16_t *varTop, int32_t len, UErrorCode &status);
|
jpayne@69
|
570
|
jpayne@69
|
571 /**
|
jpayne@69
|
572 * Sets the variable top to the primary weight of the specified string.
|
jpayne@69
|
573 *
|
jpayne@69
|
574 * Beginning with ICU 53, the variable top is pinned to
|
jpayne@69
|
575 * the top of one of the supported reordering groups,
|
jpayne@69
|
576 * and it must not be beyond the last of those groups.
|
jpayne@69
|
577 * See setMaxVariable().
|
jpayne@69
|
578 * @param varTop a UnicodeString size 1 or more (if contraction) of char16_ts to which the variable top should be set
|
jpayne@69
|
579 * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
|
jpayne@69
|
580 * U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
|
jpayne@69
|
581 * U_ILLEGAL_ARGUMENT_ERROR if the variable top is beyond
|
jpayne@69
|
582 * the last reordering group supported by setMaxVariable()
|
jpayne@69
|
583 * @return variable top primary weight
|
jpayne@69
|
584 * @deprecated ICU 53 Call setMaxVariable() instead.
|
jpayne@69
|
585 */
|
jpayne@69
|
586 virtual uint32_t setVariableTop(const UnicodeString &varTop, UErrorCode &status);
|
jpayne@69
|
587
|
jpayne@69
|
588 /**
|
jpayne@69
|
589 * Sets the variable top to the specified primary weight.
|
jpayne@69
|
590 *
|
jpayne@69
|
591 * Beginning with ICU 53, the variable top is pinned to
|
jpayne@69
|
592 * the top of one of the supported reordering groups,
|
jpayne@69
|
593 * and it must not be beyond the last of those groups.
|
jpayne@69
|
594 * See setMaxVariable().
|
jpayne@69
|
595 * @param varTop primary weight, as returned by setVariableTop or ucol_getVariableTop
|
jpayne@69
|
596 * @param status error code
|
jpayne@69
|
597 * @deprecated ICU 53 Call setMaxVariable() instead.
|
jpayne@69
|
598 */
|
jpayne@69
|
599 virtual void setVariableTop(uint32_t varTop, UErrorCode &status);
|
jpayne@69
|
600 #endif // U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
601
|
jpayne@69
|
602 /**
|
jpayne@69
|
603 * Gets the variable top value of a Collator.
|
jpayne@69
|
604 * @param status error code (not changed by function). If error code is set, the return value is undefined.
|
jpayne@69
|
605 * @return the variable top primary weight
|
jpayne@69
|
606 * @see getMaxVariable
|
jpayne@69
|
607 * @stable ICU 2.0
|
jpayne@69
|
608 */
|
jpayne@69
|
609 virtual uint32_t getVariableTop(UErrorCode &status) const;
|
jpayne@69
|
610
|
jpayne@69
|
611 /**
|
jpayne@69
|
612 * Get a UnicodeSet that contains all the characters and sequences tailored in
|
jpayne@69
|
613 * this collator.
|
jpayne@69
|
614 * @param status error code of the operation
|
jpayne@69
|
615 * @return a pointer to a UnicodeSet object containing all the
|
jpayne@69
|
616 * code points and sequences that may sort differently than
|
jpayne@69
|
617 * in the root collator. The object must be disposed of by using delete
|
jpayne@69
|
618 * @stable ICU 2.4
|
jpayne@69
|
619 */
|
jpayne@69
|
620 virtual UnicodeSet *getTailoredSet(UErrorCode &status) const;
|
jpayne@69
|
621
|
jpayne@69
|
622 /**
|
jpayne@69
|
623 * Get the sort key as an array of bytes from a UnicodeString.
|
jpayne@69
|
624 *
|
jpayne@69
|
625 * Note that sort keys are often less efficient than simply doing comparison.
|
jpayne@69
|
626 * For more details, see the ICU User Guide.
|
jpayne@69
|
627 *
|
jpayne@69
|
628 * @param source string to be processed.
|
jpayne@69
|
629 * @param result buffer to store result in. If NULL, number of bytes needed
|
jpayne@69
|
630 * will be returned.
|
jpayne@69
|
631 * @param resultLength length of the result buffer. If if not enough the
|
jpayne@69
|
632 * buffer will be filled to capacity.
|
jpayne@69
|
633 * @return Number of bytes needed for storing the sort key
|
jpayne@69
|
634 * @stable ICU 2.0
|
jpayne@69
|
635 */
|
jpayne@69
|
636 virtual int32_t getSortKey(const UnicodeString& source, uint8_t *result,
|
jpayne@69
|
637 int32_t resultLength) const;
|
jpayne@69
|
638
|
jpayne@69
|
639 /**
|
jpayne@69
|
640 * Get the sort key as an array of bytes from a char16_t buffer.
|
jpayne@69
|
641 *
|
jpayne@69
|
642 * Note that sort keys are often less efficient than simply doing comparison.
|
jpayne@69
|
643 * For more details, see the ICU User Guide.
|
jpayne@69
|
644 *
|
jpayne@69
|
645 * @param source string to be processed.
|
jpayne@69
|
646 * @param sourceLength length of string to be processed. If -1, the string
|
jpayne@69
|
647 * is 0 terminated and length will be decided by the function.
|
jpayne@69
|
648 * @param result buffer to store result in. If NULL, number of bytes needed
|
jpayne@69
|
649 * will be returned.
|
jpayne@69
|
650 * @param resultLength length of the result buffer. If if not enough the
|
jpayne@69
|
651 * buffer will be filled to capacity.
|
jpayne@69
|
652 * @return Number of bytes needed for storing the sort key
|
jpayne@69
|
653 * @stable ICU 2.2
|
jpayne@69
|
654 */
|
jpayne@69
|
655 virtual int32_t getSortKey(const char16_t *source, int32_t sourceLength,
|
jpayne@69
|
656 uint8_t *result, int32_t resultLength) const;
|
jpayne@69
|
657
|
jpayne@69
|
658 /**
|
jpayne@69
|
659 * Retrieves the reordering codes for this collator.
|
jpayne@69
|
660 * @param dest The array to fill with the script ordering.
|
jpayne@69
|
661 * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function
|
jpayne@69
|
662 * will only return the length of the result without writing any codes (pre-flighting).
|
jpayne@69
|
663 * @param status A reference to an error code value, which must not indicate
|
jpayne@69
|
664 * a failure before the function call.
|
jpayne@69
|
665 * @return The length of the script ordering array.
|
jpayne@69
|
666 * @see ucol_setReorderCodes
|
jpayne@69
|
667 * @see Collator#getEquivalentReorderCodes
|
jpayne@69
|
668 * @see Collator#setReorderCodes
|
jpayne@69
|
669 * @stable ICU 4.8
|
jpayne@69
|
670 */
|
jpayne@69
|
671 virtual int32_t getReorderCodes(int32_t *dest,
|
jpayne@69
|
672 int32_t destCapacity,
|
jpayne@69
|
673 UErrorCode& status) const;
|
jpayne@69
|
674
|
jpayne@69
|
675 /**
|
jpayne@69
|
676 * Sets the ordering of scripts for this collator.
|
jpayne@69
|
677 * @param reorderCodes An array of script codes in the new order. This can be NULL if the
|
jpayne@69
|
678 * length is also set to 0. An empty array will clear any reordering codes on the collator.
|
jpayne@69
|
679 * @param reorderCodesLength The length of reorderCodes.
|
jpayne@69
|
680 * @param status error code
|
jpayne@69
|
681 * @see ucol_setReorderCodes
|
jpayne@69
|
682 * @see Collator#getReorderCodes
|
jpayne@69
|
683 * @see Collator#getEquivalentReorderCodes
|
jpayne@69
|
684 * @stable ICU 4.8
|
jpayne@69
|
685 */
|
jpayne@69
|
686 virtual void setReorderCodes(const int32_t* reorderCodes,
|
jpayne@69
|
687 int32_t reorderCodesLength,
|
jpayne@69
|
688 UErrorCode& status) ;
|
jpayne@69
|
689
|
jpayne@69
|
690 /**
|
jpayne@69
|
691 * Implements ucol_strcollUTF8().
|
jpayne@69
|
692 * @internal
|
jpayne@69
|
693 */
|
jpayne@69
|
694 virtual UCollationResult internalCompareUTF8(
|
jpayne@69
|
695 const char *left, int32_t leftLength,
|
jpayne@69
|
696 const char *right, int32_t rightLength,
|
jpayne@69
|
697 UErrorCode &errorCode) const;
|
jpayne@69
|
698
|
jpayne@69
|
699 /** Get the short definition string for a collator. This internal API harvests the collator's
|
jpayne@69
|
700 * locale and the attribute set and produces a string that can be used for opening
|
jpayne@69
|
701 * a collator with the same attributes using the ucol_openFromShortString API.
|
jpayne@69
|
702 * This string will be normalized.
|
jpayne@69
|
703 * The structure and the syntax of the string is defined in the "Naming collators"
|
jpayne@69
|
704 * section of the users guide:
|
jpayne@69
|
705 * http://userguide.icu-project.org/collation/concepts#TOC-Collator-naming-scheme
|
jpayne@69
|
706 * This function supports preflighting.
|
jpayne@69
|
707 *
|
jpayne@69
|
708 * This is internal, and intended to be used with delegate converters.
|
jpayne@69
|
709 *
|
jpayne@69
|
710 * @param locale a locale that will appear as a collators locale in the resulting
|
jpayne@69
|
711 * short string definition. If NULL, the locale will be harvested
|
jpayne@69
|
712 * from the collator.
|
jpayne@69
|
713 * @param buffer space to hold the resulting string
|
jpayne@69
|
714 * @param capacity capacity of the buffer
|
jpayne@69
|
715 * @param status for returning errors. All the preflighting errors are featured
|
jpayne@69
|
716 * @return length of the resulting string
|
jpayne@69
|
717 * @see ucol_openFromShortString
|
jpayne@69
|
718 * @see ucol_normalizeShortDefinitionString
|
jpayne@69
|
719 * @see ucol_getShortDefinitionString
|
jpayne@69
|
720 * @internal
|
jpayne@69
|
721 */
|
jpayne@69
|
722 virtual int32_t internalGetShortDefinitionString(const char *locale,
|
jpayne@69
|
723 char *buffer,
|
jpayne@69
|
724 int32_t capacity,
|
jpayne@69
|
725 UErrorCode &status) const;
|
jpayne@69
|
726
|
jpayne@69
|
727 /**
|
jpayne@69
|
728 * Implements ucol_nextSortKeyPart().
|
jpayne@69
|
729 * @internal
|
jpayne@69
|
730 */
|
jpayne@69
|
731 virtual int32_t internalNextSortKeyPart(
|
jpayne@69
|
732 UCharIterator *iter, uint32_t state[2],
|
jpayne@69
|
733 uint8_t *dest, int32_t count, UErrorCode &errorCode) const;
|
jpayne@69
|
734
|
jpayne@69
|
735 // Do not enclose the default constructor with #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
736 /**
|
jpayne@69
|
737 * Only for use in ucol_openRules().
|
jpayne@69
|
738 * @internal
|
jpayne@69
|
739 */
|
jpayne@69
|
740 RuleBasedCollator();
|
jpayne@69
|
741
|
jpayne@69
|
742 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
743 /**
|
jpayne@69
|
744 * Implements ucol_getLocaleByType().
|
jpayne@69
|
745 * Needed because the lifetime of the locale ID string must match that of the collator.
|
jpayne@69
|
746 * getLocale() returns a copy of a Locale, with minimal lifetime in a C wrapper.
|
jpayne@69
|
747 * @internal
|
jpayne@69
|
748 */
|
jpayne@69
|
749 const char *internalGetLocaleID(ULocDataLocaleType type, UErrorCode &errorCode) const;
|
jpayne@69
|
750
|
jpayne@69
|
751 /**
|
jpayne@69
|
752 * Implements ucol_getContractionsAndExpansions().
|
jpayne@69
|
753 * Gets this collator's sets of contraction strings and/or
|
jpayne@69
|
754 * characters and strings that map to multiple collation elements (expansions).
|
jpayne@69
|
755 * If addPrefixes is TRUE, then contractions that are expressed as
|
jpayne@69
|
756 * prefix/pre-context rules are included.
|
jpayne@69
|
757 * @param contractions if not NULL, the set to hold the contractions
|
jpayne@69
|
758 * @param expansions if not NULL, the set to hold the expansions
|
jpayne@69
|
759 * @param addPrefixes include prefix contextual mappings
|
jpayne@69
|
760 * @param errorCode in/out ICU error code
|
jpayne@69
|
761 * @internal
|
jpayne@69
|
762 */
|
jpayne@69
|
763 void internalGetContractionsAndExpansions(
|
jpayne@69
|
764 UnicodeSet *contractions, UnicodeSet *expansions,
|
jpayne@69
|
765 UBool addPrefixes, UErrorCode &errorCode) const;
|
jpayne@69
|
766
|
jpayne@69
|
767 /**
|
jpayne@69
|
768 * Adds the contractions that start with character c to the set.
|
jpayne@69
|
769 * Ignores prefixes. Used by AlphabeticIndex.
|
jpayne@69
|
770 * @internal
|
jpayne@69
|
771 */
|
jpayne@69
|
772 void internalAddContractions(UChar32 c, UnicodeSet &set, UErrorCode &errorCode) const;
|
jpayne@69
|
773
|
jpayne@69
|
774 /**
|
jpayne@69
|
775 * Implements from-rule constructors, and ucol_openRules().
|
jpayne@69
|
776 * @internal
|
jpayne@69
|
777 */
|
jpayne@69
|
778 void internalBuildTailoring(
|
jpayne@69
|
779 const UnicodeString &rules,
|
jpayne@69
|
780 int32_t strength,
|
jpayne@69
|
781 UColAttributeValue decompositionMode,
|
jpayne@69
|
782 UParseError *outParseError, UnicodeString *outReason,
|
jpayne@69
|
783 UErrorCode &errorCode);
|
jpayne@69
|
784
|
jpayne@69
|
785 /** @internal */
|
jpayne@69
|
786 static inline RuleBasedCollator *rbcFromUCollator(UCollator *uc) {
|
jpayne@69
|
787 return dynamic_cast<RuleBasedCollator *>(fromUCollator(uc));
|
jpayne@69
|
788 }
|
jpayne@69
|
789 /** @internal */
|
jpayne@69
|
790 static inline const RuleBasedCollator *rbcFromUCollator(const UCollator *uc) {
|
jpayne@69
|
791 return dynamic_cast<const RuleBasedCollator *>(fromUCollator(uc));
|
jpayne@69
|
792 }
|
jpayne@69
|
793
|
jpayne@69
|
794 /**
|
jpayne@69
|
795 * Appends the CEs for the string to the vector.
|
jpayne@69
|
796 * @internal for tests & tools
|
jpayne@69
|
797 */
|
jpayne@69
|
798 void internalGetCEs(const UnicodeString &str, UVector64 &ces, UErrorCode &errorCode) const;
|
jpayne@69
|
799 #endif // U_HIDE_INTERNAL_API
|
jpayne@69
|
800
|
jpayne@69
|
801 protected:
|
jpayne@69
|
802 /**
|
jpayne@69
|
803 * Used internally by registration to define the requested and valid locales.
|
jpayne@69
|
804 * @param requestedLocale the requested locale
|
jpayne@69
|
805 * @param validLocale the valid locale
|
jpayne@69
|
806 * @param actualLocale the actual locale
|
jpayne@69
|
807 * @internal
|
jpayne@69
|
808 */
|
jpayne@69
|
809 virtual void setLocales(const Locale& requestedLocale, const Locale& validLocale, const Locale& actualLocale);
|
jpayne@69
|
810
|
jpayne@69
|
811 private:
|
jpayne@69
|
812 friend class CollationElementIterator;
|
jpayne@69
|
813 friend class Collator;
|
jpayne@69
|
814
|
jpayne@69
|
815 RuleBasedCollator(const CollationCacheEntry *entry);
|
jpayne@69
|
816
|
jpayne@69
|
817 /**
|
jpayne@69
|
818 * Enumeration of attributes that are relevant for short definition strings
|
jpayne@69
|
819 * (e.g., ucol_getShortDefinitionString()).
|
jpayne@69
|
820 * Effectively extends UColAttribute.
|
jpayne@69
|
821 */
|
jpayne@69
|
822 enum Attributes {
|
jpayne@69
|
823 ATTR_VARIABLE_TOP = UCOL_ATTRIBUTE_COUNT,
|
jpayne@69
|
824 ATTR_LIMIT
|
jpayne@69
|
825 };
|
jpayne@69
|
826
|
jpayne@69
|
827 void adoptTailoring(CollationTailoring *t, UErrorCode &errorCode);
|
jpayne@69
|
828
|
jpayne@69
|
829 // Both lengths must be <0 or else both must be >=0.
|
jpayne@69
|
830 UCollationResult doCompare(const char16_t *left, int32_t leftLength,
|
jpayne@69
|
831 const char16_t *right, int32_t rightLength,
|
jpayne@69
|
832 UErrorCode &errorCode) const;
|
jpayne@69
|
833 UCollationResult doCompare(const uint8_t *left, int32_t leftLength,
|
jpayne@69
|
834 const uint8_t *right, int32_t rightLength,
|
jpayne@69
|
835 UErrorCode &errorCode) const;
|
jpayne@69
|
836
|
jpayne@69
|
837 void writeSortKey(const char16_t *s, int32_t length,
|
jpayne@69
|
838 SortKeyByteSink &sink, UErrorCode &errorCode) const;
|
jpayne@69
|
839
|
jpayne@69
|
840 void writeIdenticalLevel(const char16_t *s, const char16_t *limit,
|
jpayne@69
|
841 SortKeyByteSink &sink, UErrorCode &errorCode) const;
|
jpayne@69
|
842
|
jpayne@69
|
843 const CollationSettings &getDefaultSettings() const;
|
jpayne@69
|
844
|
jpayne@69
|
845 void setAttributeDefault(int32_t attribute) {
|
jpayne@69
|
846 explicitlySetAttributes &= ~((uint32_t)1 << attribute);
|
jpayne@69
|
847 }
|
jpayne@69
|
848 void setAttributeExplicitly(int32_t attribute) {
|
jpayne@69
|
849 explicitlySetAttributes |= (uint32_t)1 << attribute;
|
jpayne@69
|
850 }
|
jpayne@69
|
851 UBool attributeHasBeenSetExplicitly(int32_t attribute) const {
|
jpayne@69
|
852 // assert(0 <= attribute < ATTR_LIMIT);
|
jpayne@69
|
853 return (UBool)((explicitlySetAttributes & ((uint32_t)1 << attribute)) != 0);
|
jpayne@69
|
854 }
|
jpayne@69
|
855
|
jpayne@69
|
856 /**
|
jpayne@69
|
857 * Tests whether a character is "unsafe" for use as a collation starting point.
|
jpayne@69
|
858 *
|
jpayne@69
|
859 * @param c code point or code unit
|
jpayne@69
|
860 * @return TRUE if c is unsafe
|
jpayne@69
|
861 * @see CollationElementIterator#setOffset(int)
|
jpayne@69
|
862 */
|
jpayne@69
|
863 UBool isUnsafe(UChar32 c) const;
|
jpayne@69
|
864
|
jpayne@69
|
865 static void U_CALLCONV computeMaxExpansions(const CollationTailoring *t, UErrorCode &errorCode);
|
jpayne@69
|
866 UBool initMaxExpansions(UErrorCode &errorCode) const;
|
jpayne@69
|
867
|
jpayne@69
|
868 void setFastLatinOptions(CollationSettings &ownedSettings) const;
|
jpayne@69
|
869
|
jpayne@69
|
870 const CollationData *data;
|
jpayne@69
|
871 const CollationSettings *settings; // reference-counted
|
jpayne@69
|
872 const CollationTailoring *tailoring; // alias of cacheEntry->tailoring
|
jpayne@69
|
873 const CollationCacheEntry *cacheEntry; // reference-counted
|
jpayne@69
|
874 Locale validLocale;
|
jpayne@69
|
875 uint32_t explicitlySetAttributes;
|
jpayne@69
|
876
|
jpayne@69
|
877 UBool actualLocaleIsSameAsValid;
|
jpayne@69
|
878 };
|
jpayne@69
|
879
|
jpayne@69
|
880 U_NAMESPACE_END
|
jpayne@69
|
881
|
jpayne@69
|
882 #endif // !UCONFIG_NO_COLLATION
|
jpayne@69
|
883
|
jpayne@69
|
884 #endif /* U_SHOW_CPLUSPLUS_API */
|
jpayne@69
|
885
|
jpayne@69
|
886 #endif // TBLCOLL_H
|