Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | ******************************************************************************* |
michael@0 | 3 | * |
michael@0 | 4 | * Copyright (C) 2001-2008, International Business Machines |
michael@0 | 5 | * Corporation and others. All Rights Reserved. |
michael@0 | 6 | * |
michael@0 | 7 | ******************************************************************************* |
michael@0 | 8 | * file name: ucol_tok.cpp |
michael@0 | 9 | * encoding: US-ASCII |
michael@0 | 10 | * tab size: 8 (not used) |
michael@0 | 11 | * indentation:4 |
michael@0 | 12 | * |
michael@0 | 13 | * created 02/22/2001 |
michael@0 | 14 | * created by: Vladimir Weinstein |
michael@0 | 15 | * |
michael@0 | 16 | * This module maintains a contraction table structure in expanded form |
michael@0 | 17 | * and provides means to flatten this structure |
michael@0 | 18 | * |
michael@0 | 19 | */ |
michael@0 | 20 | |
michael@0 | 21 | #ifndef UCOL_CNTTABLE_H |
michael@0 | 22 | #define UCOL_CNTTABLE_H |
michael@0 | 23 | |
michael@0 | 24 | #include "unicode/utypes.h" |
michael@0 | 25 | |
michael@0 | 26 | #if !UCONFIG_NO_COLLATION |
michael@0 | 27 | |
michael@0 | 28 | #include "utrie.h" |
michael@0 | 29 | #include "ucol_imp.h" |
michael@0 | 30 | |
michael@0 | 31 | U_CDECL_BEGIN |
michael@0 | 32 | |
michael@0 | 33 | #define UPRV_CNTTAB_NEWELEMENT 0xFFFFFF |
michael@0 | 34 | |
michael@0 | 35 | #define isCntTableElement(CE) (isSpecial((CE)) && \ |
michael@0 | 36 | ((getCETag((CE)) == CONTRACTION_TAG)||(getCETag((CE)) == SPEC_PROC_TAG))) |
michael@0 | 37 | |
michael@0 | 38 | typedef struct ContractionTable ContractionTable; |
michael@0 | 39 | struct ContractionTable { |
michael@0 | 40 | UChar *codePoints; |
michael@0 | 41 | uint32_t *CEs; |
michael@0 | 42 | uint32_t position; |
michael@0 | 43 | uint32_t size; |
michael@0 | 44 | }; |
michael@0 | 45 | |
michael@0 | 46 | struct CntTable { |
michael@0 | 47 | ContractionTable **elements; |
michael@0 | 48 | /*CompactEIntArray *mapping;*/ |
michael@0 | 49 | UNewTrie *mapping; |
michael@0 | 50 | UChar *codePoints; |
michael@0 | 51 | uint32_t *CEs; |
michael@0 | 52 | int32_t *offsets; |
michael@0 | 53 | int32_t position; |
michael@0 | 54 | int32_t size; |
michael@0 | 55 | int32_t capacity; |
michael@0 | 56 | UColCETags currentTag; |
michael@0 | 57 | }; |
michael@0 | 58 | |
michael@0 | 59 | U_CAPI CntTable* U_EXPORT2 |
michael@0 | 60 | /*uprv_cnttab_open(CompactEIntArray *mapping, UErrorCode *status);*/ |
michael@0 | 61 | uprv_cnttab_open(UNewTrie *mapping, UErrorCode *status); |
michael@0 | 62 | U_CAPI CntTable* U_EXPORT2 |
michael@0 | 63 | uprv_cnttab_clone(CntTable *table, UErrorCode *status); |
michael@0 | 64 | U_CAPI void U_EXPORT2 |
michael@0 | 65 | uprv_cnttab_close(CntTable *table); |
michael@0 | 66 | |
michael@0 | 67 | /* construct the table for output */ |
michael@0 | 68 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 69 | uprv_cnttab_constructTable(CntTable *table, uint32_t mainOffset, UErrorCode *status); |
michael@0 | 70 | /* adds more contractions in table. If element is non existant, it creates on. Returns element handle */ |
michael@0 | 71 | U_CAPI uint32_t U_EXPORT2 |
michael@0 | 72 | uprv_cnttab_addContraction(CntTable *table, uint32_t element, UChar codePoint, uint32_t value, UErrorCode *status); |
michael@0 | 73 | /* sets a part of contraction sequence in table. If element is non existant, it creates on. Returns element handle */ |
michael@0 | 74 | U_CAPI uint32_t U_EXPORT2 |
michael@0 | 75 | uprv_cnttab_setContraction(CntTable *table, uint32_t element, uint32_t offset, UChar codePoint, uint32_t value, UErrorCode *status); |
michael@0 | 76 | /* inserts a part of contraction sequence in table. Sequences behind the offset are moved back. If element is non existant, it creates on. Returns element handle */ |
michael@0 | 77 | U_CAPI uint32_t U_EXPORT2 |
michael@0 | 78 | uprv_cnttab_insertContraction(CntTable *table, uint32_t element, UChar codePoint, uint32_t value, UErrorCode *status); |
michael@0 | 79 | /* this is for adding non contractions */ |
michael@0 | 80 | U_CAPI uint32_t U_EXPORT2 |
michael@0 | 81 | uprv_cnttab_changeLastCE(CntTable *table, uint32_t element, uint32_t value, UErrorCode *status); |
michael@0 | 82 | |
michael@0 | 83 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 84 | uprv_cnttab_findCP(CntTable *table, uint32_t element, UChar codePoint, UErrorCode *status); |
michael@0 | 85 | |
michael@0 | 86 | U_CAPI uint32_t U_EXPORT2 |
michael@0 | 87 | uprv_cnttab_getCE(CntTable *table, uint32_t element, uint32_t position, UErrorCode *status); |
michael@0 | 88 | |
michael@0 | 89 | U_CAPI uint32_t U_EXPORT2 |
michael@0 | 90 | uprv_cnttab_changeContraction(CntTable *table, uint32_t element, UChar codePoint, uint32_t newCE, UErrorCode *status); |
michael@0 | 91 | |
michael@0 | 92 | U_CAPI uint32_t U_EXPORT2 |
michael@0 | 93 | uprv_cnttab_findCE(CntTable *table, uint32_t element, UChar codePoint, UErrorCode *status); |
michael@0 | 94 | |
michael@0 | 95 | U_CAPI UBool U_EXPORT2 |
michael@0 | 96 | uprv_cnttab_isTailored(CntTable *table, uint32_t element, UChar *ztString, UErrorCode *status); |
michael@0 | 97 | |
michael@0 | 98 | U_CDECL_END |
michael@0 | 99 | |
michael@0 | 100 | #endif /* #if !UCONFIG_NO_COLLATION */ |
michael@0 | 101 | |
michael@0 | 102 | #endif |