1 // © 2017 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
5 // created: 2017jun04 Markus W. Scherer
6 // (pulled out of n2builder.cpp)
8 // Write mappings and compositions in compact form for Normalizer2 "extra data",
9 // the data that does not fit into the trie itself.
11 #ifndef __EXTRADATA_H__
12 #define __EXTRADATA_H__
14 #include "unicode/utypes.h"
16 #if !UCONFIG_NO_NORMALIZATION
18 #include "unicode/errorcode.h"
19 #include "unicode/unistr.h"
20 #include "unicode/utf16.h"
29 class ExtraData
: public Norms::Enumerator
{
31 ExtraData(Norms
&n
, UBool fast
);
33 void rangeHandler(UChar32 start
, UChar32 end
, Norm
&norm
) U_OVERRIDE
;
35 UnicodeString maybeYesCompositions
;
36 UnicodeString yesYesCompositions
;
37 UnicodeString yesNoMappingsAndCompositions
;
38 UnicodeString yesNoMappingsOnly
;
39 UnicodeString noNoMappingsCompYes
;
40 UnicodeString noNoMappingsCompBoundaryBefore
;
41 UnicodeString noNoMappingsCompNoMaybeCC
;
42 UnicodeString noNoMappingsEmpty
;
46 * Requires norm.hasMapping().
47 * Returns the offset of the "first unit" from the beginning of the extraData for c.
48 * That is the same as the length of the optional data
49 * for the raw mapping and the ccc/lccc word.
51 int32_t writeMapping(UChar32 c
, const Norm
&norm
, UnicodeString
&dataString
);
52 int32_t writeNoNoMapping(UChar32 c
, const Norm
&norm
,
53 UnicodeString
&dataString
, Hashtable
&previousMappings
);
54 UBool
setNoNoDelta(UChar32 c
, Norm
&norm
) const;
55 /** Requires norm.compositions!=nullptr. */
56 void writeCompositions(UChar32 c
, const Norm
&norm
, UnicodeString
&dataString
);
57 void writeExtraData(UChar32 c
, Norm
&norm
);
60 Hashtable previousNoNoMappingsCompYes
; // If constructed in runtime code, pass in UErrorCode.
61 Hashtable previousNoNoMappingsCompBoundaryBefore
;
62 Hashtable previousNoNoMappingsCompNoMaybeCC
;
63 Hashtable previousNoNoMappingsEmpty
;
68 #endif // #if !UCONFIG_NO_NORMALIZATION
70 #endif // __EXTRADATA_H__