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