]> git.saurik.com Git - apple/icu.git/blame - icuSources/tools/gennorm2/extradata.h
ICU-64232.0.1.tar.gz
[apple/icu.git] / icuSources / tools / gennorm2 / extradata.h
CommitLineData
0f5d89e8
A
1// © 2017 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3
4// extradata.h
5// created: 2017jun04 Markus W. Scherer
6// (pulled out of n2builder.cpp)
7
8// Write mappings and compositions in compact form for Normalizer2 "extra data",
9// the data that does not fit into the trie itself.
10
11#ifndef __EXTRADATA_H__
12#define __EXTRADATA_H__
13
14#include "unicode/utypes.h"
15
16#if !UCONFIG_NO_NORMALIZATION
17
18#include "unicode/errorcode.h"
19#include "unicode/unistr.h"
20#include "unicode/utf16.h"
21#include "hash.h"
22#include "norms.h"
23#include "toolutil.h"
24#include "utrie2.h"
25#include "uvectr32.h"
26
27U_NAMESPACE_BEGIN
28
29class ExtraData : public Norms::Enumerator {
30public:
31 ExtraData(Norms &n, UBool fast);
32
33 void rangeHandler(UChar32 start, UChar32 end, Norm &norm) U_OVERRIDE;
34
35 UnicodeString maybeYesCompositions;
36 UnicodeString yesYesCompositions;
37 UnicodeString yesNoMappingsAndCompositions;
38 UnicodeString yesNoMappingsOnly;
39 UnicodeString noNoMappingsCompYes;
40 UnicodeString noNoMappingsCompBoundaryBefore;
41 UnicodeString noNoMappingsCompNoMaybeCC;
42 UnicodeString noNoMappingsEmpty;
43
44private:
45 /**
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.
50 */
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);
58
59 UBool optimizeFast;
60 Hashtable previousNoNoMappingsCompYes; // If constructed in runtime code, pass in UErrorCode.
61 Hashtable previousNoNoMappingsCompBoundaryBefore;
62 Hashtable previousNoNoMappingsCompNoMaybeCC;
63 Hashtable previousNoNoMappingsEmpty;
64};
65
66U_NAMESPACE_END
67
68#endif // #if !UCONFIG_NO_NORMALIZATION
69
70#endif // __EXTRADATA_H__