| OLD | NEW |
| 1 /* | 1 /* |
| 2 ****************************************************************************** | 2 ****************************************************************************** |
| 3 * Copyright (C) 1996-2012, International Business Machines * | 3 * Copyright (C) 1996-2014, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. * | 4 * Corporation and others. All Rights Reserved. |
| 5 ****************************************************************************** | 5 ****************************************************************************** |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * \file | 9 * \file |
| 10 * \brief C++ API: Collation Service. | 10 * \brief C++ API: Collation Service. |
| 11 */ | 11 */ |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * File coll.h | 14 * File coll.h |
| (...skipping 21 matching lines...) Expand all Loading... |
| 36 * 09/03/97 helena Added createCollationKeyValues(). | 36 * 09/03/97 helena Added createCollationKeyValues(). |
| 37 * 02/10/98 damiba Added compare() with length as parameter. | 37 * 02/10/98 damiba Added compare() with length as parameter. |
| 38 * 04/23/99 stephen Removed EDecompositionMode, merged with | 38 * 04/23/99 stephen Removed EDecompositionMode, merged with |
| 39 * Normalizer::EMode. | 39 * Normalizer::EMode. |
| 40 * 11/02/99 helena Collator performance enhancements. Eliminates the | 40 * 11/02/99 helena Collator performance enhancements. Eliminates the |
| 41 * UnicodeString construction and special case for NO_OP
. | 41 * UnicodeString construction and special case for NO_OP
. |
| 42 * 11/23/99 srl More performance enhancements. Inlining of | 42 * 11/23/99 srl More performance enhancements. Inlining of |
| 43 * critical accessors. | 43 * critical accessors. |
| 44 * 05/15/00 helena Added version information API. | 44 * 05/15/00 helena Added version information API. |
| 45 * 01/29/01 synwee Modified into a C++ wrapper which calls C apis | 45 * 01/29/01 synwee Modified into a C++ wrapper which calls C apis |
| 46 * (ucoll.h). | 46 * (ucol.h). |
| 47 * 2012-2014 markus Rewritten in C++ again. |
| 47 */ | 48 */ |
| 48 | 49 |
| 49 #ifndef COLL_H | 50 #ifndef COLL_H |
| 50 #define COLL_H | 51 #define COLL_H |
| 51 | 52 |
| 52 #include "unicode/utypes.h" | 53 #include "unicode/utypes.h" |
| 53 | 54 |
| 54 #if !UCONFIG_NO_COLLATION | 55 #if !UCONFIG_NO_COLLATION |
| 55 | 56 |
| 56 #include "unicode/uobject.h" | 57 #include "unicode/uobject.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 75 | 76 |
| 76 /** | 77 /** |
| 77 * @stable ICU 2.0 | 78 * @stable ICU 2.0 |
| 78 */ | 79 */ |
| 79 class CollationKey; | 80 class CollationKey; |
| 80 | 81 |
| 81 /** | 82 /** |
| 82 * The <code>Collator</code> class performs locale-sensitive string | 83 * The <code>Collator</code> class performs locale-sensitive string |
| 83 * comparison.<br> | 84 * comparison.<br> |
| 84 * You use this class to build searching and sorting routines for natural | 85 * You use this class to build searching and sorting routines for natural |
| 85 * language text.<br> | 86 * language text. |
| 86 * <em>Important: </em>The ICU collation service has been reimplemented | |
| 87 * in order to achieve better performance and UCA compliance. | |
| 88 * For details, see the | |
| 89 * <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collatio
n/ICU_collation_design.htm"> | |
| 90 * collation design document</a>. | |
| 91 * <p> | 87 * <p> |
| 92 * <code>Collator</code> is an abstract base class. Subclasses implement | 88 * <code>Collator</code> is an abstract base class. Subclasses implement |
| 93 * specific collation strategies. One subclass, | 89 * specific collation strategies. One subclass, |
| 94 * <code>RuleBasedCollator</code>, is currently provided and is applicable | 90 * <code>RuleBasedCollator</code>, is currently provided and is applicable |
| 95 * to a wide set of languages. Other subclasses may be created to handle more | 91 * to a wide set of languages. Other subclasses may be created to handle more |
| 96 * specialized needs. | 92 * specialized needs. |
| 97 * <p> | 93 * <p> |
| 98 * Like other locale-sensitive classes, you can use the static factory method, | 94 * Like other locale-sensitive classes, you can use the static factory method, |
| 99 * <code>createInstance</code>, to obtain the appropriate | 95 * <code>createInstance</code>, to obtain the appropriate |
| 100 * <code>Collator</code> object for a given locale. You will only need to | 96 * <code>Collator</code> object for a given locale. You will only need to |
| (...skipping 10 matching lines...) Expand all Loading... |
| 111 * UErrorCode success = U_ZERO_ERROR; | 107 * UErrorCode success = U_ZERO_ERROR; |
| 112 * Collator* myCollator = Collator::createInstance(success); | 108 * Collator* myCollator = Collator::createInstance(success); |
| 113 * if (myCollator->compare("abc", "ABC") < 0) | 109 * if (myCollator->compare("abc", "ABC") < 0) |
| 114 * cout << "abc is less than ABC" << endl; | 110 * cout << "abc is less than ABC" << endl; |
| 115 * else | 111 * else |
| 116 * cout << "abc is greater than or equal to ABC" << endl; | 112 * cout << "abc is greater than or equal to ABC" << endl; |
| 117 * \endcode | 113 * \endcode |
| 118 * </pre> | 114 * </pre> |
| 119 * \htmlonly</blockquote>\endhtmlonly | 115 * \htmlonly</blockquote>\endhtmlonly |
| 120 * <p> | 116 * <p> |
| 121 * You can set a <code>Collator</code>'s <em>strength</em> property to | 117 * You can set a <code>Collator</code>'s <em>strength</em> attribute to |
| 122 * determine the level of difference considered significant in comparisons. | 118 * determine the level of difference considered significant in comparisons. |
| 123 * Five strengths are provided: <code>PRIMARY</code>, <code>SECONDARY</code>, | 119 * Five strengths are provided: <code>PRIMARY</code>, <code>SECONDARY</code>, |
| 124 * <code>TERTIARY</code>, <code>QUATERNARY</code> and <code>IDENTICAL</code>. | 120 * <code>TERTIARY</code>, <code>QUATERNARY</code> and <code>IDENTICAL</code>. |
| 125 * The exact assignment of strengths to language features is locale dependant. | 121 * The exact assignment of strengths to language features is locale dependent. |
| 126 * For example, in Czech, "e" and "f" are considered primary differences, | 122 * For example, in Czech, "e" and "f" are considered primary differences, |
| 127 * while "e" and "\u00EA" are secondary differences, "e" and "E" are tertiary | 123 * while "e" and "\u00EA" are secondary differences, "e" and "E" are tertiary |
| 128 * differences and "e" and "e" are identical. The following shows how both case | 124 * differences and "e" and "e" are identical. The following shows how both case |
| 129 * and accents could be ignored for US English. | 125 * and accents could be ignored for US English. |
| 130 * \htmlonly<blockquote>\endhtmlonly | 126 * \htmlonly<blockquote>\endhtmlonly |
| 131 * <pre> | 127 * <pre> |
| 132 * \code | 128 * \code |
| 133 * //Get the Collator for US English and set its strength to PRIMARY | 129 * //Get the Collator for US English and set its strength to PRIMARY |
| 134 * UErrorCode success = U_ZERO_ERROR; | 130 * UErrorCode success = U_ZERO_ERROR; |
| 135 * Collator* usCollator = Collator::createInstance(Locale::US, success); | 131 * Collator* usCollator = Collator::createInstance(Locale::getUS(), success); |
| 136 * usCollator->setStrength(Collator::PRIMARY); | 132 * usCollator->setStrength(Collator::PRIMARY); |
| 137 * if (usCollator->compare("abc", "ABC") == 0) | 133 * if (usCollator->compare("abc", "ABC") == 0) |
| 138 * cout << "'abc' and 'ABC' strings are equivalent with strength PRIMARY" <<
endl; | 134 * cout << "'abc' and 'ABC' strings are equivalent with strength PRIMARY" <<
endl; |
| 139 * \endcode | 135 * \endcode |
| 140 * </pre> | 136 * </pre> |
| 141 * \htmlonly</blockquote>\endhtmlonly | 137 * \htmlonly</blockquote>\endhtmlonly |
| 142 * <p> | 138 * |
| 143 * For comparing strings exactly once, the <code>compare</code> method | 139 * The <code>getSortKey</code> methods |
| 144 * provides the best performance. When sorting a list of strings however, it | |
| 145 * is generally necessary to compare each string multiple times. In this case, | |
| 146 * sort keys provide better performance. The <code>getSortKey</code> methods | |
| 147 * convert a string to a series of bytes that can be compared bitwise against | 140 * convert a string to a series of bytes that can be compared bitwise against |
| 148 * other sort keys using <code>strcmp()</code>. Sort keys are written as | 141 * other sort keys using <code>strcmp()</code>. Sort keys are written as |
| 149 * zero-terminated byte strings. They consist of several substrings, one for | 142 * zero-terminated byte strings. |
| 150 * each collation strength level, that are delimited by 0x01 bytes. | 143 * |
| 151 * If the string code points are appended for UCOL_IDENTICAL, then they are | 144 * Another set of APIs returns a <code>CollationKey</code> object that wraps |
| 152 * processed for correct code point order comparison and may contain 0x01 | |
| 153 * bytes but not zero bytes. | |
| 154 * </p> | |
| 155 * <p> | |
| 156 * An older set of APIs returns a <code>CollationKey</code> object that wraps | |
| 157 * the sort key bytes instead of returning the bytes themselves. | 145 * the sort key bytes instead of returning the bytes themselves. |
| 158 * Its use is deprecated, but it is still available for compatibility with | |
| 159 * Java. | |
| 160 * </p> | 146 * </p> |
| 161 * <p> | 147 * <p> |
| 162 * <strong>Note:</strong> <code>Collator</code>s with different Locale, | 148 * <strong>Note:</strong> <code>Collator</code>s with different Locale, |
| 163 * and CollationStrength settings will return different sort | 149 * and CollationStrength settings will return different sort |
| 164 * orders for the same set of strings. Locales have specific collation rules, | 150 * orders for the same set of strings. Locales have specific collation rules, |
| 165 * and the way in which secondary and tertiary differences are taken into | 151 * and the way in which secondary and tertiary differences are taken into |
| 166 * account, for example, will result in a different sorting order for same | 152 * account, for example, will result in a different sorting order for same |
| 167 * strings. | 153 * strings. |
| 168 * </p> | 154 * </p> |
| 169 * @see RuleBasedCollator | 155 * @see RuleBasedCollator |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 * The caller owns the returned object and is responsible for deleting it. | 277 * The caller owns the returned object and is responsible for deleting it. |
| 292 * | 278 * |
| 293 * @param err the error code status. | 279 * @param err the error code status. |
| 294 * @return the collation object of the default locale.(for example, en
_US) | 280 * @return the collation object of the default locale.(for example, en
_US) |
| 295 * @see Locale#getDefault | 281 * @see Locale#getDefault |
| 296 * @stable ICU 2.0 | 282 * @stable ICU 2.0 |
| 297 */ | 283 */ |
| 298 static Collator* U_EXPORT2 createInstance(UErrorCode& err); | 284 static Collator* U_EXPORT2 createInstance(UErrorCode& err); |
| 299 | 285 |
| 300 /** | 286 /** |
| 301 * Gets the table-based collation object for the desired locale. The | 287 * Gets the collation object for the desired locale. The |
| 302 * resource of the desired locale will be loaded by ResourceLoader. | 288 * resource of the desired locale will be loaded. |
| 303 * Locale::ENGLISH is the base collation table and all other languages are | 289 * |
| 290 * Locale::getRoot() is the base collation table and all other languages are |
| 304 * built on top of it with additional language-specific modifications. | 291 * built on top of it with additional language-specific modifications. |
| 292 * |
| 293 * For some languages, multiple collation types are available; |
| 294 * for example, "de@collation=phonebook". |
| 295 * Starting with ICU 54, collation attributes can be specified via locale ke
ywords as well, |
| 296 * in the old locale extension syntax ("el@colCaseFirst=upper") |
| 297 * or in language tag syntax ("el-u-kf-upper"). |
| 298 * See <a href="http://userguide.icu-project.org/collation/api">User Guide:
Collation API</a>. |
| 299 * |
| 305 * The UErrorCode& err parameter is used to return status information to the
user. | 300 * The UErrorCode& err parameter is used to return status information to the
user. |
| 306 * To check whether the construction succeeded or not, you should check | 301 * To check whether the construction succeeded or not, you should check |
| 307 * the value of U_SUCCESS(err). If you wish more detailed information, you | 302 * the value of U_SUCCESS(err). If you wish more detailed information, you |
| 308 * can check for informational error results which still indicate success. | 303 * can check for informational error results which still indicate success. |
| 309 * U_USING_FALLBACK_ERROR indicates that a fall back locale was used. For | 304 * U_USING_FALLBACK_ERROR indicates that a fall back locale was used. For |
| 310 * example, 'de_CH' was requested, but nothing was found there, so 'de' was | 305 * example, 'de_CH' was requested, but nothing was found there, so 'de' was |
| 311 * used. U_USING_DEFAULT_ERROR indicates that the default locale data was | 306 * used. U_USING_DEFAULT_ERROR indicates that the default locale data was |
| 312 * used; neither the requested locale nor any of its fall back locales | 307 * used; neither the requested locale nor any of its fall back locales |
| 313 * could be found. | 308 * could be found. |
| 309 * |
| 314 * The caller owns the returned object and is responsible for deleting it. | 310 * The caller owns the returned object and is responsible for deleting it. |
| 315 * @param loc The locale ID for which to open a collator. | 311 * @param loc The locale ID for which to open a collator. |
| 316 * @param err the error code status. | 312 * @param err the error code status. |
| 317 * @return the created table-based collation object based on the desir
ed | 313 * @return the created table-based collation object based on the desir
ed |
| 318 * locale. | 314 * locale. |
| 319 * @see Locale | 315 * @see Locale |
| 320 * @see ResourceLoader | 316 * @see ResourceLoader |
| 321 * @stable ICU 2.2 | 317 * @stable ICU 2.2 |
| 322 */ | 318 */ |
| 323 static Collator* U_EXPORT2 createInstance(const Locale& loc, UErrorCode& err
); | 319 static Collator* U_EXPORT2 createInstance(const Locale& loc, UErrorCode& err
); |
| 324 | 320 |
| 325 #ifdef U_USE_COLLATION_OBSOLETE_2_6 | |
| 326 /** | |
| 327 * Create a Collator with a specific version. | |
| 328 * This is the same as createInstance(loc, err) except that getVersion() of | |
| 329 * the returned object is guaranteed to be the same as the version | |
| 330 * parameter. | |
| 331 * This is designed to be used to open the same collator for a given | |
| 332 * locale even when ICU is updated. | |
| 333 * The same locale and version guarantees the same sort keys and | |
| 334 * comparison results. | |
| 335 * <p> | |
| 336 * Note: this API will be removed in a future release. Use | |
| 337 * <tt>createInstance(const Locale&, UErrorCode&) instead.</tt></p> | |
| 338 * | |
| 339 * @param loc The locale ID for which to open a collator. | |
| 340 * @param version The requested collator version. | |
| 341 * @param err A reference to a UErrorCode, | |
| 342 * must not indicate a failure before calling this function. | |
| 343 * @return A pointer to a Collator, or 0 if an error occurred | |
| 344 * or a collator with the requested version is not available. | |
| 345 * | |
| 346 * @see getVersion | |
| 347 * @obsolete ICU 2.6 | |
| 348 */ | |
| 349 static Collator *createInstance(const Locale &loc, UVersionInfo version, UEr
rorCode &err); | |
| 350 #endif | |
| 351 | |
| 352 /** | 321 /** |
| 353 * The comparison function compares the character data stored in two | 322 * The comparison function compares the character data stored in two |
| 354 * different strings. Returns information about whether a string is less | 323 * different strings. Returns information about whether a string is less |
| 355 * than, greater than or equal to another string. | 324 * than, greater than or equal to another string. |
| 356 * @param source the source string to be compared with. | 325 * @param source the source string to be compared with. |
| 357 * @param target the string that is to be compared with the source string. | 326 * @param target the string that is to be compared with the source string. |
| 358 * @return Returns a byte value. GREATER if source is greater | 327 * @return Returns a byte value. GREATER if source is greater |
| 359 * than target; EQUAL if source is equal to target; LESS if source is less | 328 * than target; EQUAL if source is equal to target; LESS if source is less |
| 360 * than target | 329 * than target |
| 361 * @deprecated ICU 2.6 use the overload with UErrorCode & | 330 * @deprecated ICU 2.6 use the overload with UErrorCode & |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 /** | 385 /** |
| 417 * The comparison function compares the character data stored in two | 386 * The comparison function compares the character data stored in two |
| 418 * different string arrays. Returns information about whether a string array | 387 * different string arrays. Returns information about whether a string array |
| 419 * is less than, greater than or equal to another string array. | 388 * is less than, greater than or equal to another string array. |
| 420 * <p>Example of use: | 389 * <p>Example of use: |
| 421 * <pre> | 390 * <pre> |
| 422 * . UChar ABC[] = {0x41, 0x42, 0x43, 0}; // = "ABC" | 391 * . UChar ABC[] = {0x41, 0x42, 0x43, 0}; // = "ABC" |
| 423 * . UChar abc[] = {0x61, 0x62, 0x63, 0}; // = "abc" | 392 * . UChar abc[] = {0x61, 0x62, 0x63, 0}; // = "abc" |
| 424 * . UErrorCode status = U_ZERO_ERROR; | 393 * . UErrorCode status = U_ZERO_ERROR; |
| 425 * . Collator *myCollation = | 394 * . Collator *myCollation = |
| 426 * . Collator::createInstance(Locale::US, status); | 395 * . Collator::createInstance(Locale::getUS(), statu
s); |
| 427 * . if (U_FAILURE(status)) return; | 396 * . if (U_FAILURE(status)) return; |
| 428 * . myCollation->setStrength(Collator::PRIMARY); | 397 * . myCollation->setStrength(Collator::PRIMARY); |
| 429 * . // result would be Collator::EQUAL ("abc" == "ABC") | 398 * . // result would be Collator::EQUAL ("abc" == "ABC") |
| 430 * . // (no primary difference between "abc" and "ABC") | 399 * . // (no primary difference between "abc" and "ABC") |
| 431 * . Collator::EComparisonResult result = | 400 * . Collator::EComparisonResult result = |
| 432 * . myCollation->compare(abc, 3, ABC, 3); | 401 * . myCollation->compare(abc, 3, ABC, 3); |
| 433 * . myCollation->setStrength(Collator::TERTIARY); | 402 * . myCollation->setStrength(Collator::TERTIARY); |
| 434 * . // result would be Collator::LESS ("abc" <<< "ABC") | 403 * . // result would be Collator::LESS ("abc" <<< "ABC") |
| 435 * . // (with tertiary difference between "abc" and "ABC") | 404 * . // (with tertiary difference between "abc" and "ABC") |
| 436 * . result = myCollation->compare(abc, 3, ABC, 3); | 405 * . result = myCollation->compare(abc, 3, ABC, 3); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 * @return UCOL_LESS, UCOL_EQUAL or UCOL_GREATER | 467 * @return UCOL_LESS, UCOL_EQUAL or UCOL_GREATER |
| 499 * @stable ICU 4.2 | 468 * @stable ICU 4.2 |
| 500 */ | 469 */ |
| 501 virtual UCollationResult compareUTF8(const StringPiece &source, | 470 virtual UCollationResult compareUTF8(const StringPiece &source, |
| 502 const StringPiece &target, | 471 const StringPiece &target, |
| 503 UErrorCode &status) const; | 472 UErrorCode &status) const; |
| 504 | 473 |
| 505 /** | 474 /** |
| 506 * Transforms the string into a series of characters that can be compared | 475 * Transforms the string into a series of characters that can be compared |
| 507 * with CollationKey::compareTo. It is not possible to restore the original | 476 * with CollationKey::compareTo. It is not possible to restore the original |
| 508 * string from the chars in the sort key. The generated sort key handles | 477 * string from the chars in the sort key. |
| 509 * only a limited number of ignorable characters. | |
| 510 * <p>Use CollationKey::equals or CollationKey::compare to compare the | 478 * <p>Use CollationKey::equals or CollationKey::compare to compare the |
| 511 * generated sort keys. | 479 * generated sort keys. |
| 512 * If the source string is null, a null collation key will be returned. | 480 * If the source string is null, a null collation key will be returned. |
| 481 * |
| 482 * Note that sort keys are often less efficient than simply doing comparison
. |
| 483 * For more details, see the ICU User Guide. |
| 484 * |
| 513 * @param source the source string to be transformed into a sort key. | 485 * @param source the source string to be transformed into a sort key. |
| 514 * @param key the collation key to be filled in | 486 * @param key the collation key to be filled in |
| 515 * @param status the error code status. | 487 * @param status the error code status. |
| 516 * @return the collation key of the string based on the collation rules. | 488 * @return the collation key of the string based on the collation rules. |
| 517 * @see CollationKey#compare | 489 * @see CollationKey#compare |
| 518 * @stable ICU 2.0 | 490 * @stable ICU 2.0 |
| 519 */ | 491 */ |
| 520 virtual CollationKey& getCollationKey(const UnicodeString& source, | 492 virtual CollationKey& getCollationKey(const UnicodeString& source, |
| 521 CollationKey& key, | 493 CollationKey& key, |
| 522 UErrorCode& status) const = 0; | 494 UErrorCode& status) const = 0; |
| 523 | 495 |
| 524 /** | 496 /** |
| 525 * Transforms the string into a series of characters that can be compared | 497 * Transforms the string into a series of characters that can be compared |
| 526 * with CollationKey::compareTo. It is not possible to restore the original | 498 * with CollationKey::compareTo. It is not possible to restore the original |
| 527 * string from the chars in the sort key. The generated sort key handles | 499 * string from the chars in the sort key. |
| 528 * only a limited number of ignorable characters. | |
| 529 * <p>Use CollationKey::equals or CollationKey::compare to compare the | 500 * <p>Use CollationKey::equals or CollationKey::compare to compare the |
| 530 * generated sort keys. | 501 * generated sort keys. |
| 531 * <p>If the source string is null, a null collation key will be returned. | 502 * <p>If the source string is null, a null collation key will be returned. |
| 503 * |
| 504 * Note that sort keys are often less efficient than simply doing comparison
. |
| 505 * For more details, see the ICU User Guide. |
| 506 * |
| 532 * @param source the source string to be transformed into a sort key. | 507 * @param source the source string to be transformed into a sort key. |
| 533 * @param sourceLength length of the collation key | 508 * @param sourceLength length of the collation key |
| 534 * @param key the collation key to be filled in | 509 * @param key the collation key to be filled in |
| 535 * @param status the error code status. | 510 * @param status the error code status. |
| 536 * @return the collation key of the string based on the collation rules. | 511 * @return the collation key of the string based on the collation rules. |
| 537 * @see CollationKey#compare | 512 * @see CollationKey#compare |
| 538 * @stable ICU 2.0 | 513 * @stable ICU 2.0 |
| 539 */ | 514 */ |
| 540 virtual CollationKey& getCollationKey(const UChar*source, | 515 virtual CollationKey& getCollationKey(const UChar*source, |
| 541 int32_t sourceLength, | 516 int32_t sourceLength, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 * @deprecated ICU 2.6 Use getAttribute(UCOL_STRENGTH...) instead | 582 * @deprecated ICU 2.6 Use getAttribute(UCOL_STRENGTH...) instead |
| 608 */ | 583 */ |
| 609 virtual ECollationStrength getStrength(void) const; | 584 virtual ECollationStrength getStrength(void) const; |
| 610 | 585 |
| 611 /** | 586 /** |
| 612 * Sets the minimum strength to be used in comparison or transformation. | 587 * Sets the minimum strength to be used in comparison or transformation. |
| 613 * <p>Example of use: | 588 * <p>Example of use: |
| 614 * <pre> | 589 * <pre> |
| 615 * \code | 590 * \code |
| 616 * UErrorCode status = U_ZERO_ERROR; | 591 * UErrorCode status = U_ZERO_ERROR; |
| 617 * Collator*myCollation = Collator::createInstance(Locale::US, status); | 592 * Collator*myCollation = Collator::createInstance(Locale::getUS(), status)
; |
| 618 * if (U_FAILURE(status)) return; | 593 * if (U_FAILURE(status)) return; |
| 619 * myCollation->setStrength(Collator::PRIMARY); | 594 * myCollation->setStrength(Collator::PRIMARY); |
| 620 * // result will be "abc" == "ABC" | 595 * // result will be "abc" == "ABC" |
| 621 * // tertiary differences will be ignored | 596 * // tertiary differences will be ignored |
| 622 * Collator::ComparisonResult result = myCollation->compare("abc", "ABC"); | 597 * Collator::ComparisonResult result = myCollation->compare("abc", "ABC"); |
| 623 * \endcode | 598 * \endcode |
| 624 * </pre> | 599 * </pre> |
| 625 * @see Collator#getStrength | 600 * @see Collator#getStrength |
| 626 * @param newStrength the new comparison level. | 601 * @param newStrength the new comparison level. |
| 627 * @deprecated ICU 2.6 Use setAttribute(UCOL_STRENGTH...) instead | 602 * @deprecated ICU 2.6 Use setAttribute(UCOL_STRENGTH...) instead |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 * @stable ICU 4.8 | 637 * @stable ICU 4.8 |
| 663 */ | 638 */ |
| 664 virtual void setReorderCodes(const int32_t* reorderCodes, | 639 virtual void setReorderCodes(const int32_t* reorderCodes, |
| 665 int32_t reorderCodesLength, | 640 int32_t reorderCodesLength, |
| 666 UErrorCode& status) ; | 641 UErrorCode& status) ; |
| 667 | 642 |
| 668 /** | 643 /** |
| 669 * Retrieves the reorder codes that are grouped with the given reorder code.
Some reorder | 644 * Retrieves the reorder codes that are grouped with the given reorder code.
Some reorder |
| 670 * codes will be grouped and must reorder together. | 645 * codes will be grouped and must reorder together. |
| 671 * @param reorderCode The reorder code to determine equivalence for. | 646 * @param reorderCode The reorder code to determine equivalence for. |
| 672 * @param dest The array to fill with the script equivalene reordering codes
. | 647 * @param dest The array to fill with the script equivalence reordering code
s. |
| 673 * @param destCapacity The length of dest. If it is 0, then dest may be NULL
and the | 648 * @param destCapacity The length of dest. If it is 0, then dest may be NULL
and the |
| 674 * function will only return the length of the result without writing any of
the result | 649 * function will only return the length of the result without writing any of
the result |
| 675 * string (pre-flighting). | 650 * string (pre-flighting). |
| 676 * @param status A reference to an error code value, which must not indicate
| 651 * @param status A reference to an error code value, which must not indicate
|
| 677 * a failure before the function call. | 652 * a failure before the function call. |
| 678 * @return The length of the of the reordering code equivalence array. | 653 * @return The length of the of the reordering code equivalence array. |
| 679 * @see ucol_setReorderCodes | 654 * @see ucol_setReorderCodes |
| 680 * @see Collator#getReorderCodes | 655 * @see Collator#getReorderCodes |
| 681 * @see Collator#setReorderCodes | 656 * @see Collator#setReorderCodes |
| 682 * @see UScriptCode | 657 * @see UScriptCode |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 * collation service. If two locales return the same result, then | 759 * collation service. If two locales return the same result, then |
| 785 * collators instantiated for these locales will behave | 760 * collators instantiated for these locales will behave |
| 786 * equivalently. The converse is not always true; two collators | 761 * equivalently. The converse is not always true; two collators |
| 787 * may in fact be equivalent, but return different results, due to | 762 * may in fact be equivalent, but return different results, due to |
| 788 * internal details. The return result has no other meaning than | 763 * internal details. The return result has no other meaning than |
| 789 * that stated above, and implies nothing as to the relationship | 764 * that stated above, and implies nothing as to the relationship |
| 790 * between the two locales. This is intended for use by | 765 * between the two locales. This is intended for use by |
| 791 * applications who wish to cache collators, or otherwise reuse | 766 * applications who wish to cache collators, or otherwise reuse |
| 792 * collators when possible. The functional equivalent may change | 767 * collators when possible. The functional equivalent may change |
| 793 * over time. For more information, please see the <a | 768 * over time. For more information, please see the <a |
| 794 * href="http://icu-project.org/userguide/locale.html#services"> | 769 * href="http://userguide.icu-project.org/locale#TOC-Locales-and-Services"> |
| 795 * Locales and Services</a> section of the ICU User Guide. | 770 * Locales and Services</a> section of the ICU User Guide. |
| 796 * @param keyword a particular keyword as enumerated by | 771 * @param keyword a particular keyword as enumerated by |
| 797 * ucol_getKeywords. | 772 * ucol_getKeywords. |
| 798 * @param locale the requested locale | 773 * @param locale the requested locale |
| 799 * @param isAvailable reference to a fillin parameter that | 774 * @param isAvailable reference to a fillin parameter that |
| 800 * indicates whether the requested locale was 'available' to the | 775 * indicates whether the requested locale was 'available' to the |
| 801 * collation service. A locale is defined as 'available' if it | 776 * collation service. A locale is defined as 'available' if it |
| 802 * physically exists within the collation locale data. | 777 * physically exists within the collation locale data. |
| 803 * @param status reference to input-output error code | 778 * @param status reference to input-output error code |
| 804 * @return the functionally equivalent collation locale, or the root | 779 * @return the functionally equivalent collation locale, or the root |
| 805 * locale upon error. | 780 * locale upon error. |
| 806 * @stable ICU 3.0 | 781 * @stable ICU 3.0 |
| 807 */ | 782 */ |
| 808 static Locale U_EXPORT2 getFunctionalEquivalent(const char* keyword, const L
ocale& locale, | 783 static Locale U_EXPORT2 getFunctionalEquivalent(const char* keyword, const L
ocale& locale, |
| 809 UBool& isAvailable, UErrorCode& status
); | 784 UBool& isAvailable, UErrorCode& status
); |
| 810 | 785 |
| 811 #if !UCONFIG_NO_SERVICE | 786 #if !UCONFIG_NO_SERVICE |
| 812 /** | 787 /** |
| 813 * Register a new Collator. The collator will be adopted. | 788 * Register a new Collator. The collator will be adopted. |
| 789 * Because ICU may choose to cache collators internally, this must be |
| 790 * called at application startup, prior to any calls to |
| 791 * Collator::createInstance to avoid undefined behavior. |
| 814 * @param toAdopt the Collator instance to be adopted | 792 * @param toAdopt the Collator instance to be adopted |
| 815 * @param locale the locale with which the collator will be associated | 793 * @param locale the locale with which the collator will be associated |
| 816 * @param status the in/out status code, no special meanings are assigned | 794 * @param status the in/out status code, no special meanings are assigned |
| 817 * @return a registry key that can be used to unregister this collator | 795 * @return a registry key that can be used to unregister this collator |
| 818 * @stable ICU 2.6 | 796 * @stable ICU 2.6 |
| 819 */ | 797 */ |
| 820 static URegistryKey U_EXPORT2 registerInstance(Collator* toAdopt, const Loca
le& locale, UErrorCode& status); | 798 static URegistryKey U_EXPORT2 registerInstance(Collator* toAdopt, const Loca
le& locale, UErrorCode& status); |
| 821 | 799 |
| 822 /** | 800 /** |
| 823 * Register a new CollatorFactory. The factory will be adopted. | 801 * Register a new CollatorFactory. The factory will be adopted. |
| 802 * Because ICU may choose to cache collators internally, this must be |
| 803 * called at application startup, prior to any calls to |
| 804 * Collator::createInstance to avoid undefined behavior. |
| 824 * @param toAdopt the CollatorFactory instance to be adopted | 805 * @param toAdopt the CollatorFactory instance to be adopted |
| 825 * @param status the in/out status code, no special meanings are assigned | 806 * @param status the in/out status code, no special meanings are assigned |
| 826 * @return a registry key that can be used to unregister this collator | 807 * @return a registry key that can be used to unregister this collator |
| 827 * @stable ICU 2.6 | 808 * @stable ICU 2.6 |
| 828 */ | 809 */ |
| 829 static URegistryKey U_EXPORT2 registerFactory(CollatorFactory* toAdopt, UErr
orCode& status); | 810 static URegistryKey U_EXPORT2 registerFactory(CollatorFactory* toAdopt, UErr
orCode& status); |
| 830 | 811 |
| 831 /** | 812 /** |
| 832 * Unregister a previously-registered Collator or CollatorFactory | 813 * Unregister a previously-registered Collator or CollatorFactory |
| 833 * using the key returned from the register call. Key becomes | 814 * using the key returned from the register call. Key becomes |
| 834 * invalid after a successful call and should not be used again. | 815 * invalid after a successful call and should not be used again. |
| 835 * The object corresponding to the key will be deleted. | 816 * The object corresponding to the key will be deleted. |
| 817 * Because ICU may choose to cache collators internally, this should |
| 818 * be called during application shutdown, after all calls to |
| 819 * Collator::createInstance to avoid undefined behavior. |
| 836 * @param key the registry key returned by a previous call to registerInstan
ce | 820 * @param key the registry key returned by a previous call to registerInstan
ce |
| 837 * @param status the in/out status code, no special meanings are assigned | 821 * @param status the in/out status code, no special meanings are assigned |
| 838 * @return TRUE if the collator for the key was successfully unregistered | 822 * @return TRUE if the collator for the key was successfully unregistered |
| 839 * @stable ICU 2.6 | 823 * @stable ICU 2.6 |
| 840 */ | 824 */ |
| 841 static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status); | 825 static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status); |
| 842 #endif /* UCONFIG_NO_SERVICE */ | 826 #endif /* UCONFIG_NO_SERVICE */ |
| 843 | 827 |
| 844 /** | 828 /** |
| 845 * Gets the version information for a Collator. | 829 * Gets the version information for a Collator. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 875 * Universal attribute getter | 859 * Universal attribute getter |
| 876 * @param attr attribute type | 860 * @param attr attribute type |
| 877 * @param status to indicate whether the operation went on smoothly or | 861 * @param status to indicate whether the operation went on smoothly or |
| 878 * there were errors | 862 * there were errors |
| 879 * @return attribute value | 863 * @return attribute value |
| 880 * @stable ICU 2.2 | 864 * @stable ICU 2.2 |
| 881 */ | 865 */ |
| 882 virtual UColAttributeValue getAttribute(UColAttribute attr, | 866 virtual UColAttributeValue getAttribute(UColAttribute attr, |
| 883 UErrorCode &status) const = 0; | 867 UErrorCode &status) const = 0; |
| 884 | 868 |
| 869 /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft methods since
they are virtual */ |
| 885 /** | 870 /** |
| 886 * Sets the variable top to a collation element value of a string supplied. | 871 * Sets the variable top to the top of the specified reordering group. |
| 872 * The variable top determines the highest-sorting character |
| 873 * which is affected by UCOL_ALTERNATE_HANDLING. |
| 874 * If that attribute is set to UCOL_NON_IGNORABLE, then the variable top has
no effect. |
| 875 * |
| 876 * The base class implementation sets U_UNSUPPORTED_ERROR. |
| 877 * @param group one of UCOL_REORDER_CODE_SPACE, UCOL_REORDER_CODE_PUNCTUATIO
N, |
| 878 * UCOL_REORDER_CODE_SYMBOL, UCOL_REORDER_CODE_CURRENCY; |
| 879 * or UCOL_REORDER_CODE_DEFAULT to restore the default max vari
able group |
| 880 * @param errorCode Standard ICU error code. Its input value must |
| 881 * pass the U_SUCCESS() test, or else the function returns |
| 882 * immediately. Check for U_FAILURE() on output or use with |
| 883 * function chaining. (See User Guide for details.) |
| 884 * @return *this |
| 885 * @see getMaxVariable |
| 886 * @draft ICU 53 |
| 887 */ |
| 888 virtual Collator &setMaxVariable(UColReorderCode group, UErrorCode &errorCod
e); |
| 889 |
| 890 /** |
| 891 * Returns the maximum reordering group whose characters are affected by UCO
L_ALTERNATE_HANDLING. |
| 892 * |
| 893 * The base class implementation returns UCOL_REORDER_CODE_PUNCTUATION. |
| 894 * @return the maximum variable reordering group. |
| 895 * @see setMaxVariable |
| 896 * @draft ICU 53 |
| 897 */ |
| 898 virtual UColReorderCode getMaxVariable() const; |
| 899 |
| 900 /** |
| 901 * Sets the variable top to the primary weight of the specified string. |
| 902 * |
| 903 * Beginning with ICU 53, the variable top is pinned to |
| 904 * the top of one of the supported reordering groups, |
| 905 * and it must not be beyond the last of those groups. |
| 906 * See setMaxVariable(). |
| 887 * @param varTop one or more (if contraction) UChars to which the variable t
op should be set | 907 * @param varTop one or more (if contraction) UChars to which the variable t
op should be set |
| 888 * @param len length of variable top string. If -1 it is considered to be ze
ro terminated. | 908 * @param len length of variable top string. If -1 it is considered to be ze
ro terminated. |
| 889 * @param status error code. If error code is set, the return value is undef
ined. Errors set by this function are: <br> | 909 * @param status error code. If error code is set, the return value is undef
ined. Errors set by this function are: <br> |
| 890 * U_CE_NOT_FOUND_ERROR if more than one character was passed and there i
s no such a contraction<br> | 910 * U_CE_NOT_FOUND_ERROR if more than one character was passed and there i
s no such contraction<br> |
| 891 * U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more
than two bytes | 911 * U_ILLEGAL_ARGUMENT_ERROR if the variable top is beyond |
| 892 * @return a 32 bit value containing the value of the variable top in upper
16 bits. Lower 16 bits are undefined | 912 * the last reordering group supported by setMaxVariable() |
| 893 * @stable ICU 2.0 | 913 * @return variable top primary weight |
| 914 * @deprecated ICU 53 Call setMaxVariable() instead. |
| 894 */ | 915 */ |
| 895 virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode
&status) = 0; | 916 virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode
&status) = 0; |
| 896 | 917 |
| 897 /** | 918 /** |
| 898 * Sets the variable top to a collation element value of a string supplied. | 919 * Sets the variable top to the primary weight of the specified string. |
| 899 * @param varTop an UnicodeString size 1 or more (if contraction) of UChars
to which the variable top should be set | 920 * |
| 921 * Beginning with ICU 53, the variable top is pinned to |
| 922 * the top of one of the supported reordering groups, |
| 923 * and it must not be beyond the last of those groups. |
| 924 * See setMaxVariable(). |
| 925 * @param varTop a UnicodeString size 1 or more (if contraction) of UChars t
o which the variable top should be set |
| 900 * @param status error code. If error code is set, the return value is undef
ined. Errors set by this function are: <br> | 926 * @param status error code. If error code is set, the return value is undef
ined. Errors set by this function are: <br> |
| 901 * U_CE_NOT_FOUND_ERROR if more than one character was passed and there i
s no such a contraction<br> | 927 * U_CE_NOT_FOUND_ERROR if more than one character was passed and there i
s no such contraction<br> |
| 902 * U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more
than two bytes | 928 * U_ILLEGAL_ARGUMENT_ERROR if the variable top is beyond |
| 903 * @return a 32 bit value containing the value of the variable top in upper
16 bits. Lower 16 bits are undefined | 929 * the last reordering group supported by setMaxVariable() |
| 904 * @stable ICU 2.0 | 930 * @return variable top primary weight |
| 931 * @deprecated ICU 53 Call setMaxVariable() instead. |
| 905 */ | 932 */ |
| 906 virtual uint32_t setVariableTop(const UnicodeString &varTop, UErrorCode &sta
tus) = 0; | 933 virtual uint32_t setVariableTop(const UnicodeString &varTop, UErrorCode &sta
tus) = 0; |
| 907 | 934 |
| 908 /** | 935 /** |
| 909 * Sets the variable top to a collation element value supplied. Variable top
is set to the upper 16 bits. | 936 * Sets the variable top to the specified primary weight. |
| 910 * Lower 16 bits are ignored. | 937 * |
| 911 * @param varTop CE value, as returned by setVariableTop or ucol)getVariable
Top | 938 * Beginning with ICU 53, the variable top is pinned to |
| 912 * @param status error code (not changed by function) | 939 * the top of one of the supported reordering groups, |
| 913 * @stable ICU 2.0 | 940 * and it must not be beyond the last of those groups. |
| 941 * See setMaxVariable(). |
| 942 * @param varTop primary weight, as returned by setVariableTop or ucol_getVa
riableTop |
| 943 * @param status error code |
| 944 * @deprecated ICU 53 Call setMaxVariable() instead. |
| 914 */ | 945 */ |
| 915 virtual void setVariableTop(uint32_t varTop, UErrorCode &status) = 0; | 946 virtual void setVariableTop(uint32_t varTop, UErrorCode &status) = 0; |
| 916 | 947 |
| 917 /** | 948 /** |
| 918 * Gets the variable top value of a Collator. | 949 * Gets the variable top value of a Collator. |
| 919 * Lower 16 bits are undefined and should be ignored. | |
| 920 * @param status error code (not changed by function). If error code is set,
the return value is undefined. | 950 * @param status error code (not changed by function). If error code is set,
the return value is undefined. |
| 951 * @return the variable top primary weight |
| 952 * @see getMaxVariable |
| 921 * @stable ICU 2.0 | 953 * @stable ICU 2.0 |
| 922 */ | 954 */ |
| 923 virtual uint32_t getVariableTop(UErrorCode &status) const = 0; | 955 virtual uint32_t getVariableTop(UErrorCode &status) const = 0; |
| 924 | 956 |
| 925 /** | 957 /** |
| 926 * Get an UnicodeSet that contains all the characters and sequences | 958 * Get a UnicodeSet that contains all the characters and sequences |
| 927 * tailored in this collator. | 959 * tailored in this collator. |
| 928 * @param status error code of the operation | 960 * @param status error code of the operation |
| 929 * @return a pointer to a UnicodeSet object containing all the | 961 * @return a pointer to a UnicodeSet object containing all the |
| 930 * code points and sequences that may sort differently than | 962 * code points and sequences that may sort differently than |
| 931 * in the UCA. The object must be disposed of by using delete | 963 * in the root collator. The object must be disposed of by using del
ete |
| 932 * @stable ICU 2.4 | 964 * @stable ICU 2.4 |
| 933 */ | 965 */ |
| 934 virtual UnicodeSet *getTailoredSet(UErrorCode &status) const; | 966 virtual UnicodeSet *getTailoredSet(UErrorCode &status) const; |
| 935 | 967 |
| 936 /** | 968 /** |
| 937 * Same as clone(). | 969 * Same as clone(). |
| 938 * The base class implementation simply calls clone(). | 970 * The base class implementation simply calls clone(). |
| 939 * @return a copy of this object, owned by the caller | 971 * @return a copy of this object, owned by the caller |
| 940 * @see clone() | 972 * @see clone() |
| 941 * @deprecated ICU 50 no need to have two methods for cloning | 973 * @deprecated ICU 50 no need to have two methods for cloning |
| 942 */ | 974 */ |
| 943 virtual Collator* safeClone(void) const; | 975 virtual Collator* safeClone(void) const; |
| 944 | 976 |
| 945 /** | 977 /** |
| 946 * Get the sort key as an array of bytes from an UnicodeString. | 978 * Get the sort key as an array of bytes from a UnicodeString. |
| 947 * Sort key byte arrays are zero-terminated and can be compared using | 979 * Sort key byte arrays are zero-terminated and can be compared using |
| 948 * strcmp(). | 980 * strcmp(). |
| 981 * |
| 982 * Note that sort keys are often less efficient than simply doing comparison
. |
| 983 * For more details, see the ICU User Guide. |
| 984 * |
| 949 * @param source string to be processed. | 985 * @param source string to be processed. |
| 950 * @param result buffer to store result in. If NULL, number of bytes needed | 986 * @param result buffer to store result in. If NULL, number of bytes needed |
| 951 * will be returned. | 987 * will be returned. |
| 952 * @param resultLength length of the result buffer. If if not enough the | 988 * @param resultLength length of the result buffer. If if not enough the |
| 953 * buffer will be filled to capacity. | 989 * buffer will be filled to capacity. |
| 954 * @return Number of bytes needed for storing the sort key | 990 * @return Number of bytes needed for storing the sort key |
| 955 * @stable ICU 2.2 | 991 * @stable ICU 2.2 |
| 956 */ | 992 */ |
| 957 virtual int32_t getSortKey(const UnicodeString& source, | 993 virtual int32_t getSortKey(const UnicodeString& source, |
| 958 uint8_t* result, | 994 uint8_t* result, |
| 959 int32_t resultLength) const = 0; | 995 int32_t resultLength) const = 0; |
| 960 | 996 |
| 961 /** | 997 /** |
| 962 * Get the sort key as an array of bytes from an UChar buffer. | 998 * Get the sort key as an array of bytes from a UChar buffer. |
| 963 * Sort key byte arrays are zero-terminated and can be compared using | 999 * Sort key byte arrays are zero-terminated and can be compared using |
| 964 * strcmp(). | 1000 * strcmp(). |
| 1001 * |
| 1002 * Note that sort keys are often less efficient than simply doing comparison
. |
| 1003 * For more details, see the ICU User Guide. |
| 1004 * |
| 965 * @param source string to be processed. | 1005 * @param source string to be processed. |
| 966 * @param sourceLength length of string to be processed. | 1006 * @param sourceLength length of string to be processed. |
| 967 * If -1, the string is 0 terminated and length will be decided by th
e | 1007 * If -1, the string is 0 terminated and length will be decided by th
e |
| 968 * function. | 1008 * function. |
| 969 * @param result buffer to store result in. If NULL, number of bytes needed | 1009 * @param result buffer to store result in. If NULL, number of bytes needed |
| 970 * will be returned. | 1010 * will be returned. |
| 971 * @param resultLength length of the result buffer. If if not enough the | 1011 * @param resultLength length of the result buffer. If if not enough the |
| 972 * buffer will be filled to capacity. | 1012 * buffer will be filled to capacity. |
| 973 * @return Number of bytes needed for storing the sort key | 1013 * @return Number of bytes needed for storing the sort key |
| 974 * @stable ICU 2.2 | 1014 * @stable ICU 2.2 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 UNormalizationMode decompositionMode); | 1091 UNormalizationMode decompositionMode); |
| 1052 #endif /* U_HIDE_DEPRECATED_API */ | 1092 #endif /* U_HIDE_DEPRECATED_API */ |
| 1053 | 1093 |
| 1054 /** | 1094 /** |
| 1055 * Copy constructor. | 1095 * Copy constructor. |
| 1056 * @param other Collator object to be copied from | 1096 * @param other Collator object to be copied from |
| 1057 * @stable ICU 2.0 | 1097 * @stable ICU 2.0 |
| 1058 */ | 1098 */ |
| 1059 Collator(const Collator& other); | 1099 Collator(const Collator& other); |
| 1060 | 1100 |
| 1061 // Collator protected methods ----------------------------------------- | 1101 public: |
| 1062 | |
| 1063 | |
| 1064 /** | 1102 /** |
| 1065 * Used internally by registraton to define the requested and valid locales. | 1103 * Used internally by registration to define the requested and valid locales. |
| 1066 * @param requestedLocale the requested locale | 1104 * @param requestedLocale the requested locale |
| 1067 * @param validLocale the valid locale | 1105 * @param validLocale the valid locale |
| 1068 * @param actualLocale the actual locale | 1106 * @param actualLocale the actual locale |
| 1069 * @internal | 1107 * @internal |
| 1070 */ | 1108 */ |
| 1071 virtual void setLocales(const Locale& requestedLocale, const Locale& validLo
cale, const Locale& actualLocale); | 1109 virtual void setLocales(const Locale& requestedLocale, const Locale& validLo
cale, const Locale& actualLocale); |
| 1072 | 1110 |
| 1073 public: | |
| 1074 #if !UCONFIG_NO_SERVICE | |
| 1075 #ifndef U_HIDE_INTERNAL_API | |
| 1076 /** | |
| 1077 * used only by ucol_open, not for public use | |
| 1078 * @internal | |
| 1079 */ | |
| 1080 static UCollator* createUCollator(const char* loc, UErrorCode* status); | |
| 1081 #endif /* U_HIDE_INTERNAL_API */ | |
| 1082 #endif | |
| 1083 | |
| 1084 /** Get the short definition string for a collator. This internal API harves
ts the collator's | 1111 /** Get the short definition string for a collator. This internal API harves
ts the collator's |
| 1085 * locale and the attribute set and produces a string that can be used for
opening | 1112 * locale and the attribute set and produces a string that can be used for
opening |
| 1086 * a collator with the same properties using the ucol_openFromShortString A
PI. | 1113 * a collator with the same attributes using the ucol_openFromShortString A
PI. |
| 1087 * This string will be normalized. | 1114 * This string will be normalized. |
| 1088 * The structure and the syntax of the string is defined in the "Naming col
lators" | 1115 * The structure and the syntax of the string is defined in the "Naming col
lators" |
| 1089 * section of the users guide: | 1116 * section of the users guide: |
| 1090 * http://icu-project.org/userguide/Collate_Concepts.html#Naming_Collators | 1117 * http://userguide.icu-project.org/collation/concepts#TOC-Collator-naming-
scheme |
| 1091 * This function supports preflighting. | 1118 * This function supports preflighting. |
| 1092 * | 1119 * |
| 1093 * This is internal, and intended to be used with delegate converters. | 1120 * This is internal, and intended to be used with delegate converters. |
| 1094 * | 1121 * |
| 1095 * @param locale a locale that will appear as a collators locale in the res
ulting | 1122 * @param locale a locale that will appear as a collators locale in the res
ulting |
| 1096 * short string definition. If NULL, the locale will be harve
sted | 1123 * short string definition. If NULL, the locale will be harve
sted |
| 1097 * from the collator. | 1124 * from the collator. |
| 1098 * @param buffer space to hold the resulting string | 1125 * @param buffer space to hold the resulting string |
| 1099 * @param capacity capacity of the buffer | 1126 * @param capacity capacity of the buffer |
| 1100 * @param status for returning errors. All the preflighting errors are feat
ured | 1127 * @param status for returning errors. All the preflighting errors are feat
ured |
| 1101 * @return length of the resulting string | 1128 * @return length of the resulting string |
| 1102 * @see ucol_openFromShortString | 1129 * @see ucol_openFromShortString |
| 1103 * @see ucol_normalizeShortDefinitionString | 1130 * @see ucol_normalizeShortDefinitionString |
| 1104 * @see ucol_getShortDefinitionString | 1131 * @see ucol_getShortDefinitionString |
| 1105 * @internal | 1132 * @internal |
| 1106 */ | 1133 */ |
| 1107 virtual int32_t internalGetShortDefinitionString(const char *locale, | 1134 virtual int32_t internalGetShortDefinitionString(const char *locale, |
| 1108 char *buffer, | 1135 char *buffer, |
| 1109 int32_t capacity, | 1136 int32_t capacity, |
| 1110 UErrorCode &status) const; | 1137 UErrorCode &status) const; |
| 1138 |
| 1139 /** |
| 1140 * Implements ucol_strcollUTF8(). |
| 1141 * @internal |
| 1142 */ |
| 1143 virtual UCollationResult internalCompareUTF8( |
| 1144 const char *left, int32_t leftLength, |
| 1145 const char *right, int32_t rightLength, |
| 1146 UErrorCode &errorCode) const; |
| 1147 |
| 1148 /** |
| 1149 * Implements ucol_nextSortKeyPart(). |
| 1150 * @internal |
| 1151 */ |
| 1152 virtual int32_t |
| 1153 internalNextSortKeyPart( |
| 1154 UCharIterator *iter, uint32_t state[2], |
| 1155 uint8_t *dest, int32_t count, UErrorCode &errorCode) const; |
| 1156 |
| 1157 #ifndef U_HIDE_INTERNAL_API |
| 1158 /** @internal */ |
| 1159 static inline Collator *fromUCollator(UCollator *uc) { |
| 1160 return reinterpret_cast<Collator *>(uc); |
| 1161 } |
| 1162 /** @internal */ |
| 1163 static inline const Collator *fromUCollator(const UCollator *uc) { |
| 1164 return reinterpret_cast<const Collator *>(uc); |
| 1165 } |
| 1166 /** @internal */ |
| 1167 inline UCollator *toUCollator() { |
| 1168 return reinterpret_cast<UCollator *>(this); |
| 1169 } |
| 1170 /** @internal */ |
| 1171 inline const UCollator *toUCollator() const { |
| 1172 return reinterpret_cast<const UCollator *>(this); |
| 1173 } |
| 1174 #endif // U_HIDE_INTERNAL_API |
| 1175 |
| 1111 private: | 1176 private: |
| 1112 /** | 1177 /** |
| 1113 * Assignment operator. Private for now. | 1178 * Assignment operator. Private for now. |
| 1114 * @internal | |
| 1115 */ | 1179 */ |
| 1116 Collator& operator=(const Collator& other); | 1180 Collator& operator=(const Collator& other); |
| 1117 | 1181 |
| 1118 friend class CFactory; | 1182 friend class CFactory; |
| 1119 friend class SimpleCFactory; | 1183 friend class SimpleCFactory; |
| 1120 friend class ICUCollatorFactory; | 1184 friend class ICUCollatorFactory; |
| 1121 friend class ICUCollatorService; | 1185 friend class ICUCollatorService; |
| 1122 static Collator* makeInstance(const Locale& desiredLocale, | 1186 static Collator* makeInstance(const Locale& desiredLocale, |
| 1123 UErrorCode& status); | 1187 UErrorCode& status); |
| 1124 | |
| 1125 // Collator private data members --------------------------------------- | |
| 1126 | |
| 1127 /* | |
| 1128 synwee : removed as attributes to be handled by child class | |
| 1129 UCollationStrength strength; | |
| 1130 Normalizer::EMode decmp; | |
| 1131 */ | |
| 1132 /* This is useless information */ | |
| 1133 /* static const UVersionInfo fVersion;*/ | |
| 1134 }; | 1188 }; |
| 1135 | 1189 |
| 1136 #if !UCONFIG_NO_SERVICE | 1190 #if !UCONFIG_NO_SERVICE |
| 1137 /** | 1191 /** |
| 1138 * A factory, used with registerFactory, the creates multiple collators and prov
ides | 1192 * A factory, used with registerFactory, the creates multiple collators and prov
ides |
| 1139 * display names for them. A factory supports some number of locales-- these ar
e the | 1193 * display names for them. A factory supports some number of locales-- these ar
e the |
| 1140 * locales for which it can create collators. The factory can be visible, in wh
ich | 1194 * locales for which it can create collators. The factory can be visible, in wh
ich |
| 1141 * case the supported locales will be enumerated by getAvailableLocales, or invi
sible, | 1195 * case the supported locales will be enumerated by getAvailableLocales, or invi
sible, |
| 1142 * in which they are not. Invisible locales are still supported, they are just
not | 1196 * in which they are not. Invisible locales are still supported, they are just
not |
| 1143 * listed by getAvailableLocales. | 1197 * listed by getAvailableLocales. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 }; | 1258 }; |
| 1205 #endif /* UCONFIG_NO_SERVICE */ | 1259 #endif /* UCONFIG_NO_SERVICE */ |
| 1206 | 1260 |
| 1207 // Collator inline methods ----------------------------------------------- | 1261 // Collator inline methods ----------------------------------------------- |
| 1208 | 1262 |
| 1209 U_NAMESPACE_END | 1263 U_NAMESPACE_END |
| 1210 | 1264 |
| 1211 #endif /* #if !UCONFIG_NO_COLLATION */ | 1265 #endif /* #if !UCONFIG_NO_COLLATION */ |
| 1212 | 1266 |
| 1213 #endif | 1267 #endif |
| OLD | NEW |