ICU 49.1.1  49.1.1
ucol.h
Go to the documentation of this file.
00001 /*
00002 *******************************************************************************
00003 * Copyright (c) 1996-2012, International Business Machines Corporation and others.
00004 * All Rights Reserved.
00005 *******************************************************************************
00006 */
00007 
00008 #ifndef UCOL_H
00009 #define UCOL_H
00010 
00011 #include "unicode/utypes.h"
00012 
00013 #if !UCONFIG_NO_COLLATION
00014 
00015 #include "unicode/unorm.h"
00016 #include "unicode/localpointer.h"
00017 #include "unicode/parseerr.h"
00018 #include "unicode/uloc.h"
00019 #include "unicode/uset.h"
00020 #include "unicode/uscript.h"
00021 
00058 struct UCollator;
00062 typedef struct UCollator UCollator;
00063 
00064 
00077 typedef enum {
00079   UCOL_EQUAL    = 0,
00081   UCOL_GREATER    = 1,
00083   UCOL_LESS    = -1
00084 } UCollationResult ;
00085 
00086 
00093 typedef enum {
00095   UCOL_DEFAULT = -1,
00096 
00098   UCOL_PRIMARY = 0,
00100   UCOL_SECONDARY = 1,
00102   UCOL_TERTIARY = 2,
00104   UCOL_DEFAULT_STRENGTH = UCOL_TERTIARY,
00105   UCOL_CE_STRENGTH_LIMIT,
00107   UCOL_QUATERNARY=3,
00109   UCOL_IDENTICAL=15,
00110   UCOL_STRENGTH_LIMIT,
00111 
00115   UCOL_OFF = 16,
00119   UCOL_ON = 17,
00120   
00122   UCOL_SHIFTED = 20,
00124   UCOL_NON_IGNORABLE = 21,
00125 
00128   UCOL_LOWER_FIRST = 24,
00130   UCOL_UPPER_FIRST = 25,
00131 
00132   UCOL_ATTRIBUTE_VALUE_COUNT
00133 
00134 } UColAttributeValue;
00135 
00145  typedef enum {
00151     UCOL_REORDER_CODE_DEFAULT       = -1,
00156     UCOL_REORDER_CODE_NONE          = USCRIPT_UNKNOWN,
00163     UCOL_REORDER_CODE_OTHERS        = USCRIPT_UNKNOWN,
00169     UCOL_REORDER_CODE_SPACE         = 0x1000,
00175     UCOL_REORDER_CODE_FIRST         = UCOL_REORDER_CODE_SPACE,
00181     UCOL_REORDER_CODE_PUNCTUATION   = 0x1001,
00187     UCOL_REORDER_CODE_SYMBOL        = 0x1002,
00193     UCOL_REORDER_CODE_CURRENCY      = 0x1003,
00199     UCOL_REORDER_CODE_DIGIT         = 0x1004,
00205     UCOL_REORDER_CODE_LIMIT         = 0x1005
00206 } UColReorderCode;
00207 
00234 typedef UColAttributeValue UCollationStrength;
00235 
00240 typedef enum {
00245      UCOL_FRENCH_COLLATION, 
00254      UCOL_ALTERNATE_HANDLING, 
00261      UCOL_CASE_FIRST, 
00269      UCOL_CASE_LEVEL,
00277      UCOL_NORMALIZATION_MODE, 
00279      UCOL_DECOMPOSITION_MODE = UCOL_NORMALIZATION_MODE,
00290      UCOL_STRENGTH,  
00294      UCOL_HIRAGANA_QUATERNARY_MODE,
00302      UCOL_NUMERIC_COLLATION, 
00303      UCOL_ATTRIBUTE_COUNT
00304 } UColAttribute;
00305 
00309 typedef enum {
00311   UCOL_TAILORING_ONLY, 
00313   UCOL_FULL_RULES 
00314 } UColRuleOption ;
00315 
00333 U_STABLE UCollator* U_EXPORT2 
00334 ucol_open(const char *loc, UErrorCode *status);
00335 
00361 U_STABLE UCollator* U_EXPORT2 
00362 ucol_openRules( const UChar        *rules,
00363                 int32_t            rulesLength,
00364                 UColAttributeValue normalizationMode,
00365                 UCollationStrength strength,
00366                 UParseError        *parseError,
00367                 UErrorCode         *status);
00368 
00403 U_STABLE UCollator* U_EXPORT2
00404 ucol_openFromShortString( const char *definition,
00405                           UBool forceDefaults,
00406                           UParseError *parseError,
00407                           UErrorCode *status);
00408 
00409 #ifndef U_HIDE_DEPRECATED_API
00410 
00423 U_DEPRECATED int32_t U_EXPORT2
00424 ucol_getContractions( const UCollator *coll,
00425                   USet *conts,
00426                   UErrorCode *status);
00427 #endif  /* U_HIDE_DEPRECATED_API */
00428 
00440 U_STABLE void U_EXPORT2
00441 ucol_getContractionsAndExpansions( const UCollator *coll,
00442                   USet *contractions, USet *expansions,
00443                   UBool addPrefixes, UErrorCode *status);
00444 
00455 U_STABLE void U_EXPORT2 
00456 ucol_close(UCollator *coll);
00457 
00458 #if U_SHOW_CPLUSPLUS_API
00459 
00460 U_NAMESPACE_BEGIN
00461 
00471 U_DEFINE_LOCAL_OPEN_POINTER(LocalUCollatorPointer, UCollator, ucol_close);
00472 
00473 U_NAMESPACE_END
00474 
00475 #endif
00476 
00492 U_STABLE UCollationResult U_EXPORT2 
00493 ucol_strcoll(    const    UCollator    *coll,
00494         const    UChar        *source,
00495         int32_t            sourceLength,
00496         const    UChar        *target,
00497         int32_t            targetLength);
00498 
00513 U_STABLE UBool U_EXPORT2 
00514 ucol_greater(const UCollator *coll,
00515              const UChar     *source, int32_t sourceLength,
00516              const UChar     *target, int32_t targetLength);
00517 
00532 U_STABLE UBool U_EXPORT2 
00533 ucol_greaterOrEqual(const UCollator *coll,
00534                     const UChar     *source, int32_t sourceLength,
00535                     const UChar     *target, int32_t targetLength);
00536 
00551 U_STABLE UBool U_EXPORT2 
00552 ucol_equal(const UCollator *coll,
00553            const UChar     *source, int32_t sourceLength,
00554            const UChar     *target, int32_t targetLength);
00555 
00568 U_STABLE UCollationResult U_EXPORT2 
00569 ucol_strcollIter(  const    UCollator    *coll,
00570                   UCharIterator *sIter,
00571                   UCharIterator *tIter,
00572                   UErrorCode *status);
00573 
00583 U_STABLE UCollationStrength U_EXPORT2 
00584 ucol_getStrength(const UCollator *coll);
00585 
00595 U_STABLE void U_EXPORT2 
00596 ucol_setStrength(UCollator *coll,
00597                  UCollationStrength strength);
00598 
00615 U_DRAFT int32_t U_EXPORT2 
00616 ucol_getReorderCodes(const UCollator* coll,
00617                     int32_t* dest,
00618                     int32_t destCapacity,
00619                     UErrorCode *pErrorCode);
00655 U_DRAFT void U_EXPORT2 
00656 ucol_setReorderCodes(UCollator* coll,
00657                     const int32_t* reorderCodes,
00658                     int32_t reorderCodesLength,
00659                     UErrorCode *pErrorCode);
00660 
00677 U_DRAFT int32_t U_EXPORT2 
00678 ucol_getEquivalentReorderCodes(int32_t reorderCode,
00679                     int32_t* dest,
00680                     int32_t destCapacity,
00681                     UErrorCode *pErrorCode);
00682 
00695 U_STABLE int32_t U_EXPORT2 
00696 ucol_getDisplayName(    const    char        *objLoc,
00697             const    char        *dispLoc,
00698             UChar             *result,
00699             int32_t         resultLength,
00700             UErrorCode        *status);
00701 
00711 U_STABLE const char* U_EXPORT2 
00712 ucol_getAvailable(int32_t localeIndex);
00713 
00722 U_STABLE int32_t U_EXPORT2 
00723 ucol_countAvailable(void);
00724 
00725 #if !UCONFIG_NO_SERVICE
00726 
00734 U_STABLE UEnumeration* U_EXPORT2
00735 ucol_openAvailableLocales(UErrorCode *status);
00736 #endif
00737 
00747 U_STABLE UEnumeration* U_EXPORT2
00748 ucol_getKeywords(UErrorCode *status);
00749 
00761 U_STABLE UEnumeration* U_EXPORT2
00762 ucol_getKeywordValues(const char *keyword, UErrorCode *status);
00763 
00780 U_STABLE UEnumeration* U_EXPORT2
00781 ucol_getKeywordValuesForLocale(const char* key,
00782                                const char* locale,
00783                                UBool commonlyUsed,
00784                                UErrorCode* status);
00785 
00816 U_STABLE int32_t U_EXPORT2
00817 ucol_getFunctionalEquivalent(char* result, int32_t resultCapacity,
00818                              const char* keyword, const char* locale,
00819                              UBool* isAvailable, UErrorCode* status);
00820 
00829 U_STABLE const UChar* U_EXPORT2 
00830 ucol_getRules(    const    UCollator    *coll, 
00831         int32_t            *length);
00832 
00853 U_STABLE int32_t U_EXPORT2
00854 ucol_getShortDefinitionString(const UCollator *coll,
00855                               const char *locale,
00856                               char *buffer,
00857                               int32_t capacity,
00858                               UErrorCode *status);
00859 
00880 U_STABLE int32_t U_EXPORT2
00881 ucol_normalizeShortDefinitionString(const char *source,
00882                                     char *destination,
00883                                     int32_t capacity,
00884                                     UParseError *parseError,
00885                                     UErrorCode *status);
00886 
00887 
00907 U_STABLE int32_t U_EXPORT2 
00908 ucol_getSortKey(const    UCollator    *coll,
00909         const    UChar        *source,
00910         int32_t        sourceLength,
00911         uint8_t        *result,
00912         int32_t        resultLength);
00913 
00914 
00935 U_STABLE int32_t U_EXPORT2 
00936 ucol_nextSortKeyPart(const UCollator *coll,
00937                      UCharIterator *iter,
00938                      uint32_t state[2],
00939                      uint8_t *dest, int32_t count,
00940                      UErrorCode *status);
00941 
00949 typedef enum {
00951   UCOL_BOUND_LOWER = 0,
00953   UCOL_BOUND_UPPER = 1,
00955   UCOL_BOUND_UPPER_LONG = 2,
00956   UCOL_BOUND_VALUE_COUNT
00957 } UColBoundMode;
00958 
00996 U_STABLE int32_t U_EXPORT2 
00997 ucol_getBound(const uint8_t       *source,
00998         int32_t             sourceLength,
00999         UColBoundMode       boundType,
01000         uint32_t            noOfLevels,
01001         uint8_t             *result,
01002         int32_t             resultLength,
01003         UErrorCode          *status);
01004         
01013 U_STABLE void U_EXPORT2
01014 ucol_getVersion(const UCollator* coll, UVersionInfo info);
01015 
01023 U_STABLE void U_EXPORT2
01024 ucol_getUCAVersion(const UCollator* coll, UVersionInfo info);
01025 
01048 U_STABLE int32_t U_EXPORT2 
01049 ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length,
01050                    const uint8_t *src2, int32_t src2Length,
01051                    uint8_t *dest, int32_t destCapacity);
01052 
01064 U_STABLE void U_EXPORT2 
01065 ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status);
01066 
01078 U_STABLE UColAttributeValue  U_EXPORT2 
01079 ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status);
01080 
01100 U_STABLE uint32_t U_EXPORT2 
01101 ucol_setVariableTop(UCollator *coll, 
01102                     const UChar *varTop, int32_t len, 
01103                     UErrorCode *status);
01104 
01116 U_STABLE uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status);
01117 
01129 U_STABLE void U_EXPORT2 
01130 ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *status);
01131 
01154 U_STABLE UCollator* U_EXPORT2 
01155 ucol_safeClone(const UCollator *coll,
01156                void            *stackBuffer,
01157                int32_t         *pBufferSize,
01158                UErrorCode      *status);
01159 
01163 #define U_COL_SAFECLONE_BUFFERSIZE 528
01164 
01176 U_STABLE int32_t U_EXPORT2 
01177 ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen);
01178 
01179 #ifndef U_HIDE_DEPRECATED_API
01180 
01194 U_DEPRECATED const char * U_EXPORT2
01195 ucol_getLocale(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status);
01196 #endif  /* U_HIDE_DEPRECATED_API */
01197 
01212 U_STABLE const char * U_EXPORT2
01213 ucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status);
01214 
01225 U_STABLE USet * U_EXPORT2
01226 ucol_getTailoredSet(const UCollator *coll, UErrorCode *status);
01227 
01228 #ifndef U_HIDE_INTERNAL_API
01229 
01240 U_INTERNAL UColAttributeValue  U_EXPORT2
01241 ucol_getAttributeOrDefault(const UCollator *coll, UColAttribute attr, UErrorCode *status);
01242 
01251 U_INTERNAL UBool U_EXPORT2
01252 ucol_equals(const UCollator *source, const UCollator *target);
01253 
01265 U_INTERNAL int32_t U_EXPORT2
01266 ucol_getUnsafeSet( const UCollator *coll,
01267                   USet *unsafe,
01268                   UErrorCode *status);
01269 
01273 U_INTERNAL void U_EXPORT2
01274 ucol_forgetUCA(void);
01275 
01296 U_INTERNAL void U_EXPORT2
01297 ucol_prepareShortStringOpen( const char *definition,
01298                           UBool forceDefaults,
01299                           UParseError *parseError,
01300                           UErrorCode *status);
01301 #endif  /* U_HIDE_INTERNAL_API */
01302 
01314 U_STABLE int32_t U_EXPORT2
01315 ucol_cloneBinary(const UCollator *coll,
01316                  uint8_t *buffer, int32_t capacity,
01317                  UErrorCode *status);
01318 
01336 U_STABLE UCollator* U_EXPORT2
01337 ucol_openBinary(const uint8_t *bin, int32_t length, 
01338                 const UCollator *base, 
01339                 UErrorCode *status);
01340 
01341 
01342 #endif /* #if !UCONFIG_NO_COLLATION */
01343 
01344 #endif