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