]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /* |
2 | ********************************************************************** | |
374ca955 | 3 | * Copyright (c) 2002-2004, International Business Machines Corporation |
b75a7d8f A |
4 | * and others. All Rights Reserved. |
5 | ********************************************************************** | |
6 | * Date Name Description | |
7 | * 02/04/2002 aliu Creation. | |
8 | ********************************************************************** | |
9 | */ | |
10 | ||
73c04bcf A |
11 | #ifndef FUNCREPL_H |
12 | #define FUNCREPL_H | |
13 | ||
b75a7d8f A |
14 | #include "unicode/utypes.h" |
15 | ||
16 | #if !UCONFIG_NO_TRANSLITERATION | |
17 | ||
18 | #include "unicode/unifunct.h" | |
19 | #include "unicode/unirepl.h" | |
20 | ||
21 | U_NAMESPACE_BEGIN | |
22 | ||
23 | class Transliterator; | |
24 | ||
25 | /** | |
26 | * A replacer that calls a transliterator to generate its output text. | |
27 | * The input text to the transliterator is the output of another | |
28 | * UnicodeReplacer object. That is, this replacer wraps another | |
29 | * replacer with a transliterator. | |
30 | * | |
31 | * Added U_I18N_API to make the definition of a global operator delete work. | |
32 | * See Jitterbug 2581. markus 2002dec17 | |
33 | * | |
34 | * @author Alan Liu | |
35 | */ | |
36 | class U_I18N_API FunctionReplacer : public UnicodeFunctor, public UnicodeReplacer { | |
37 | ||
38 | private: | |
39 | ||
40 | /** | |
41 | * The transliterator. Must not be null. OWNED. | |
42 | */ | |
43 | Transliterator* translit; | |
44 | ||
45 | /** | |
46 | * The replacer object. This generates text that is then | |
47 | * processed by 'translit'. Must not be null. OWNED. | |
48 | */ | |
49 | UnicodeFunctor* replacer; | |
50 | ||
b75a7d8f A |
51 | public: |
52 | ||
53 | /** | |
54 | * Construct a replacer that takes the output of the given | |
55 | * replacer, passes it through the given transliterator, and emits | |
56 | * the result as output. | |
57 | */ | |
58 | FunctionReplacer(Transliterator* adoptedTranslit, | |
59 | UnicodeFunctor* adoptedReplacer); | |
60 | ||
61 | /** | |
62 | * Copy constructor. | |
63 | */ | |
64 | FunctionReplacer(const FunctionReplacer& other); | |
65 | ||
66 | /** | |
67 | * Destructor | |
68 | */ | |
69 | virtual ~FunctionReplacer(); | |
70 | ||
71 | /** | |
72 | * Implement UnicodeFunctor | |
73 | */ | |
74 | virtual UnicodeFunctor* clone() const; | |
75 | ||
76 | /** | |
77 | * UnicodeFunctor API. Cast 'this' to a UnicodeReplacer* pointer | |
78 | * and return the pointer. | |
79 | */ | |
80 | virtual UnicodeReplacer* toReplacer() const; | |
81 | ||
82 | /** | |
83 | * UnicodeReplacer API | |
84 | */ | |
85 | virtual int32_t replace(Replaceable& text, | |
86 | int32_t start, | |
87 | int32_t limit, | |
88 | int32_t& cursor); | |
89 | ||
90 | /** | |
91 | * UnicodeReplacer API | |
92 | */ | |
93 | virtual UnicodeString& toReplacerPattern(UnicodeString& rule, | |
94 | UBool escapeUnprintable) const; | |
95 | ||
96 | /** | |
97 | * Implement UnicodeReplacer | |
98 | */ | |
99 | virtual void addReplacementSetTo(UnicodeSet& toUnionTo) const; | |
100 | ||
101 | /** | |
102 | * UnicodeFunctor API | |
103 | */ | |
104 | virtual void setData(const TransliterationRuleData*); | |
105 | ||
106 | /** | |
107 | * ICU "poor man's RTTI", returns a UClassID for the actual class. | |
108 | * | |
109 | * @draft ICU 2.2 | |
110 | */ | |
374ca955 | 111 | virtual UClassID getDynamicClassID() const; |
b75a7d8f A |
112 | |
113 | /** | |
114 | * ICU "poor man's RTTI", returns a UClassID for this class. | |
115 | * | |
116 | * @draft ICU 2.2 | |
117 | */ | |
374ca955 | 118 | static UClassID U_EXPORT2 getStaticClassID(); |
b75a7d8f A |
119 | }; |
120 | ||
121 | U_NAMESPACE_END | |
122 | ||
123 | #endif /* #if !UCONFIG_NO_TRANSLITERATION */ | |
73c04bcf | 124 | #endif |
b75a7d8f A |
125 | |
126 | //eof |