]> git.saurik.com Git - apple/icu.git/blame - icuSources/tools/gennorm2/n2builder.h
ICU-491.11.1.tar.gz
[apple/icu.git] / icuSources / tools / gennorm2 / n2builder.h
CommitLineData
729e4ab9
A
1/*
2*******************************************************************************
3*
4388f060 4* Copyright (C) 2009-2011, 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);
67
68private:
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 overrides
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();
4388f060 93 int32_t writeMapping(UChar32 c, const Norm *p, UnicodeString &dataString);
729e4ab9
A
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_DELTA-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;
4388f060 114 uint8_t smallFCD[0x100];
729e4ab9
A
115
116 UVersionInfo unicodeVersion;
117};
118
119U_NAMESPACE_END
120
121#endif // #if !UCONFIG_NO_NORMALIZATION
122
123#endif // __N2BUILDER_H__