1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html |
3 | /* |
4 | ********************************************************************** |
5 | * Copyright (C) 2001-2010, International Business Machines |
6 | * Corporation and others. All Rights Reserved. |
7 | ********************************************************************** |
8 | * Date Name Description |
9 | * 07/03/01 aliu Creation. |
10 | ********************************************************************** |
11 | */ |
12 | #ifndef NORTRANS_H |
13 | #define NORTRANS_H |
14 | |
15 | #include "unicode/utypes.h" |
16 | |
17 | #if !UCONFIG_NO_TRANSLITERATION |
18 | |
19 | #include "unicode/translit.h" |
20 | #include "unicode/normalizer2.h" |
21 | |
22 | U_NAMESPACE_BEGIN |
23 | |
24 | /** |
25 | * A transliterator that performs normalization. |
26 | * @author Alan Liu |
27 | */ |
28 | class NormalizationTransliterator : public Transliterator { |
29 | const Normalizer2 &fNorm2; |
30 | |
31 | public: |
32 | |
33 | /** |
34 | * Destructor. |
35 | */ |
36 | virtual ~NormalizationTransliterator(); |
37 | |
38 | /** |
39 | * Copy constructor. |
40 | */ |
41 | NormalizationTransliterator(const NormalizationTransliterator&); |
42 | |
43 | /** |
44 | * Transliterator API. |
45 | * @return A copy of the object. |
46 | */ |
47 | virtual NormalizationTransliterator* clone() const; |
48 | |
49 | /** |
50 | * ICU "poor man's RTTI", returns a UClassID for the actual class. |
51 | */ |
52 | virtual UClassID getDynamicClassID() const; |
53 | |
54 | /** |
55 | * ICU "poor man's RTTI", returns a UClassID for this class. |
56 | */ |
57 | U_I18N_API static UClassID U_EXPORT2 getStaticClassID(); |
58 | |
59 | protected: |
60 | |
61 | /** |
62 | * Implements {@link Transliterator#handleTransliterate}. |
63 | * @param text the buffer holding transliterated and |
64 | * untransliterated text |
65 | * @param offset the start and limit of the text, the position |
66 | * of the cursor, and the start and limit of transliteration. |
67 | * @param incremental if true, assume more text may be coming after |
68 | * pos.contextLimit. Otherwise, assume the text is complete. |
69 | */ |
70 | virtual void handleTransliterate(Replaceable& text, UTransPosition& offset, |
71 | UBool isIncremental) const; |
72 | public: |
73 | |
74 | /** |
75 | * System registration hook. Public to Transliterator only. |
76 | */ |
77 | static void registerIDs(); |
78 | |
79 | private: |
80 | |
81 | // Transliterator::Factory methods |
82 | static Transliterator* _create(const UnicodeString& ID, |
83 | Token context); |
84 | |
85 | /** |
86 | * Constructs a transliterator. This method is private. |
87 | * Public users must use the factory method createInstance(). |
88 | */ |
89 | NormalizationTransliterator(const UnicodeString& id, const Normalizer2 &norm2); |
90 | |
91 | private: |
92 | /** |
93 | * Assignment operator. |
94 | */ |
95 | NormalizationTransliterator& operator=(const NormalizationTransliterator&); |
96 | }; |
97 | |
98 | U_NAMESPACE_END |
99 | |
100 | #endif /* #if !UCONFIG_NO_TRANSLITERATION */ |
101 | |
102 | #endif |
103 | |