intl/icu/source/tools/gennorm2/n2builder.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial