1 /* 2 ******************************************************************************* 3 * 4 * Copyright (C) 2000-2006, International Business Machines 5 * Corporation and others. All Rights Reserved. 6 * 7 ******************************************************************************* 8 * file name: ucol_elm.h 9 * encoding: US-ASCII 10 * tab size: 8 (not used) 11 * indentation:4 12 * 13 * created 02/22/2001 14 * created by: Vladimir Weinstein 15 * 16 * This program reads the Franctional UCA table and generates 17 * internal format for UCA table as well as inverse UCA table. 18 * It then writes binary files containing the data: ucadata.dat 19 * & invuca.dat 20 */ 21 #ifndef UCOL_UCAELEMS_H 22 #define UCOL_UCAELEMS_H 23 24 #include "unicode/utypes.h" 25 #include "ucol_tok.h" 26 27 #if !UCONFIG_NO_COLLATION 28 29 #include "ucol_cnt.h" 30 #include "ucol_imp.h" 31 32 #ifdef UCOL_DEBUG 33 #include "cmemory.h" 34 #include <stdio.h> 35 #endif 36 37 U_CDECL_BEGIN 38 39 /* This is the maximum trie capacity for the mapping trie. 40 Due to current limitations in genuca and the design of UTrie, 41 this number can't be more than 256K. 42 As of Unicode 5, it currently could safely go to 128K without 43 a problem. Normally, less than 32K are tailored. 44 */ 45 #define UCOL_ELM_TRIE_CAPACITY 0x40000 46 47 /* This is the maxmun capacity for temparay combining class 48 * table. The table will be compacted after scanning all the 49 * Unicode codepoints. 50 */ 51 #define UCOL_MAX_CM_TAB 0x10000 52 53 54 typedef struct { 55 uint32_t *CEs; 56 int32_t position; 57 int32_t size; 58 } ExpansionTable; 59 60 typedef struct { 61 UChar prefixChars[128]; 62 UChar *prefix; 63 uint32_t prefixSize; 64 UChar uchars[128]; 65 UChar *cPoints; 66 uint32_t cSize; /* Number of characters in sequence - for contraction */ 67 uint32_t noOfCEs; /* Number of collation elements */ 68 uint32_t CEs[128]; /* These are collation elements - there could be more than one - in case of expansion */ 69 uint32_t mapCE; /* This is the value element maps in original table */ 70 uint32_t sizePrim[128]; 71 uint32_t sizeSec[128]; 72 uint32_t sizeTer[128]; 73 UBool variableTop; 74 UBool caseBit; 75 UBool isThai; 76 } UCAElements; 77 78 typedef struct { 79 uint32_t *endExpansionCE; 80 UBool *isV; 81 int32_t position; 82 int32_t size; 83 uint8_t maxLSize; 84 uint8_t maxVSize; 85 uint8_t maxTSize; 86 } MaxJamoExpansionTable; 87 88 typedef struct { 89 uint32_t *endExpansionCE; 90 uint8_t *expansionCESize; 91 int32_t position; 92 int32_t size; 93 } MaxExpansionTable; 94 95 typedef struct { 96 uint16_t index[256]; /* index of cPoints by combining class 0-255. */ 97 UChar *cPoints; /* code point array of all combining marks */ 98 uint32_t size; /* total number of combining marks */ 99 } CombinClassTable; 100 101 typedef struct { 102 /*CompactEIntArray *mapping; */ 103 UNewTrie *mapping; 104 ExpansionTable *expansions; 105 struct CntTable *contractions; 106 UCATableHeader *image; 107 UColOptionSet *options; 108 MaxExpansionTable *maxExpansions; 109 MaxJamoExpansionTable *maxJamoExpansions; 110 uint8_t *unsafeCP; 111 uint8_t *contrEndCP; 112 const UCollator *UCA; 113 UHashtable *prefixLookup; 114 CombinClassTable *cmLookup; /* combining class lookup for tailoring. */ 115 } tempUCATable; 116 117 typedef struct { 118 UChar cp; 119 uint16_t cClass; // combining class 120 }CompData; 121 122 typedef struct { 123 CompData *precomp; 124 int32_t precompLen; 125 UChar *decomp; 126 int32_t decompLen; 127 UChar *comp; 128 int32_t compLen; 129 uint16_t curClass; 130 uint16_t tailoringCM; 131 int32_t cmPos; 132 }tempTailorContext; 133 134 U_CAPI tempUCATable * U_EXPORT2 uprv_uca_initTempTable(UCATableHeader *image, UColOptionSet *opts, const UCollator *UCA, UColCETags initTag, UColCETags supplementaryInitTag, UErrorCode *status); 135 U_CAPI tempUCATable * U_EXPORT2 uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status); 136 U_CAPI void U_EXPORT2 uprv_uca_closeTempTable(tempUCATable *t); 137 U_CAPI uint32_t U_EXPORT2 uprv_uca_addAnElement(tempUCATable *t, UCAElements *element, UErrorCode *status); 138 U_CAPI UCATableHeader * U_EXPORT2 uprv_uca_assembleTable(tempUCATable *t, UErrorCode *status); 139 U_CAPI int32_t U_EXPORT2 140 uprv_uca_canonicalClosure(tempUCATable *t, UColTokenParser *src, UErrorCode *status); 141 #define paddedsize(something) ((something)+((((something)%4)!=0)?(4-(something)%4):0)) 142 #define headersize (paddedsize(sizeof(UCATableHeader))+paddedsize(sizeof(UColOptionSet))) 143 144 U_CDECL_END 145 146 #endif /* #if !UCONFIG_NO_COLLATION */ 147 148 #endif 149