Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ****************************************************************************** |
michael@0 | 3 | * Copyright (C) 1996-2013, International Business Machines Corporation and |
michael@0 | 4 | * others. All Rights Reserved. |
michael@0 | 5 | ****************************************************************************** |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | /** |
michael@0 | 9 | * \file |
michael@0 | 10 | * \brief C++ API: RuleBasedCollator class provides the simple implementation of Collator. |
michael@0 | 11 | */ |
michael@0 | 12 | |
michael@0 | 13 | /** |
michael@0 | 14 | * File tblcoll.h |
michael@0 | 15 | * |
michael@0 | 16 | * Created by: Helena Shih |
michael@0 | 17 | * |
michael@0 | 18 | * Modification History: |
michael@0 | 19 | * |
michael@0 | 20 | * Date Name Description |
michael@0 | 21 | * 2/5/97 aliu Added streamIn and streamOut methods. Added |
michael@0 | 22 | * constructor which reads RuleBasedCollator object from |
michael@0 | 23 | * a binary file. Added writeToFile method which streams |
michael@0 | 24 | * RuleBasedCollator out to a binary file. The streamIn |
michael@0 | 25 | * and streamOut methods use istream and ostream objects |
michael@0 | 26 | * in binary mode. |
michael@0 | 27 | * 2/12/97 aliu Modified to use TableCollationData sub-object to |
michael@0 | 28 | * hold invariant data. |
michael@0 | 29 | * 2/13/97 aliu Moved several methods into this class from Collation. |
michael@0 | 30 | * Added a private RuleBasedCollator(Locale&) constructor, |
michael@0 | 31 | * to be used by Collator::createDefault(). General |
michael@0 | 32 | * clean up. |
michael@0 | 33 | * 2/20/97 helena Added clone, operator==, operator!=, operator=, and copy |
michael@0 | 34 | * constructor and getDynamicClassID. |
michael@0 | 35 | * 3/5/97 aliu Modified constructFromFile() to add parameter |
michael@0 | 36 | * specifying whether or not binary loading is to be |
michael@0 | 37 | * attempted. This is required for dynamic rule loading. |
michael@0 | 38 | * 05/07/97 helena Added memory allocation error detection. |
michael@0 | 39 | * 6/17/97 helena Added IDENTICAL strength for compare, changed getRules to |
michael@0 | 40 | * use MergeCollation::getPattern. |
michael@0 | 41 | * 6/20/97 helena Java class name change. |
michael@0 | 42 | * 8/18/97 helena Added internal API documentation. |
michael@0 | 43 | * 09/03/97 helena Added createCollationKeyValues(). |
michael@0 | 44 | * 02/10/98 damiba Added compare with "length" parameter |
michael@0 | 45 | * 08/05/98 erm Synched with 1.2 version of RuleBasedCollator.java |
michael@0 | 46 | * 04/23/99 stephen Removed EDecompositionMode, merged with |
michael@0 | 47 | * Normalizer::EMode |
michael@0 | 48 | * 06/14/99 stephen Removed kResourceBundleSuffix |
michael@0 | 49 | * 11/02/99 helena Collator performance enhancements. Eliminates the |
michael@0 | 50 | * UnicodeString construction and special case for NO_OP. |
michael@0 | 51 | * 11/23/99 srl More performance enhancements. Updates to NormalizerIterator |
michael@0 | 52 | * internal state management. |
michael@0 | 53 | * 12/15/99 aliu Update to support Thai collation. Move NormalizerIterator |
michael@0 | 54 | * to implementation file. |
michael@0 | 55 | * 01/29/01 synwee Modified into a C++ wrapper which calls C API |
michael@0 | 56 | * (ucol.h) |
michael@0 | 57 | */ |
michael@0 | 58 | |
michael@0 | 59 | #ifndef TBLCOLL_H |
michael@0 | 60 | #define TBLCOLL_H |
michael@0 | 61 | |
michael@0 | 62 | #include "unicode/utypes.h" |
michael@0 | 63 | |
michael@0 | 64 | |
michael@0 | 65 | #if !UCONFIG_NO_COLLATION |
michael@0 | 66 | |
michael@0 | 67 | #include "unicode/coll.h" |
michael@0 | 68 | #include "unicode/ucol.h" |
michael@0 | 69 | #include "unicode/sortkey.h" |
michael@0 | 70 | #include "unicode/normlzr.h" |
michael@0 | 71 | |
michael@0 | 72 | U_NAMESPACE_BEGIN |
michael@0 | 73 | |
michael@0 | 74 | /** |
michael@0 | 75 | * @stable ICU 2.0 |
michael@0 | 76 | */ |
michael@0 | 77 | class StringSearch; |
michael@0 | 78 | /** |
michael@0 | 79 | * @stable ICU 2.0 |
michael@0 | 80 | */ |
michael@0 | 81 | class CollationElementIterator; |
michael@0 | 82 | |
michael@0 | 83 | /** |
michael@0 | 84 | * The RuleBasedCollator class provides the simple implementation of |
michael@0 | 85 | * Collator, using data-driven tables. The user can create a customized |
michael@0 | 86 | * table-based collation. |
michael@0 | 87 | * <P> |
michael@0 | 88 | * <em>Important: </em>The ICU collation service has been reimplemented |
michael@0 | 89 | * in order to achieve better performance and UCA compliance. |
michael@0 | 90 | * For details, see the |
michael@0 | 91 | * <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm"> |
michael@0 | 92 | * collation design document</a>. |
michael@0 | 93 | * <p> |
michael@0 | 94 | * RuleBasedCollator is a thin C++ wrapper over the C implementation. |
michael@0 | 95 | * <p> |
michael@0 | 96 | * For more information about the collation service see |
michael@0 | 97 | * <a href="http://icu-project.org/userguide/Collate_Intro.html">the users guide</a>. |
michael@0 | 98 | * <p> |
michael@0 | 99 | * Collation service provides correct sorting orders for most locales supported in ICU. |
michael@0 | 100 | * If specific data for a locale is not available, the orders eventually falls back |
michael@0 | 101 | * to the <a href="http://www.unicode.org/unicode/reports/tr10/">UCA sort order</a>. |
michael@0 | 102 | * <p> |
michael@0 | 103 | * Sort ordering may be customized by providing your own set of rules. For more on |
michael@0 | 104 | * this subject see the <a href="http://icu-project.org/userguide/Collate_Customization.html"> |
michael@0 | 105 | * Collation customization</a> section of the users guide. |
michael@0 | 106 | * <p> |
michael@0 | 107 | * Note, RuleBasedCollator is not to be subclassed. |
michael@0 | 108 | * @see Collator |
michael@0 | 109 | * @version 2.0 11/15/2001 |
michael@0 | 110 | */ |
michael@0 | 111 | class U_I18N_API RuleBasedCollator : public Collator |
michael@0 | 112 | { |
michael@0 | 113 | public: |
michael@0 | 114 | |
michael@0 | 115 | // constructor ------------------------------------------------------------- |
michael@0 | 116 | |
michael@0 | 117 | /** |
michael@0 | 118 | * RuleBasedCollator constructor. This takes the table rules and builds a |
michael@0 | 119 | * collation table out of them. Please see RuleBasedCollator class |
michael@0 | 120 | * description for more details on the collation rule syntax. |
michael@0 | 121 | * @param rules the collation rules to build the collation table from. |
michael@0 | 122 | * @param status reporting a success or an error. |
michael@0 | 123 | * @see Locale |
michael@0 | 124 | * @stable ICU 2.0 |
michael@0 | 125 | */ |
michael@0 | 126 | RuleBasedCollator(const UnicodeString& rules, UErrorCode& status); |
michael@0 | 127 | |
michael@0 | 128 | /** |
michael@0 | 129 | * RuleBasedCollator constructor. This takes the table rules and builds a |
michael@0 | 130 | * collation table out of them. Please see RuleBasedCollator class |
michael@0 | 131 | * description for more details on the collation rule syntax. |
michael@0 | 132 | * @param rules the collation rules to build the collation table from. |
michael@0 | 133 | * @param collationStrength default strength for comparison |
michael@0 | 134 | * @param status reporting a success or an error. |
michael@0 | 135 | * @see Locale |
michael@0 | 136 | * @stable ICU 2.0 |
michael@0 | 137 | */ |
michael@0 | 138 | RuleBasedCollator(const UnicodeString& rules, |
michael@0 | 139 | ECollationStrength collationStrength, |
michael@0 | 140 | UErrorCode& status); |
michael@0 | 141 | |
michael@0 | 142 | /** |
michael@0 | 143 | * RuleBasedCollator constructor. This takes the table rules and builds a |
michael@0 | 144 | * collation table out of them. Please see RuleBasedCollator class |
michael@0 | 145 | * description for more details on the collation rule syntax. |
michael@0 | 146 | * @param rules the collation rules to build the collation table from. |
michael@0 | 147 | * @param decompositionMode the normalisation mode |
michael@0 | 148 | * @param status reporting a success or an error. |
michael@0 | 149 | * @see Locale |
michael@0 | 150 | * @stable ICU 2.0 |
michael@0 | 151 | */ |
michael@0 | 152 | RuleBasedCollator(const UnicodeString& rules, |
michael@0 | 153 | UColAttributeValue decompositionMode, |
michael@0 | 154 | UErrorCode& status); |
michael@0 | 155 | |
michael@0 | 156 | /** |
michael@0 | 157 | * RuleBasedCollator constructor. This takes the table rules and builds a |
michael@0 | 158 | * collation table out of them. Please see RuleBasedCollator class |
michael@0 | 159 | * description for more details on the collation rule syntax. |
michael@0 | 160 | * @param rules the collation rules to build the collation table from. |
michael@0 | 161 | * @param collationStrength default strength for comparison |
michael@0 | 162 | * @param decompositionMode the normalisation mode |
michael@0 | 163 | * @param status reporting a success or an error. |
michael@0 | 164 | * @see Locale |
michael@0 | 165 | * @stable ICU 2.0 |
michael@0 | 166 | */ |
michael@0 | 167 | RuleBasedCollator(const UnicodeString& rules, |
michael@0 | 168 | ECollationStrength collationStrength, |
michael@0 | 169 | UColAttributeValue decompositionMode, |
michael@0 | 170 | UErrorCode& status); |
michael@0 | 171 | |
michael@0 | 172 | /** |
michael@0 | 173 | * Copy constructor. |
michael@0 | 174 | * @param other the RuleBasedCollator object to be copied |
michael@0 | 175 | * @see Locale |
michael@0 | 176 | * @stable ICU 2.0 |
michael@0 | 177 | */ |
michael@0 | 178 | RuleBasedCollator(const RuleBasedCollator& other); |
michael@0 | 179 | |
michael@0 | 180 | |
michael@0 | 181 | /** Opens a collator from a collator binary image created using |
michael@0 | 182 | * cloneBinary. Binary image used in instantiation of the |
michael@0 | 183 | * collator remains owned by the user and should stay around for |
michael@0 | 184 | * the lifetime of the collator. The API also takes a base collator |
michael@0 | 185 | * which usualy should be UCA. |
michael@0 | 186 | * @param bin binary image owned by the user and required through the |
michael@0 | 187 | * lifetime of the collator |
michael@0 | 188 | * @param length size of the image. If negative, the API will try to |
michael@0 | 189 | * figure out the length of the image |
michael@0 | 190 | * @param base fallback collator, usually UCA. Base is required to be |
michael@0 | 191 | * present through the lifetime of the collator. Currently |
michael@0 | 192 | * it cannot be NULL. |
michael@0 | 193 | * @param status for catching errors |
michael@0 | 194 | * @return newly created collator |
michael@0 | 195 | * @see cloneBinary |
michael@0 | 196 | * @stable ICU 3.4 |
michael@0 | 197 | */ |
michael@0 | 198 | RuleBasedCollator(const uint8_t *bin, int32_t length, |
michael@0 | 199 | const RuleBasedCollator *base, |
michael@0 | 200 | UErrorCode &status); |
michael@0 | 201 | // destructor -------------------------------------------------------------- |
michael@0 | 202 | |
michael@0 | 203 | /** |
michael@0 | 204 | * Destructor. |
michael@0 | 205 | * @stable ICU 2.0 |
michael@0 | 206 | */ |
michael@0 | 207 | virtual ~RuleBasedCollator(); |
michael@0 | 208 | |
michael@0 | 209 | // public methods ---------------------------------------------------------- |
michael@0 | 210 | |
michael@0 | 211 | /** |
michael@0 | 212 | * Assignment operator. |
michael@0 | 213 | * @param other other RuleBasedCollator object to compare with. |
michael@0 | 214 | * @stable ICU 2.0 |
michael@0 | 215 | */ |
michael@0 | 216 | RuleBasedCollator& operator=(const RuleBasedCollator& other); |
michael@0 | 217 | |
michael@0 | 218 | /** |
michael@0 | 219 | * Returns true if argument is the same as this object. |
michael@0 | 220 | * @param other Collator object to be compared. |
michael@0 | 221 | * @return true if arguments is the same as this object. |
michael@0 | 222 | * @stable ICU 2.0 |
michael@0 | 223 | */ |
michael@0 | 224 | virtual UBool operator==(const Collator& other) const; |
michael@0 | 225 | |
michael@0 | 226 | /** |
michael@0 | 227 | * Makes a copy of this object. |
michael@0 | 228 | * @return a copy of this object, owned by the caller |
michael@0 | 229 | * @stable ICU 2.0 |
michael@0 | 230 | */ |
michael@0 | 231 | virtual Collator* clone(void) const; |
michael@0 | 232 | |
michael@0 | 233 | /** |
michael@0 | 234 | * Creates a collation element iterator for the source string. The caller of |
michael@0 | 235 | * this method is responsible for the memory management of the return |
michael@0 | 236 | * pointer. |
michael@0 | 237 | * @param source the string over which the CollationElementIterator will |
michael@0 | 238 | * iterate. |
michael@0 | 239 | * @return the collation element iterator of the source string using this as |
michael@0 | 240 | * the based Collator. |
michael@0 | 241 | * @stable ICU 2.2 |
michael@0 | 242 | */ |
michael@0 | 243 | virtual CollationElementIterator* createCollationElementIterator( |
michael@0 | 244 | const UnicodeString& source) const; |
michael@0 | 245 | |
michael@0 | 246 | /** |
michael@0 | 247 | * Creates a collation element iterator for the source. The caller of this |
michael@0 | 248 | * method is responsible for the memory management of the returned pointer. |
michael@0 | 249 | * @param source the CharacterIterator which produces the characters over |
michael@0 | 250 | * which the CollationElementItgerator will iterate. |
michael@0 | 251 | * @return the collation element iterator of the source using this as the |
michael@0 | 252 | * based Collator. |
michael@0 | 253 | * @stable ICU 2.2 |
michael@0 | 254 | */ |
michael@0 | 255 | virtual CollationElementIterator* createCollationElementIterator( |
michael@0 | 256 | const CharacterIterator& source) const; |
michael@0 | 257 | |
michael@0 | 258 | // Make deprecated versions of Collator::compare() visible. |
michael@0 | 259 | using Collator::compare; |
michael@0 | 260 | |
michael@0 | 261 | /** |
michael@0 | 262 | * The comparison function compares the character data stored in two |
michael@0 | 263 | * different strings. Returns information about whether a string is less |
michael@0 | 264 | * than, greater than or equal to another string. |
michael@0 | 265 | * @param source the source string to be compared with. |
michael@0 | 266 | * @param target the string that is to be compared with the source string. |
michael@0 | 267 | * @param status possible error code |
michael@0 | 268 | * @return Returns an enum value. UCOL_GREATER if source is greater |
michael@0 | 269 | * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less |
michael@0 | 270 | * than target |
michael@0 | 271 | * @stable ICU 2.6 |
michael@0 | 272 | **/ |
michael@0 | 273 | virtual UCollationResult compare(const UnicodeString& source, |
michael@0 | 274 | const UnicodeString& target, |
michael@0 | 275 | UErrorCode &status) const; |
michael@0 | 276 | |
michael@0 | 277 | /** |
michael@0 | 278 | * Does the same thing as compare but limits the comparison to a specified |
michael@0 | 279 | * length |
michael@0 | 280 | * @param source the source string to be compared with. |
michael@0 | 281 | * @param target the string that is to be compared with the source string. |
michael@0 | 282 | * @param length the length the comparison is limited to |
michael@0 | 283 | * @param status possible error code |
michael@0 | 284 | * @return Returns an enum value. UCOL_GREATER if source (up to the specified |
michael@0 | 285 | * length) is greater than target; UCOL_EQUAL if source (up to specified |
michael@0 | 286 | * length) is equal to target; UCOL_LESS if source (up to the specified |
michael@0 | 287 | * length) is less than target. |
michael@0 | 288 | * @stable ICU 2.6 |
michael@0 | 289 | */ |
michael@0 | 290 | virtual UCollationResult compare(const UnicodeString& source, |
michael@0 | 291 | const UnicodeString& target, |
michael@0 | 292 | int32_t length, |
michael@0 | 293 | UErrorCode &status) const; |
michael@0 | 294 | |
michael@0 | 295 | /** |
michael@0 | 296 | * The comparison function compares the character data stored in two |
michael@0 | 297 | * different string arrays. Returns information about whether a string array |
michael@0 | 298 | * is less than, greater than or equal to another string array. |
michael@0 | 299 | * @param source the source string array to be compared with. |
michael@0 | 300 | * @param sourceLength the length of the source string array. If this value |
michael@0 | 301 | * is equal to -1, the string array is null-terminated. |
michael@0 | 302 | * @param target the string that is to be compared with the source string. |
michael@0 | 303 | * @param targetLength the length of the target string array. If this value |
michael@0 | 304 | * is equal to -1, the string array is null-terminated. |
michael@0 | 305 | * @param status possible error code |
michael@0 | 306 | * @return Returns an enum value. UCOL_GREATER if source is greater |
michael@0 | 307 | * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less |
michael@0 | 308 | * than target |
michael@0 | 309 | * @stable ICU 2.6 |
michael@0 | 310 | */ |
michael@0 | 311 | virtual UCollationResult compare(const UChar* source, int32_t sourceLength, |
michael@0 | 312 | const UChar* target, int32_t targetLength, |
michael@0 | 313 | UErrorCode &status) const; |
michael@0 | 314 | |
michael@0 | 315 | /** |
michael@0 | 316 | * Compares two strings using the Collator. |
michael@0 | 317 | * Returns whether the first one compares less than/equal to/greater than |
michael@0 | 318 | * the second one. |
michael@0 | 319 | * This version takes UCharIterator input. |
michael@0 | 320 | * @param sIter the first ("source") string iterator |
michael@0 | 321 | * @param tIter the second ("target") string iterator |
michael@0 | 322 | * @param status ICU status |
michael@0 | 323 | * @return UCOL_LESS, UCOL_EQUAL or UCOL_GREATER |
michael@0 | 324 | * @stable ICU 4.2 |
michael@0 | 325 | */ |
michael@0 | 326 | virtual UCollationResult compare(UCharIterator &sIter, |
michael@0 | 327 | UCharIterator &tIter, |
michael@0 | 328 | UErrorCode &status) const; |
michael@0 | 329 | |
michael@0 | 330 | /** |
michael@0 | 331 | * Transforms a specified region of the string into a series of characters |
michael@0 | 332 | * that can be compared with CollationKey.compare. Use a CollationKey when |
michael@0 | 333 | * you need to do repeated comparisions on the same string. For a single |
michael@0 | 334 | * comparison the compare method will be faster. |
michael@0 | 335 | * @param source the source string. |
michael@0 | 336 | * @param key the transformed key of the source string. |
michael@0 | 337 | * @param status the error code status. |
michael@0 | 338 | * @return the transformed key. |
michael@0 | 339 | * @see CollationKey |
michael@0 | 340 | * @stable ICU 2.0 |
michael@0 | 341 | */ |
michael@0 | 342 | virtual CollationKey& getCollationKey(const UnicodeString& source, |
michael@0 | 343 | CollationKey& key, |
michael@0 | 344 | UErrorCode& status) const; |
michael@0 | 345 | |
michael@0 | 346 | /** |
michael@0 | 347 | * Transforms a specified region of the string into a series of characters |
michael@0 | 348 | * that can be compared with CollationKey.compare. Use a CollationKey when |
michael@0 | 349 | * you need to do repeated comparisions on the same string. For a single |
michael@0 | 350 | * comparison the compare method will be faster. |
michael@0 | 351 | * @param source the source string. |
michael@0 | 352 | * @param sourceLength the length of the source string. |
michael@0 | 353 | * @param key the transformed key of the source string. |
michael@0 | 354 | * @param status the error code status. |
michael@0 | 355 | * @return the transformed key. |
michael@0 | 356 | * @see CollationKey |
michael@0 | 357 | * @stable ICU 2.0 |
michael@0 | 358 | */ |
michael@0 | 359 | virtual CollationKey& getCollationKey(const UChar *source, |
michael@0 | 360 | int32_t sourceLength, |
michael@0 | 361 | CollationKey& key, |
michael@0 | 362 | UErrorCode& status) const; |
michael@0 | 363 | |
michael@0 | 364 | /** |
michael@0 | 365 | * Generates the hash code for the rule-based collation object. |
michael@0 | 366 | * @return the hash code. |
michael@0 | 367 | * @stable ICU 2.0 |
michael@0 | 368 | */ |
michael@0 | 369 | virtual int32_t hashCode(void) const; |
michael@0 | 370 | |
michael@0 | 371 | /** |
michael@0 | 372 | * Gets the locale of the Collator |
michael@0 | 373 | * @param type can be either requested, valid or actual locale. For more |
michael@0 | 374 | * information see the definition of ULocDataLocaleType in |
michael@0 | 375 | * uloc.h |
michael@0 | 376 | * @param status the error code status. |
michael@0 | 377 | * @return locale where the collation data lives. If the collator |
michael@0 | 378 | * was instantiated from rules, locale is empty. |
michael@0 | 379 | * @deprecated ICU 2.8 likely to change in ICU 3.0, based on feedback |
michael@0 | 380 | */ |
michael@0 | 381 | virtual Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const; |
michael@0 | 382 | |
michael@0 | 383 | /** |
michael@0 | 384 | * Gets the tailoring rules for this collator. |
michael@0 | 385 | * @return the collation tailoring from which this collator was created |
michael@0 | 386 | * @stable ICU 2.0 |
michael@0 | 387 | */ |
michael@0 | 388 | const UnicodeString& getRules(void) const; |
michael@0 | 389 | |
michael@0 | 390 | /** |
michael@0 | 391 | * Gets the version information for a Collator. |
michael@0 | 392 | * @param info the version # information, the result will be filled in |
michael@0 | 393 | * @stable ICU 2.0 |
michael@0 | 394 | */ |
michael@0 | 395 | virtual void getVersion(UVersionInfo info) const; |
michael@0 | 396 | |
michael@0 | 397 | #ifndef U_HIDE_DEPRECATED_API |
michael@0 | 398 | /** |
michael@0 | 399 | * Returns the maximum length of any expansion sequences that end with the |
michael@0 | 400 | * specified comparison order. |
michael@0 | 401 | * |
michael@0 | 402 | * This is specific to the kind of collation element values and sequences |
michael@0 | 403 | * returned by the CollationElementIterator. |
michael@0 | 404 | * Call CollationElementIterator::getMaxExpansion() instead. |
michael@0 | 405 | * |
michael@0 | 406 | * @param order a collation order returned by CollationElementIterator::previous |
michael@0 | 407 | * or CollationElementIterator::next. |
michael@0 | 408 | * @return maximum size of the expansion sequences ending with the collation |
michael@0 | 409 | * element, or 1 if the collation element does not occur at the end of |
michael@0 | 410 | * any expansion sequence |
michael@0 | 411 | * @see CollationElementIterator#getMaxExpansion |
michael@0 | 412 | * @deprecated ICU 51 Use CollationElementIterator::getMaxExpansion() instead. |
michael@0 | 413 | */ |
michael@0 | 414 | int32_t getMaxExpansion(int32_t order) const; |
michael@0 | 415 | #endif /* U_HIDE_DEPRECATED_API */ |
michael@0 | 416 | |
michael@0 | 417 | /** |
michael@0 | 418 | * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This |
michael@0 | 419 | * method is to implement a simple version of RTTI, since not all C++ |
michael@0 | 420 | * compilers support genuine RTTI. Polymorphic operator==() and clone() |
michael@0 | 421 | * methods call this method. |
michael@0 | 422 | * @return The class ID for this object. All objects of a given class have |
michael@0 | 423 | * the same class ID. Objects of other classes have different class |
michael@0 | 424 | * IDs. |
michael@0 | 425 | * @stable ICU 2.0 |
michael@0 | 426 | */ |
michael@0 | 427 | virtual UClassID getDynamicClassID(void) const; |
michael@0 | 428 | |
michael@0 | 429 | /** |
michael@0 | 430 | * Returns the class ID for this class. This is useful only for comparing to |
michael@0 | 431 | * a return value from getDynamicClassID(). For example: |
michael@0 | 432 | * <pre> |
michael@0 | 433 | * Base* polymorphic_pointer = createPolymorphicObject(); |
michael@0 | 434 | * if (polymorphic_pointer->getDynamicClassID() == |
michael@0 | 435 | * Derived::getStaticClassID()) ... |
michael@0 | 436 | * </pre> |
michael@0 | 437 | * @return The class ID for all objects of this class. |
michael@0 | 438 | * @stable ICU 2.0 |
michael@0 | 439 | */ |
michael@0 | 440 | static UClassID U_EXPORT2 getStaticClassID(void); |
michael@0 | 441 | |
michael@0 | 442 | #ifndef U_HIDE_DEPRECATED_API |
michael@0 | 443 | /** |
michael@0 | 444 | * Do not use this method: The caller and the ICU library might use different heaps. |
michael@0 | 445 | * Use cloneBinary() instead which writes to caller-provided memory. |
michael@0 | 446 | * |
michael@0 | 447 | * Returns a binary format of this collator. |
michael@0 | 448 | * @param length Returns the length of the data, in bytes |
michael@0 | 449 | * @param status the error code status. |
michael@0 | 450 | * @return memory, owned by the caller, of size 'length' bytes. |
michael@0 | 451 | * @deprecated ICU 52. Use cloneBinary() instead. |
michael@0 | 452 | */ |
michael@0 | 453 | uint8_t *cloneRuleData(int32_t &length, UErrorCode &status); |
michael@0 | 454 | #endif /* U_HIDE_DEPRECATED_API */ |
michael@0 | 455 | |
michael@0 | 456 | /** Creates a binary image of a collator. This binary image can be stored and |
michael@0 | 457 | * later used to instantiate a collator using ucol_openBinary. |
michael@0 | 458 | * This API supports preflighting. |
michael@0 | 459 | * @param buffer a fill-in buffer to receive the binary image |
michael@0 | 460 | * @param capacity capacity of the destination buffer |
michael@0 | 461 | * @param status for catching errors |
michael@0 | 462 | * @return size of the image |
michael@0 | 463 | * @see ucol_openBinary |
michael@0 | 464 | * @stable ICU 3.4 |
michael@0 | 465 | */ |
michael@0 | 466 | int32_t cloneBinary(uint8_t *buffer, int32_t capacity, UErrorCode &status); |
michael@0 | 467 | |
michael@0 | 468 | /** |
michael@0 | 469 | * Returns current rules. Delta defines whether full rules are returned or |
michael@0 | 470 | * just the tailoring. |
michael@0 | 471 | * |
michael@0 | 472 | * getRules(void) should normally be used instead. |
michael@0 | 473 | * See http://userguide.icu-project.org/collation/customization#TOC-Building-on-Existing-Locales |
michael@0 | 474 | * @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES. |
michael@0 | 475 | * @param buffer UnicodeString to store the result rules |
michael@0 | 476 | * @stable ICU 2.2 |
michael@0 | 477 | * @see UCOL_FULL_RULES |
michael@0 | 478 | */ |
michael@0 | 479 | void getRules(UColRuleOption delta, UnicodeString &buffer); |
michael@0 | 480 | |
michael@0 | 481 | /** |
michael@0 | 482 | * Universal attribute setter |
michael@0 | 483 | * @param attr attribute type |
michael@0 | 484 | * @param value attribute value |
michael@0 | 485 | * @param status to indicate whether the operation went on smoothly or there were errors |
michael@0 | 486 | * @stable ICU 2.2 |
michael@0 | 487 | */ |
michael@0 | 488 | virtual void setAttribute(UColAttribute attr, UColAttributeValue value, |
michael@0 | 489 | UErrorCode &status); |
michael@0 | 490 | |
michael@0 | 491 | /** |
michael@0 | 492 | * Universal attribute getter. |
michael@0 | 493 | * @param attr attribute type |
michael@0 | 494 | * @param status to indicate whether the operation went on smoothly or there were errors |
michael@0 | 495 | * @return attribute value |
michael@0 | 496 | * @stable ICU 2.2 |
michael@0 | 497 | */ |
michael@0 | 498 | virtual UColAttributeValue getAttribute(UColAttribute attr, |
michael@0 | 499 | UErrorCode &status) const; |
michael@0 | 500 | |
michael@0 | 501 | /** |
michael@0 | 502 | * Sets the variable top to a collation element value of a string supplied. |
michael@0 | 503 | * @param varTop one or more (if contraction) UChars to which the variable top should be set |
michael@0 | 504 | * @param len length of variable top string. If -1 it is considered to be zero terminated. |
michael@0 | 505 | * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br> |
michael@0 | 506 | * U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such a contraction<br> |
michael@0 | 507 | * U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes |
michael@0 | 508 | * @return a 32 bit value containing the value of the variable top in upper 16 bits. Lower 16 bits are undefined |
michael@0 | 509 | * @stable ICU 2.0 |
michael@0 | 510 | */ |
michael@0 | 511 | virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status); |
michael@0 | 512 | |
michael@0 | 513 | /** |
michael@0 | 514 | * Sets the variable top to a collation element value of a string supplied. |
michael@0 | 515 | * @param varTop an UnicodeString size 1 or more (if contraction) of UChars to which the variable top should be set |
michael@0 | 516 | * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br> |
michael@0 | 517 | * U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such a contraction<br> |
michael@0 | 518 | * U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes |
michael@0 | 519 | * @return a 32 bit value containing the value of the variable top in upper 16 bits. Lower 16 bits are undefined |
michael@0 | 520 | * @stable ICU 2.0 |
michael@0 | 521 | */ |
michael@0 | 522 | virtual uint32_t setVariableTop(const UnicodeString &varTop, UErrorCode &status); |
michael@0 | 523 | |
michael@0 | 524 | /** |
michael@0 | 525 | * Sets the variable top to a collation element value supplied. Variable top is set to the upper 16 bits. |
michael@0 | 526 | * Lower 16 bits are ignored. |
michael@0 | 527 | * @param varTop CE value, as returned by setVariableTop or ucol)getVariableTop |
michael@0 | 528 | * @param status error code (not changed by function) |
michael@0 | 529 | * @stable ICU 2.0 |
michael@0 | 530 | */ |
michael@0 | 531 | virtual void setVariableTop(uint32_t varTop, UErrorCode &status); |
michael@0 | 532 | |
michael@0 | 533 | /** |
michael@0 | 534 | * Gets the variable top value of a Collator. |
michael@0 | 535 | * Lower 16 bits are undefined and should be ignored. |
michael@0 | 536 | * @param status error code (not changed by function). If error code is set, the return value is undefined. |
michael@0 | 537 | * @stable ICU 2.0 |
michael@0 | 538 | */ |
michael@0 | 539 | virtual uint32_t getVariableTop(UErrorCode &status) const; |
michael@0 | 540 | |
michael@0 | 541 | /** |
michael@0 | 542 | * Get an UnicodeSet that contains all the characters and sequences tailored in |
michael@0 | 543 | * this collator. |
michael@0 | 544 | * @param status error code of the operation |
michael@0 | 545 | * @return a pointer to a UnicodeSet object containing all the |
michael@0 | 546 | * code points and sequences that may sort differently than |
michael@0 | 547 | * in the UCA. The object must be disposed of by using delete |
michael@0 | 548 | * @stable ICU 2.4 |
michael@0 | 549 | */ |
michael@0 | 550 | virtual UnicodeSet *getTailoredSet(UErrorCode &status) const; |
michael@0 | 551 | |
michael@0 | 552 | /** |
michael@0 | 553 | * Get the sort key as an array of bytes from an UnicodeString. |
michael@0 | 554 | * @param source string to be processed. |
michael@0 | 555 | * @param result buffer to store result in. If NULL, number of bytes needed |
michael@0 | 556 | * will be returned. |
michael@0 | 557 | * @param resultLength length of the result buffer. If if not enough the |
michael@0 | 558 | * buffer will be filled to capacity. |
michael@0 | 559 | * @return Number of bytes needed for storing the sort key |
michael@0 | 560 | * @stable ICU 2.0 |
michael@0 | 561 | */ |
michael@0 | 562 | virtual int32_t getSortKey(const UnicodeString& source, uint8_t *result, |
michael@0 | 563 | int32_t resultLength) const; |
michael@0 | 564 | |
michael@0 | 565 | /** |
michael@0 | 566 | * Get the sort key as an array of bytes from an UChar buffer. |
michael@0 | 567 | * @param source string to be processed. |
michael@0 | 568 | * @param sourceLength length of string to be processed. If -1, the string |
michael@0 | 569 | * is 0 terminated and length will be decided by the function. |
michael@0 | 570 | * @param result buffer to store result in. If NULL, number of bytes needed |
michael@0 | 571 | * will be returned. |
michael@0 | 572 | * @param resultLength length of the result buffer. If if not enough the |
michael@0 | 573 | * buffer will be filled to capacity. |
michael@0 | 574 | * @return Number of bytes needed for storing the sort key |
michael@0 | 575 | * @stable ICU 2.2 |
michael@0 | 576 | */ |
michael@0 | 577 | virtual int32_t getSortKey(const UChar *source, int32_t sourceLength, |
michael@0 | 578 | uint8_t *result, int32_t resultLength) const; |
michael@0 | 579 | |
michael@0 | 580 | /** |
michael@0 | 581 | * Retrieves the reordering codes for this collator. |
michael@0 | 582 | * @param dest The array to fill with the script ordering. |
michael@0 | 583 | * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function |
michael@0 | 584 | * will only return the length of the result without writing any of the result string (pre-flighting). |
michael@0 | 585 | * @param status A reference to an error code value, which must not indicate |
michael@0 | 586 | * a failure before the function call. |
michael@0 | 587 | * @return The length of the script ordering array. |
michael@0 | 588 | * @see ucol_setReorderCodes |
michael@0 | 589 | * @see Collator#getEquivalentReorderCodes |
michael@0 | 590 | * @see Collator#setReorderCodes |
michael@0 | 591 | * @stable ICU 4.8 |
michael@0 | 592 | */ |
michael@0 | 593 | virtual int32_t getReorderCodes(int32_t *dest, |
michael@0 | 594 | int32_t destCapacity, |
michael@0 | 595 | UErrorCode& status) const; |
michael@0 | 596 | |
michael@0 | 597 | /** |
michael@0 | 598 | * Sets the ordering of scripts for this collator. |
michael@0 | 599 | * @param reorderCodes An array of script codes in the new order. This can be NULL if the |
michael@0 | 600 | * length is also set to 0. An empty array will clear any reordering codes on the collator. |
michael@0 | 601 | * @param reorderCodesLength The length of reorderCodes. |
michael@0 | 602 | * @param status error code |
michael@0 | 603 | * @see Collator#getReorderCodes |
michael@0 | 604 | * @see Collator#getEquivalentReorderCodes |
michael@0 | 605 | * @stable ICU 4.8 |
michael@0 | 606 | */ |
michael@0 | 607 | virtual void setReorderCodes(const int32_t* reorderCodes, |
michael@0 | 608 | int32_t reorderCodesLength, |
michael@0 | 609 | UErrorCode& status) ; |
michael@0 | 610 | |
michael@0 | 611 | /** |
michael@0 | 612 | * Retrieves the reorder codes that are grouped with the given reorder code. Some reorder |
michael@0 | 613 | * codes will be grouped and must reorder together. |
michael@0 | 614 | * @param reorderCode The reorder code to determine equivalence for. |
michael@0 | 615 | * @param dest The array to fill with the script equivalene reordering codes. |
michael@0 | 616 | * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the |
michael@0 | 617 | * function will only return the length of the result without writing any of the result |
michael@0 | 618 | * string (pre-flighting). |
michael@0 | 619 | * @param status A reference to an error code value, which must not indicate |
michael@0 | 620 | * a failure before the function call. |
michael@0 | 621 | * @return The length of the of the reordering code equivalence array. |
michael@0 | 622 | * @see ucol_setReorderCodes |
michael@0 | 623 | * @see Collator#getReorderCodes |
michael@0 | 624 | * @see Collator#setReorderCodes |
michael@0 | 625 | * @stable ICU 4.8 |
michael@0 | 626 | */ |
michael@0 | 627 | static int32_t U_EXPORT2 getEquivalentReorderCodes(int32_t reorderCode, |
michael@0 | 628 | int32_t* dest, |
michael@0 | 629 | int32_t destCapacity, |
michael@0 | 630 | UErrorCode& status); |
michael@0 | 631 | |
michael@0 | 632 | private: |
michael@0 | 633 | |
michael@0 | 634 | // private static constants ----------------------------------------------- |
michael@0 | 635 | |
michael@0 | 636 | enum { |
michael@0 | 637 | /* need look up in .commit() */ |
michael@0 | 638 | CHARINDEX = 0x70000000, |
michael@0 | 639 | /* Expand index follows */ |
michael@0 | 640 | EXPANDCHARINDEX = 0x7E000000, |
michael@0 | 641 | /* contract indexes follows */ |
michael@0 | 642 | CONTRACTCHARINDEX = 0x7F000000, |
michael@0 | 643 | /* unmapped character values */ |
michael@0 | 644 | UNMAPPED = 0xFFFFFFFF, |
michael@0 | 645 | /* primary strength increment */ |
michael@0 | 646 | PRIMARYORDERINCREMENT = 0x00010000, |
michael@0 | 647 | /* secondary strength increment */ |
michael@0 | 648 | SECONDARYORDERINCREMENT = 0x00000100, |
michael@0 | 649 | /* tertiary strength increment */ |
michael@0 | 650 | TERTIARYORDERINCREMENT = 0x00000001, |
michael@0 | 651 | /* mask off anything but primary order */ |
michael@0 | 652 | PRIMARYORDERMASK = 0xffff0000, |
michael@0 | 653 | /* mask off anything but secondary order */ |
michael@0 | 654 | SECONDARYORDERMASK = 0x0000ff00, |
michael@0 | 655 | /* mask off anything but tertiary order */ |
michael@0 | 656 | TERTIARYORDERMASK = 0x000000ff, |
michael@0 | 657 | /* mask off ignorable char order */ |
michael@0 | 658 | IGNORABLEMASK = 0x0000ffff, |
michael@0 | 659 | /* use only the primary difference */ |
michael@0 | 660 | PRIMARYDIFFERENCEONLY = 0xffff0000, |
michael@0 | 661 | /* use only the primary and secondary difference */ |
michael@0 | 662 | SECONDARYDIFFERENCEONLY = 0xffffff00, |
michael@0 | 663 | /* primary order shift */ |
michael@0 | 664 | PRIMARYORDERSHIFT = 16, |
michael@0 | 665 | /* secondary order shift */ |
michael@0 | 666 | SECONDARYORDERSHIFT = 8, |
michael@0 | 667 | /* starting value for collation elements */ |
michael@0 | 668 | COLELEMENTSTART = 0x02020202, |
michael@0 | 669 | /* testing mask for primary low element */ |
michael@0 | 670 | PRIMARYLOWZEROMASK = 0x00FF0000, |
michael@0 | 671 | /* reseting value for secondaries and tertiaries */ |
michael@0 | 672 | RESETSECONDARYTERTIARY = 0x00000202, |
michael@0 | 673 | /* reseting value for tertiaries */ |
michael@0 | 674 | RESETTERTIARY = 0x00000002, |
michael@0 | 675 | |
michael@0 | 676 | PRIMIGNORABLE = 0x0202 |
michael@0 | 677 | }; |
michael@0 | 678 | |
michael@0 | 679 | // private data members --------------------------------------------------- |
michael@0 | 680 | |
michael@0 | 681 | UBool dataIsOwned; |
michael@0 | 682 | |
michael@0 | 683 | UBool isWriteThroughAlias; |
michael@0 | 684 | |
michael@0 | 685 | /** |
michael@0 | 686 | * c struct for collation. All initialisation for it has to be done through |
michael@0 | 687 | * setUCollator(). |
michael@0 | 688 | */ |
michael@0 | 689 | UCollator *ucollator; |
michael@0 | 690 | |
michael@0 | 691 | /** |
michael@0 | 692 | * Rule UnicodeString |
michael@0 | 693 | */ |
michael@0 | 694 | UnicodeString urulestring; |
michael@0 | 695 | |
michael@0 | 696 | // friend classes -------------------------------------------------------- |
michael@0 | 697 | |
michael@0 | 698 | /** |
michael@0 | 699 | * Used to iterate over collation elements in a character source. |
michael@0 | 700 | */ |
michael@0 | 701 | friend class CollationElementIterator; |
michael@0 | 702 | |
michael@0 | 703 | /** |
michael@0 | 704 | * Collator ONLY needs access to RuleBasedCollator(const Locale&, |
michael@0 | 705 | * UErrorCode&) |
michael@0 | 706 | */ |
michael@0 | 707 | friend class Collator; |
michael@0 | 708 | |
michael@0 | 709 | /** |
michael@0 | 710 | * Searching over collation elements in a character source |
michael@0 | 711 | */ |
michael@0 | 712 | friend class StringSearch; |
michael@0 | 713 | |
michael@0 | 714 | // private constructors -------------------------------------------------- |
michael@0 | 715 | |
michael@0 | 716 | /** |
michael@0 | 717 | * Default constructor |
michael@0 | 718 | */ |
michael@0 | 719 | RuleBasedCollator(); |
michael@0 | 720 | |
michael@0 | 721 | /** |
michael@0 | 722 | * RuleBasedCollator constructor. This constructor takes a locale. The |
michael@0 | 723 | * only caller of this class should be Collator::createInstance(). If |
michael@0 | 724 | * createInstance() happens to know that the requested locale's collation is |
michael@0 | 725 | * implemented as a RuleBasedCollator, it can then call this constructor. |
michael@0 | 726 | * OTHERWISE IT SHOULDN'T, since this constructor ALWAYS RETURNS A VALID |
michael@0 | 727 | * COLLATION TABLE. It does this by falling back to defaults. |
michael@0 | 728 | * @param desiredLocale locale used |
michael@0 | 729 | * @param status error code status |
michael@0 | 730 | */ |
michael@0 | 731 | RuleBasedCollator(const Locale& desiredLocale, UErrorCode& status); |
michael@0 | 732 | |
michael@0 | 733 | /** |
michael@0 | 734 | * common constructor implementation |
michael@0 | 735 | * |
michael@0 | 736 | * @param rules the collation rules to build the collation table from. |
michael@0 | 737 | * @param collationStrength default strength for comparison |
michael@0 | 738 | * @param decompositionMode the normalisation mode |
michael@0 | 739 | * @param status reporting a success or an error. |
michael@0 | 740 | */ |
michael@0 | 741 | void |
michael@0 | 742 | construct(const UnicodeString& rules, |
michael@0 | 743 | UColAttributeValue collationStrength, |
michael@0 | 744 | UColAttributeValue decompositionMode, |
michael@0 | 745 | UErrorCode& status); |
michael@0 | 746 | |
michael@0 | 747 | // private methods ------------------------------------------------------- |
michael@0 | 748 | |
michael@0 | 749 | /** |
michael@0 | 750 | * Creates the c struct for ucollator |
michael@0 | 751 | * @param locale desired locale |
michael@0 | 752 | * @param status error status |
michael@0 | 753 | */ |
michael@0 | 754 | void setUCollator(const Locale& locale, UErrorCode& status); |
michael@0 | 755 | |
michael@0 | 756 | /** |
michael@0 | 757 | * Creates the c struct for ucollator |
michael@0 | 758 | * @param locale desired locale name |
michael@0 | 759 | * @param status error status |
michael@0 | 760 | */ |
michael@0 | 761 | void setUCollator(const char* locale, UErrorCode& status); |
michael@0 | 762 | |
michael@0 | 763 | /** |
michael@0 | 764 | * Creates the c struct for ucollator. This used internally by StringSearch. |
michael@0 | 765 | * Hence the responsibility of cleaning up the ucollator is not done by |
michael@0 | 766 | * this RuleBasedCollator. The isDataOwned flag is set to FALSE. |
michael@0 | 767 | * @param collator new ucollator data |
michael@0 | 768 | */ |
michael@0 | 769 | void setUCollator(UCollator *collator); |
michael@0 | 770 | |
michael@0 | 771 | public: |
michael@0 | 772 | #ifndef U_HIDE_INTERNAL_API |
michael@0 | 773 | /** |
michael@0 | 774 | * Get UCollator data struct. Used only by StringSearch & intltest. |
michael@0 | 775 | * @return UCollator data struct |
michael@0 | 776 | * @internal |
michael@0 | 777 | */ |
michael@0 | 778 | const UCollator * getUCollator(); |
michael@0 | 779 | #endif /* U_HIDE_INTERNAL_API */ |
michael@0 | 780 | |
michael@0 | 781 | protected: |
michael@0 | 782 | /** |
michael@0 | 783 | * Used internally by registraton to define the requested and valid locales. |
michael@0 | 784 | * @param requestedLocale the requsted locale |
michael@0 | 785 | * @param validLocale the valid locale |
michael@0 | 786 | * @param actualLocale the actual locale |
michael@0 | 787 | * @internal |
michael@0 | 788 | */ |
michael@0 | 789 | virtual void setLocales(const Locale& requestedLocale, const Locale& validLocale, const Locale& actualLocale); |
michael@0 | 790 | |
michael@0 | 791 | private: |
michael@0 | 792 | // if not owned and not a write through alias, copy the ucollator |
michael@0 | 793 | void checkOwned(void); |
michael@0 | 794 | |
michael@0 | 795 | // utility to init rule string used by checkOwned and construct |
michael@0 | 796 | void setRuleStringFromCollator(); |
michael@0 | 797 | |
michael@0 | 798 | public: |
michael@0 | 799 | /** Get the short definition string for a collator. This internal API harvests the collator's |
michael@0 | 800 | * locale and the attribute set and produces a string that can be used for opening |
michael@0 | 801 | * a collator with the same properties using the ucol_openFromShortString API. |
michael@0 | 802 | * This string will be normalized. |
michael@0 | 803 | * The structure and the syntax of the string is defined in the "Naming collators" |
michael@0 | 804 | * section of the users guide: |
michael@0 | 805 | * http://icu-project.org/userguide/Collate_Concepts.html#Naming_Collators |
michael@0 | 806 | * This function supports preflighting. |
michael@0 | 807 | * |
michael@0 | 808 | * This is internal, and intended to be used with delegate converters. |
michael@0 | 809 | * |
michael@0 | 810 | * @param locale a locale that will appear as a collators locale in the resulting |
michael@0 | 811 | * short string definition. If NULL, the locale will be harvested |
michael@0 | 812 | * from the collator. |
michael@0 | 813 | * @param buffer space to hold the resulting string |
michael@0 | 814 | * @param capacity capacity of the buffer |
michael@0 | 815 | * @param status for returning errors. All the preflighting errors are featured |
michael@0 | 816 | * @return length of the resulting string |
michael@0 | 817 | * @see ucol_openFromShortString |
michael@0 | 818 | * @see ucol_normalizeShortDefinitionString |
michael@0 | 819 | * @see ucol_getShortDefinitionString |
michael@0 | 820 | * @internal |
michael@0 | 821 | */ |
michael@0 | 822 | virtual int32_t internalGetShortDefinitionString(const char *locale, |
michael@0 | 823 | char *buffer, |
michael@0 | 824 | int32_t capacity, |
michael@0 | 825 | UErrorCode &status) const; |
michael@0 | 826 | }; |
michael@0 | 827 | |
michael@0 | 828 | // inline method implementation --------------------------------------------- |
michael@0 | 829 | |
michael@0 | 830 | inline void RuleBasedCollator::setUCollator(const Locale &locale, |
michael@0 | 831 | UErrorCode &status) |
michael@0 | 832 | { |
michael@0 | 833 | setUCollator(locale.getName(), status); |
michael@0 | 834 | } |
michael@0 | 835 | |
michael@0 | 836 | |
michael@0 | 837 | inline void RuleBasedCollator::setUCollator(UCollator *collator) |
michael@0 | 838 | { |
michael@0 | 839 | |
michael@0 | 840 | if (ucollator && dataIsOwned) { |
michael@0 | 841 | ucol_close(ucollator); |
michael@0 | 842 | } |
michael@0 | 843 | ucollator = collator; |
michael@0 | 844 | dataIsOwned = FALSE; |
michael@0 | 845 | isWriteThroughAlias = TRUE; |
michael@0 | 846 | setRuleStringFromCollator(); |
michael@0 | 847 | } |
michael@0 | 848 | |
michael@0 | 849 | #ifndef U_HIDE_INTERNAL_API |
michael@0 | 850 | inline const UCollator * RuleBasedCollator::getUCollator() |
michael@0 | 851 | { |
michael@0 | 852 | return ucollator; |
michael@0 | 853 | } |
michael@0 | 854 | #endif /* U_HIDE_INTERNAL_API */ |
michael@0 | 855 | |
michael@0 | 856 | U_NAMESPACE_END |
michael@0 | 857 | |
michael@0 | 858 | #endif /* #if !UCONFIG_NO_COLLATION */ |
michael@0 | 859 | |
michael@0 | 860 | #endif |