]> git.saurik.com Git - apple/icu.git/blame - icuSources/tools/gennorm2/n2builder.h
ICU-551.51.4.tar.gz
[apple/icu.git] / icuSources / tools / gennorm2 / n2builder.h
CommitLineData
729e4ab9
A
1/*
2*******************************************************************************
3*
b331163b 4* Copyright (C) 2009-2014, International Business Machines
729e4ab9
A
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
30U_NAMESPACE_BEGIN
31
32extern UBool beVerbose, haveCopyright;
33
34struct Norm;
35
36class BuilderReorderingBuffer;
37class ExtraDataWriter;
38
39class Normalizer2DataBuilder {
40public:
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);
b331163b 67 void writeCSourceFile(const char *filename);
729e4ab9
A
68
69private:
70 friend class CompositionBuilder;
71 friend class Decomposer;
72 friend class ExtraDataWriter;
73 friend class Norm16Writer;
74
75 // No copy constructor nor assignment operator.
76 Normalizer2DataBuilder(const Normalizer2DataBuilder &other);
77 Normalizer2DataBuilder &operator=(const Normalizer2DataBuilder &other);
78
79 Norm *allocNorm();
80 Norm *getNorm(UChar32 c);
81 Norm *createNorm(UChar32 c);
82 Norm *checkNormForMapping(Norm *p, UChar32 c); // check for permitted overrides
83
84 const Norm &getNormRef(UChar32 c) const;
85 uint8_t getCC(UChar32 c) const;
86 UBool combinesWithCCBetween(const Norm &norm, uint8_t lowCC, uint8_t highCC) const;
87 UChar32 combine(const Norm &norm, UChar32 trail) const;
88
89 void addComposition(UChar32 start, UChar32 end, uint32_t value);
90 UBool decompose(UChar32 start, UChar32 end, uint32_t value);
91 void reorder(Norm *p, BuilderReorderingBuffer &buffer);
92 UBool hasNoCompBoundaryAfter(BuilderReorderingBuffer &buffer);
93 void setHangulData();
4388f060 94 int32_t writeMapping(UChar32 c, const Norm *p, UnicodeString &dataString);
729e4ab9
A
95 void writeCompositions(UChar32 c, const Norm *p, UnicodeString &dataString);
96 void writeExtraData(UChar32 c, uint32_t value, ExtraDataWriter &writer);
97 int32_t getCenterNoNoDelta() {
98 return indexes[Normalizer2Impl::IX_MIN_MAYBE_YES]-Normalizer2Impl::MAX_DELTA-1;
99 }
100 void writeNorm16(UChar32 start, UChar32 end, uint32_t value);
101 void processData();
102
103 UTrie2 *normTrie;
104 UToolMemory *normMem;
105 Norm *norms;
106
107 int32_t phase;
108 OverrideHandling overrideHandling;
109
110 Optimization optimization;
111
112 int32_t indexes[Normalizer2Impl::IX_COUNT];
113 UTrie2 *norm16Trie;
b331163b 114 int32_t norm16TrieLength;
729e4ab9 115 UnicodeString extraData;
4388f060 116 uint8_t smallFCD[0x100];
729e4ab9
A
117
118 UVersionInfo unicodeVersion;
119};
120
121U_NAMESPACE_END
122
123#endif // #if !UCONFIG_NO_NORMALIZATION
124
125#endif // __N2BUILDER_H__