2 *******************************************************************************
4 * Copyright (C) 2009-2014, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: n2builder.h
10 * tab size: 8 (not used)
13 * created on: 2009nov25
14 * created by: Markus W. Scherer
17 #ifndef __N2BUILDER_H__
18 #define __N2BUILDER_H__
20 #include "unicode/utypes.h"
22 #if !UCONFIG_NO_NORMALIZATION
24 #include "unicode/errorcode.h"
25 #include "unicode/unistr.h"
26 #include "normalizer2impl.h" // for IX_COUNT
32 extern UBool beVerbose
, haveCopyright
;
36 class BuilderReorderingBuffer
;
37 class ExtraDataWriter
;
39 class Normalizer2DataBuilder
{
41 Normalizer2DataBuilder(UErrorCode
&errorCode
);
42 ~Normalizer2DataBuilder();
44 enum OverrideHandling
{
50 void setOverrideHandling(OverrideHandling oh
);
57 void setOptimization(Optimization opt
) { optimization
=opt
; }
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
);
64 void setUnicodeVersion(const char *v
);
66 void writeBinaryFile(const char *filename
);
67 void writeCSourceFile(const char *filename
);
70 friend class CompositionBuilder
;
71 friend class Decomposer
;
72 friend class ExtraDataWriter
;
73 friend class Norm16Writer
;
75 // No copy constructor nor assignment operator.
76 Normalizer2DataBuilder(const Normalizer2DataBuilder
&other
);
77 Normalizer2DataBuilder
&operator=(const Normalizer2DataBuilder
&other
);
80 Norm
*getNorm(UChar32 c
);
81 Norm
*createNorm(UChar32 c
);
82 Norm
*checkNormForMapping(Norm
*p
, UChar32 c
); // check for permitted overrides
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;
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
);
94 int32_t writeMapping(UChar32 c
, const Norm
*p
, UnicodeString
&dataString
);
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;
100 void writeNorm16(UChar32 start
, UChar32 end
, uint32_t value
);
104 UToolMemory
*normMem
;
108 OverrideHandling overrideHandling
;
110 Optimization optimization
;
112 int32_t indexes
[Normalizer2Impl::IX_COUNT
];
114 int32_t norm16TrieLength
;
115 UnicodeString extraData
;
116 uint8_t smallFCD
[0x100];
118 UVersionInfo unicodeVersion
;
123 #endif // #if !UCONFIG_NO_NORMALIZATION
125 #endif // __N2BUILDER_H__