-U_NAMESPACE_BEGIN
-
-class SortKeyByteSink;
-
-U_NAMESPACE_END
-
-/* function used by C++ getCollationKey to prevent restarting the calculation */
-U_CFUNC int32_t
-ucol_getSortKeyWithAllocation(const UCollator *coll,
- const UChar *source, int32_t sourceLength,
- uint8_t *&result, int32_t &resultCapacity,
- UErrorCode *pErrorCode);
-
-typedef void U_CALLCONV
-SortKeyGenerator(const UCollator *coll,
- const UChar *source,
- int32_t sourceLength,
- icu::SortKeyByteSink &result,
- UErrorCode *status);
-
-/* worker function for generating sortkeys */
-U_CFUNC
-void U_CALLCONV
-ucol_calcSortKey(const UCollator *coll,
- const UChar *source,
- int32_t sourceLength,
- icu::SortKeyByteSink &result,
- UErrorCode *status);
-
-U_CFUNC
-void U_CALLCONV
-ucol_calcSortKeySimpleTertiary(const UCollator *coll,
- const UChar *source,
- int32_t sourceLength,
- icu::SortKeyByteSink &result,
- UErrorCode *status);
-
-#else
-
-typedef void U_CALLCONV
-SortKeyGenerator(const UCollator *coll,
- const UChar *source,
- int32_t sourceLength,
- void *result,
- UErrorCode *status);
-
-#endif
-
-/**
- * Makes a copy of the Collator's rule data. The format is
- * that of .col files.
- *
- * @param length returns the length of the data, in bytes.
- * @param status the error status
- * @return memory, owned by the caller, of size 'length' bytes.
- * @internal INTERNAL USE ONLY
- */
-U_CFUNC uint8_t* U_EXPORT2
-ucol_cloneRuleData(const UCollator *coll, int32_t *length, UErrorCode *status);
-
-/**
- * Used to set requested and valid locales on a collator returned by the collator
- * service.
- */
-U_CFUNC void U_EXPORT2
-ucol_setReqValidLocales(UCollator *coll, char *requestedLocaleToAdopt, char *validLocaleToAdopt, char *actualLocaleToAdopt);
-
-#define UCOL_SPECIAL_FLAG 0xF0000000
-#define UCOL_TAG_SHIFT 24
-#define UCOL_TAG_MASK 0x0F000000
-#define INIT_EXP_TABLE_SIZE 1024
-#define UCOL_NOT_FOUND 0xF0000000
-#define UCOL_EXPANSION 0xF1000000
-#define UCOL_CONTRACTION 0xF2000000
-#define UCOL_THAI 0xF3000000
-#define UCOL_UNMARKED 0x03
-#define UCOL_NEW_TERTIARYORDERMASK 0x0000003f
-
-/* Bit mask for primary collation strength. */
-#define UCOL_PRIMARYMASK 0xFFFF0000
-
-/* Bit mask for secondary collation strength. */
-#define UCOL_SECONDARYMASK 0x0000FF00
-
-/* Bit mask for tertiary collation strength. */
-#define UCOL_TERTIARYMASK 0x000000FF
-
-/**
- * Internal.
- * This indicates the last element in a UCollationElements has been consumed.
- * Compare with the UCOL_NULLORDER, UCOL_NULLORDER is returned if error occurs.
- */
-#define UCOL_NO_MORE_CES 0x00010101
-#define UCOL_NO_MORE_CES_PRIMARY 0x00010000
-#define UCOL_NO_MORE_CES_SECONDARY 0x00000100
-#define UCOL_NO_MORE_CES_TERTIARY 0x00000001
-
-#define isSpecial(CE) ((((CE)&UCOL_SPECIAL_FLAG)>>28)==0xF)
-
-#define UCOL_UPPER_CASE 0x80
-#define UCOL_MIXED_CASE 0x40
-#define UCOL_LOWER_CASE 0x00
-
-#define UCOL_CONTINUATION_MARKER 0xC0
-#define UCOL_REMOVE_CONTINUATION 0xFFFFFF3F
-
-#define isContinuation(CE) (((CE) & UCOL_CONTINUATION_MARKER) == UCOL_CONTINUATION_MARKER)
-#define isFlagged(CE) (((CE) & 0x80) == 0x80)
-#define isLongPrimary(CE) (((CE) & 0xC0) == 0xC0)
-
-#define getCETag(CE) (((CE)&UCOL_TAG_MASK)>>UCOL_TAG_SHIFT)
-#define isContraction(CE) (isSpecial((CE)) && (getCETag((CE)) == CONTRACTION_TAG))
-#define isPrefix(CE) (isSpecial((CE)) && (getCETag((CE)) == SPEC_PROC_TAG))
-#define constructContractCE(tag, CE) (UCOL_SPECIAL_FLAG | ((tag)<<UCOL_TAG_SHIFT) | ((CE)&0xFFFFFF))
-#define constructSpecProcCE(CE) (UCOL_SPECIAL_FLAG | (SPEC_PROC_TAG<<UCOL_TAG_SHIFT) | ((CE)&0xFFFFFF))
-#define getContractOffset(CE) ((CE)&0xFFFFFF)
-#define getExpansionOffset(CE) (((CE)&0x00FFFFF0)>>4)
-#define getExpansionCount(CE) ((CE)&0xF)
-#define isCEIgnorable(CE) (((CE) & 0xFFFFFFBF) == 0)
-
-/* StringSearch internal use */
-#define inNormBuf(coleiter) ((coleiter)->iteratordata_.flags & UCOL_ITER_INNORMBUF)
-#define isFCDPointerNull(coleiter) ((coleiter)->iteratordata_.fcdPosition == NULL)
-#define hasExpansion(coleiter) ((coleiter)->iteratordata_.CEpos != (coleiter)->iteratordata_.CEs)
-#define getExpansionPrefix(coleiter) ((coleiter)->iteratordata_.toReturn - (coleiter)->iteratordata_.CEs)
-#define setExpansionPrefix(coleiter, offset) ((coleiter)->iteratordata_.CEs + offset)
-#define getExpansionSuffix(coleiter) ((coleiter)->iteratordata_.CEpos - (coleiter)->iteratordata_.toReturn)
-#define setExpansionSuffix(coleiter, offset) ((coleiter)->iteratordata_.toReturn = (coleiter)->iteratordata_.CEpos - leftoverces)
-
-/* This is an enum that lists magic special byte values from the fractional UCA.
- * See also http://site.icu-project.org/design/collation/bytes */
-/* TODO: all the #defines that refer to special byte values from the UCA should be changed to point here */
-
-enum {
- UCOL_BYTE_ZERO = 0x00,
- UCOL_BYTE_LEVEL_SEPARATOR = 0x01,
- UCOL_BYTE_SORTKEY_GLUE = 0x02,
- UCOL_BYTE_SHIFT_PREFIX = 0x03,
- UCOL_BYTE_UNSHIFTED_MIN = UCOL_BYTE_SHIFT_PREFIX,
- UCOL_BYTE_FIRST_TAILORED = 0x04,
- UCOL_BYTE_COMMON = 0x05,
- UCOL_BYTE_FIRST_UCA = UCOL_BYTE_COMMON,
- /* TODO: Make the following values dynamic since they change with almost every UCA version. */
- UCOL_CODAN_PLACEHOLDER = 0x12,
- UCOL_BYTE_FIRST_NON_LATIN_PRIMARY = 0x5B,
- UCOL_BYTE_UNSHIFTED_MAX = 0xFF
-};
-
-#if 0
-#define UCOL_RESET_TOP_VALUE 0x9F000303
-#define UCOL_FIRST_PRIMARY_IGNORABLE 0x00008705
-#define UCOL_LAST_PRIMARY_IGNORABLE 0x0000DD05
-#define UCOL_LAST_PRIMARY_IGNORABLE_CONT 0x000051C0
-#define UCOL_FIRST_SECONDARY_IGNORABLE 0x00000000
-#define UCOL_LAST_SECONDARY_IGNORABLE 0x00000500
-#define UCOL_FIRST_TERTIARY_IGNORABLE 0x00000000
-#define UCOL_LAST_TERTIARY_IGNORABLE 0x00000000
-#define UCOL_FIRST_VARIABLE 0x05070505
-#define UCOL_LAST_VARIABLE 0x179B0505
-#define UCOL_FIRST_NON_VARIABLE 0x1A200505
-#define UCOL_LAST_NON_VARIABLE 0x7B41058F
-
-#define UCOL_NEXT_TOP_VALUE 0xE8960303
-#define UCOL_NEXT_FIRST_PRIMARY_IGNORABLE 0x00008905
-#define UCOL_NEXT_LAST_PRIMARY_IGNORABLE 0x03000303
-#define UCOL_NEXT_FIRST_SECONDARY_IGNORABLE 0x00008705
-#define UCOL_NEXT_LAST_SECONDARY_IGNORABLE 0x00000500
-#define UCOL_NEXT_FIRST_TERTIARY_IGNORABLE 0x00000000
-#define UCOL_NEXT_LAST_TERTIARY_IGNORABLE 0x00000000
-#define UCOL_NEXT_FIRST_VARIABLE 0x05090505
-#define UCOL_NEXT_LAST_VARIABLE 0x1A200505
-
-#define PRIMARY_IMPLICIT_MIN 0xE8000000
-#define PRIMARY_IMPLICIT_MAX 0xF0000000
-#endif
-
-/* These constants can be changed - sortkey size is affected by them */
-#define UCOL_PROPORTION2 0.5
-#define UCOL_PROPORTION3 0.667
-
-/* These values come from the UCA */
-#define UCOL_COMMON_BOT2 UCOL_BYTE_COMMON
-#define UCOL_COMMON_TOP2 0x86u
-#define UCOL_TOTAL2 (UCOL_COMMON_TOP2-UCOL_COMMON_BOT2-1)
-
-#define UCOL_FLAG_BIT_MASK_CASE_SW_OFF 0x80
-#define UCOL_FLAG_BIT_MASK_CASE_SW_ON 0x40
-#define UCOL_COMMON_TOP3_CASE_SW_OFF 0x85
-#define UCOL_COMMON_TOP3_CASE_SW_LOWER 0x45
-#define UCOL_COMMON_TOP3_CASE_SW_UPPER 0xC5
-
-/* These values come from the UCA */
-#define UCOL_COMMON_BOT3 0x05
-
-#define UCOL_COMMON_BOTTOM3_CASE_SW_UPPER 0x86;
-#define UCOL_COMMON_BOTTOM3_CASE_SW_LOWER UCOL_COMMON_BOT3;
-
-#define UCOL_TOP_COUNT2 (UCOL_PROPORTION2*UCOL_TOTAL2)
-#define UCOL_BOT_COUNT2 (UCOL_TOTAL2-UCOL_TOP_COUNT2)
-
-
-#define UCOL_COMMON2 UCOL_COMMON_BOT2
-#define UCOL_COMMON3_UPPERFIRST 0xC5
-#define UCOL_COMMON3_NORMAL UCOL_COMMON_BOT3
-
-#define UCOL_COMMON4 0xFF
-
-/* constants for case level/case first handling */
-/* used to instantiate UCollators fields in ucol_updateInternalState */
-#define UCOL_CASE_SWITCH 0xC0
-#define UCOL_NO_CASE_SWITCH 0x00
-
-#define UCOL_REMOVE_CASE 0x3F
-#define UCOL_KEEP_CASE 0xFF
-
-#define UCOL_CASE_BIT_MASK 0xC0
-
-#define UCOL_TERT_CASE_MASK 0xFF
-
-#define UCOL_ENDOFLATINONERANGE 0xFF
-#define UCOL_LATINONETABLELEN (UCOL_ENDOFLATINONERANGE+50)
-#define UCOL_BAIL_OUT_CE 0xFF000000
-
-
-typedef enum {
- NOT_FOUND_TAG = 0,
- EXPANSION_TAG = 1, /* This code point results in an expansion */
- CONTRACTION_TAG = 2, /* Start of a contraction */
- THAI_TAG = 3, /* Thai character - do the reordering */
- CHARSET_TAG = 4, /* Charset processing, not yet implemented */
- SURROGATE_TAG = 5, /* Lead surrogate that is tailored and doesn't start a contraction */
- HANGUL_SYLLABLE_TAG = 6, /* AC00-D7AF*/
- LEAD_SURROGATE_TAG = 7, /* D800-DBFF*/
- TRAIL_SURROGATE_TAG = 8, /* DC00-DFFF*/
- CJK_IMPLICIT_TAG = 9, /* 0x3400-0x4DB5, 0x4E00-0x9FA5, 0xF900-0xFA2D*/
- IMPLICIT_TAG = 10,
- SPEC_PROC_TAG = 11,
- /* ICU 2.1 */
- LONG_PRIMARY_TAG = 12, /* This is a three byte primary with starting secondaries and tertiaries */
- /* It fits in a single 32 bit CE and is used instead of expansion to save */
- /* space without affecting the performance (hopefully) */
-
- DIGIT_TAG = 13, /* COllate Digits As Numbers (CODAN) implementation */
-
- CE_TAGS_COUNT
-} UColCETags;
-
-/*
- *****************************************************************************************
- * set to zero
- * NON_CHARACTER FDD0 - FDEF, FFFE, FFFF, 1FFFE, 1FFFF, 2FFFE, 2FFFF,...e.g. **FFFE, **FFFF
- ******************************************************************************************
- */
-
-typedef struct {
- uint32_t variableTopValue;
- /*UColAttributeValue*/ int32_t frenchCollation;
- /*UColAttributeValue*/ int32_t alternateHandling; /* attribute for handling variable elements*/
- /*UColAttributeValue*/ int32_t caseFirst; /* who goes first, lower case or uppercase */
- /*UColAttributeValue*/ int32_t caseLevel; /* do we have an extra case level */
- /*UColAttributeValue*/ int32_t normalizationMode; /* attribute for normalization */
- /*UColAttributeValue*/ int32_t strength; /* attribute for strength */
- /*UColAttributeValue*/ int32_t hiraganaQ; /* attribute for special Hiragana */
- /*UColAttributeValue*/ int32_t numericCollation; /* attribute for numeric collation */
- uint32_t reserved[15]; /* for future use */
-} UColOptionSet;
-
-typedef struct {
- uint32_t UCA_FIRST_TERTIARY_IGNORABLE[2]; /*0x00000000*/
- uint32_t UCA_LAST_TERTIARY_IGNORABLE[2]; /*0x00000000*/
- uint32_t UCA_FIRST_PRIMARY_IGNORABLE[2]; /*0x00008705*/
- uint32_t UCA_FIRST_SECONDARY_IGNORABLE[2]; /*0x00000000*/
- uint32_t UCA_LAST_SECONDARY_IGNORABLE[2]; /*0x00000500*/
- uint32_t UCA_LAST_PRIMARY_IGNORABLE[2]; /*0x0000DD05*/
- uint32_t UCA_FIRST_VARIABLE[2]; /*0x05070505*/
- uint32_t UCA_LAST_VARIABLE[2]; /*0x13CF0505*/
- uint32_t UCA_FIRST_NON_VARIABLE[2]; /*0x16200505*/
- uint32_t UCA_LAST_NON_VARIABLE[2]; /*0x767C0505*/
- uint32_t UCA_RESET_TOP_VALUE[2]; /*0x9F000303*/
- uint32_t UCA_FIRST_IMPLICIT[2];
- uint32_t UCA_LAST_IMPLICIT[2];
- uint32_t UCA_FIRST_TRAILING[2];
- uint32_t UCA_LAST_TRAILING[2];
-
-#if 0
- uint32_t UCA_NEXT_TOP_VALUE[2]; /*0xE8960303*/
- uint32_t UCA_NEXT_FIRST_PRIMARY_IGNORABLE; /*0x00008905*/
- uint32_t UCA_NEXT_LAST_PRIMARY_IGNORABLE; /*0x03000303*/
- uint32_t UCA_NEXT_FIRST_SECONDARY_IGNORABLE; /*0x00008705*/
- uint32_t UCA_NEXT_LAST_SECONDARY_IGNORABLE; /*0x00000500*/
- uint32_t UCA_NEXT_FIRST_TERTIARY_IGNORABLE; /*0x00000000*/
- uint32_t UCA_NEXT_LAST_TERTIARY_IGNORABLE; /*0x00000000*/
- uint32_t UCA_NEXT_FIRST_VARIABLE; /*0x05090505*/
- uint32_t UCA_NEXT_LAST_VARIABLE; /*0x16200505*/
-#endif
-
- uint32_t UCA_PRIMARY_TOP_MIN;
- uint32_t UCA_PRIMARY_IMPLICIT_MIN; /*0xE8000000*/
- uint32_t UCA_PRIMARY_IMPLICIT_MAX; /*0xF0000000*/
- uint32_t UCA_PRIMARY_TRAILING_MIN; /*0xE8000000*/
- uint32_t UCA_PRIMARY_TRAILING_MAX; /*0xF0000000*/
- uint32_t UCA_PRIMARY_SPECIAL_MIN; /*0xE8000000*/
- uint32_t UCA_PRIMARY_SPECIAL_MAX; /*0xF0000000*/
-} UCAConstants;
-
-/* definition of UCATableHeader moved to common/ucol_data.h */
-
-#define U_UNKNOWN_STATE 0
-#define U_COLLATOR_STATE 0x01
-#define U_STATE_LIMIT 0x02
-
-/* This is the first structure in a state */
-/* it should be machine independent */
-typedef struct {
- /* this structure is supposed to be readable on all the platforms.*/
- /* first 2 fields hold the size of the structure in a platform independent way */
- uint8_t sizeLo;
- uint8_t sizeHi;
- /* identifying the writing platform */
- uint8_t isBigEndian;
- /* see U_CHARSET_FAMILY values in utypes.h */
- uint8_t charsetFamily;
- /* version of ICU this state structure comes from */
- uint8_t icuVersion[4];
- /* What is the data following this state */
- uint8_t type;
- /* more stuff to come, keep it on 16 byte boundary */
- uint8_t reserved[7];
-} UStateStruct;
-
-/* This structure follows UStatusStruct */
-/* and contains data specific for the collators */
-/* Endianess needs to be decided before accessing this structure */
-/* However, it's size IS endianess independent */
-typedef struct {
- /* size of this structure */
- uint8_t sizeLo;
- uint8_t sizeHi;
- /* This state is followed by the frozen tailoring */
- uint8_t containsTailoring;
- /* This state is followed by the frozen UCA */
- uint8_t containsUCA;
- /* Version info - the same one */
- uint8_t versionInfo[4];
-
- /* for charset CEs */
- uint8_t charsetName[32];
- /* this is the resolved locale name*/
- uint8_t locale[32];
-
- /* Attributes. Open ended */
- /* all the following will be moved to uint32_t because of portability */
- /* variable top value */
- uint32_t variableTopValue;
- /* attribute for handling variable elements*/
- uint32_t /*UColAttributeValue*/ alternateHandling;
- /* how to handle secondary weights */
- uint32_t /*UColAttributeValue*/ frenchCollation;
- /* who goes first, lower case or uppercase */
- uint32_t /*UColAttributeValue*/ caseFirst;
- /* do we have an extra case level */
- uint32_t /*UColAttributeValue*/ caseLevel;
- /* attribute for normalization */
- uint32_t /*UColAttributeValue*/ normalizationMode;
- /* attribute for strength */
- uint32_t /*UColAttributeValue*/ strength;
- /* to be immediately 16 byte aligned */
- uint8_t reserved[12];
-} UColStateStruct;
-
-#define UCOL_INV_SIZEMASK 0xFFF00000
-#define UCOL_INV_OFFSETMASK 0x000FFFFF
-#define UCOL_INV_SHIFTVALUE 20