OLD | NEW |
(Empty) | |
| 1 /* |
| 2 ******************************************************************************* |
| 3 * |
| 4 * Copyright (C) 2009-2010, International Business Machines |
| 5 * Corporation and others. All Rights Reserved. |
| 6 * |
| 7 ******************************************************************************* |
| 8 * file name: n2builder.h |
| 9 * encoding: US-ASCII |
| 10 * tab size: 8 (not used) |
| 11 * indentation:4 |
| 12 * |
| 13 * created on: 2009nov25 |
| 14 * created by: Markus W. Scherer |
| 15 */ |
| 16 |
| 17 #ifndef __N2BUILDER_H__ |
| 18 #define __N2BUILDER_H__ |
| 19 |
| 20 #include "unicode/utypes.h" |
| 21 |
| 22 #if !UCONFIG_NO_NORMALIZATION |
| 23 |
| 24 #include "unicode/errorcode.h" |
| 25 #include "unicode/unistr.h" |
| 26 #include "normalizer2impl.h" // for IX_COUNT |
| 27 #include "toolutil.h" |
| 28 #include "utrie2.h" |
| 29 |
| 30 U_NAMESPACE_BEGIN |
| 31 |
| 32 extern UBool beVerbose, haveCopyright; |
| 33 |
| 34 struct Norm; |
| 35 |
| 36 class BuilderReorderingBuffer; |
| 37 class ExtraDataWriter; |
| 38 |
| 39 class Normalizer2DataBuilder { |
| 40 public: |
| 41 Normalizer2DataBuilder(UErrorCode &errorCode); |
| 42 ~Normalizer2DataBuilder(); |
| 43 |
| 44 enum OverrideHandling { |
| 45 OVERRIDE_NONE, |
| 46 OVERRIDE_ANY, |
| 47 OVERRIDE_PREVIOUS |
| 48 }; |
| 49 |
| 50 void setOverrideHandling(OverrideHandling oh); |
| 51 |
| 52 enum Optimization { |
| 53 OPTIMIZE_NORMAL, |
| 54 OPTIMIZE_FAST |
| 55 }; |
| 56 |
| 57 void setOptimization(Optimization opt) { optimization=opt; } |
| 58 |
| 59 void setCC(UChar32 c, uint8_t cc); |
| 60 void setOneWayMapping(UChar32 c, const UnicodeString &m); |
| 61 void setRoundTripMapping(UChar32 c, const UnicodeString &m); |
| 62 void removeMapping(UChar32 c); |
| 63 |
| 64 void setUnicodeVersion(const char *v); |
| 65 |
| 66 void writeBinaryFile(const char *filename); |
| 67 |
| 68 private: |
| 69 friend class CompositionBuilder; |
| 70 friend class Decomposer; |
| 71 friend class ExtraDataWriter; |
| 72 friend class Norm16Writer; |
| 73 |
| 74 // No copy constructor nor assignment operator. |
| 75 Normalizer2DataBuilder(const Normalizer2DataBuilder &other); |
| 76 Normalizer2DataBuilder &operator=(const Normalizer2DataBuilder &other); |
| 77 |
| 78 Norm *allocNorm(); |
| 79 Norm *getNorm(UChar32 c); |
| 80 Norm *createNorm(UChar32 c); |
| 81 Norm *checkNormForMapping(Norm *p, UChar32 c); // check for permitted overr
ides |
| 82 |
| 83 const Norm &getNormRef(UChar32 c) const; |
| 84 uint8_t getCC(UChar32 c) const; |
| 85 UBool combinesWithCCBetween(const Norm &norm, uint8_t lowCC, uint8_t highCC)
const; |
| 86 UChar32 combine(const Norm &norm, UChar32 trail) const; |
| 87 |
| 88 void addComposition(UChar32 start, UChar32 end, uint32_t value); |
| 89 UBool decompose(UChar32 start, UChar32 end, uint32_t value); |
| 90 void reorder(Norm *p, BuilderReorderingBuffer &buffer); |
| 91 UBool hasNoCompBoundaryAfter(BuilderReorderingBuffer &buffer); |
| 92 void setHangulData(); |
| 93 void writeMapping(UChar32 c, const Norm *p, UnicodeString &dataString); |
| 94 void writeCompositions(UChar32 c, const Norm *p, UnicodeString &dataString); |
| 95 void writeExtraData(UChar32 c, uint32_t value, ExtraDataWriter &writer); |
| 96 int32_t getCenterNoNoDelta() { |
| 97 return indexes[Normalizer2Impl::IX_MIN_MAYBE_YES]-Normalizer2Impl::MAX_D
ELTA-1; |
| 98 } |
| 99 void writeNorm16(UChar32 start, UChar32 end, uint32_t value); |
| 100 void processData(); |
| 101 |
| 102 UTrie2 *normTrie; |
| 103 UToolMemory *normMem; |
| 104 Norm *norms; |
| 105 |
| 106 int32_t phase; |
| 107 OverrideHandling overrideHandling; |
| 108 |
| 109 Optimization optimization; |
| 110 |
| 111 int32_t indexes[Normalizer2Impl::IX_COUNT]; |
| 112 UTrie2 *norm16Trie; |
| 113 UnicodeString extraData; |
| 114 |
| 115 UVersionInfo unicodeVersion; |
| 116 }; |
| 117 |
| 118 U_NAMESPACE_END |
| 119 |
| 120 #endif // #if !UCONFIG_NO_NORMALIZATION |
| 121 |
| 122 #endif // __N2BUILDER_H__ |
OLD | NEW |