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