1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/tools/gennorm2/n2builder.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,123 @@ 1.4 +/* 1.5 +******************************************************************************* 1.6 +* 1.7 +* Copyright (C) 2009-2011, International Business Machines 1.8 +* Corporation and others. All Rights Reserved. 1.9 +* 1.10 +******************************************************************************* 1.11 +* file name: n2builder.h 1.12 +* encoding: US-ASCII 1.13 +* tab size: 8 (not used) 1.14 +* indentation:4 1.15 +* 1.16 +* created on: 2009nov25 1.17 +* created by: Markus W. Scherer 1.18 +*/ 1.19 + 1.20 +#ifndef __N2BUILDER_H__ 1.21 +#define __N2BUILDER_H__ 1.22 + 1.23 +#include "unicode/utypes.h" 1.24 + 1.25 +#if !UCONFIG_NO_NORMALIZATION 1.26 + 1.27 +#include "unicode/errorcode.h" 1.28 +#include "unicode/unistr.h" 1.29 +#include "normalizer2impl.h" // for IX_COUNT 1.30 +#include "toolutil.h" 1.31 +#include "utrie2.h" 1.32 + 1.33 +U_NAMESPACE_BEGIN 1.34 + 1.35 +extern UBool beVerbose, haveCopyright; 1.36 + 1.37 +struct Norm; 1.38 + 1.39 +class BuilderReorderingBuffer; 1.40 +class ExtraDataWriter; 1.41 + 1.42 +class Normalizer2DataBuilder { 1.43 +public: 1.44 + Normalizer2DataBuilder(UErrorCode &errorCode); 1.45 + ~Normalizer2DataBuilder(); 1.46 + 1.47 + enum OverrideHandling { 1.48 + OVERRIDE_NONE, 1.49 + OVERRIDE_ANY, 1.50 + OVERRIDE_PREVIOUS 1.51 + }; 1.52 + 1.53 + void setOverrideHandling(OverrideHandling oh); 1.54 + 1.55 + enum Optimization { 1.56 + OPTIMIZE_NORMAL, 1.57 + OPTIMIZE_FAST 1.58 + }; 1.59 + 1.60 + void setOptimization(Optimization opt) { optimization=opt; } 1.61 + 1.62 + void setCC(UChar32 c, uint8_t cc); 1.63 + void setOneWayMapping(UChar32 c, const UnicodeString &m); 1.64 + void setRoundTripMapping(UChar32 c, const UnicodeString &m); 1.65 + void removeMapping(UChar32 c); 1.66 + 1.67 + void setUnicodeVersion(const char *v); 1.68 + 1.69 + void writeBinaryFile(const char *filename); 1.70 + 1.71 +private: 1.72 + friend class CompositionBuilder; 1.73 + friend class Decomposer; 1.74 + friend class ExtraDataWriter; 1.75 + friend class Norm16Writer; 1.76 + 1.77 + // No copy constructor nor assignment operator. 1.78 + Normalizer2DataBuilder(const Normalizer2DataBuilder &other); 1.79 + Normalizer2DataBuilder &operator=(const Normalizer2DataBuilder &other); 1.80 + 1.81 + Norm *allocNorm(); 1.82 + Norm *getNorm(UChar32 c); 1.83 + Norm *createNorm(UChar32 c); 1.84 + Norm *checkNormForMapping(Norm *p, UChar32 c); // check for permitted overrides 1.85 + 1.86 + const Norm &getNormRef(UChar32 c) const; 1.87 + uint8_t getCC(UChar32 c) const; 1.88 + UBool combinesWithCCBetween(const Norm &norm, uint8_t lowCC, uint8_t highCC) const; 1.89 + UChar32 combine(const Norm &norm, UChar32 trail) const; 1.90 + 1.91 + void addComposition(UChar32 start, UChar32 end, uint32_t value); 1.92 + UBool decompose(UChar32 start, UChar32 end, uint32_t value); 1.93 + void reorder(Norm *p, BuilderReorderingBuffer &buffer); 1.94 + UBool hasNoCompBoundaryAfter(BuilderReorderingBuffer &buffer); 1.95 + void setHangulData(); 1.96 + int32_t writeMapping(UChar32 c, const Norm *p, UnicodeString &dataString); 1.97 + void writeCompositions(UChar32 c, const Norm *p, UnicodeString &dataString); 1.98 + void writeExtraData(UChar32 c, uint32_t value, ExtraDataWriter &writer); 1.99 + int32_t getCenterNoNoDelta() { 1.100 + return indexes[Normalizer2Impl::IX_MIN_MAYBE_YES]-Normalizer2Impl::MAX_DELTA-1; 1.101 + } 1.102 + void writeNorm16(UChar32 start, UChar32 end, uint32_t value); 1.103 + void processData(); 1.104 + 1.105 + UTrie2 *normTrie; 1.106 + UToolMemory *normMem; 1.107 + Norm *norms; 1.108 + 1.109 + int32_t phase; 1.110 + OverrideHandling overrideHandling; 1.111 + 1.112 + Optimization optimization; 1.113 + 1.114 + int32_t indexes[Normalizer2Impl::IX_COUNT]; 1.115 + UTrie2 *norm16Trie; 1.116 + UnicodeString extraData; 1.117 + uint8_t smallFCD[0x100]; 1.118 + 1.119 + UVersionInfo unicodeVersion; 1.120 +}; 1.121 + 1.122 +U_NAMESPACE_END 1.123 + 1.124 +#endif // #if !UCONFIG_NO_NORMALIZATION 1.125 + 1.126 +#endif // __N2BUILDER_H__