]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/cpdtrans.h
ICU-8.11.1.tar.gz
[apple/icu.git] / icuSources / i18n / cpdtrans.h
1 /*
2 **********************************************************************
3 * Copyright (C) 1999-2005, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 * Date Name Description
7 * 11/17/99 aliu Creation.
8 **********************************************************************
9 */
10 #ifndef CPDTRANS_H
11 #define CPDTRANS_H
12
13 #include "unicode/utypes.h"
14
15 #if !UCONFIG_NO_TRANSLITERATION
16
17 #include "unicode/translit.h"
18
19 U_NAMESPACE_BEGIN
20
21 class U_COMMON_API UVector;
22 class TransliteratorRegistry;
23
24 /**
25 * A transliterator that is composed of two or more other
26 * transliterator objects linked together. For example, if one
27 * transliterator transliterates from script A to script B, and
28 * another transliterates from script B to script C, the two may be
29 * combined to form a new transliterator from A to C.
30 *
31 * <p>Composed transliterators may not behave as expected. For
32 * example, inverses may not combine to form the identity
33 * transliterator. See the class documentation for {@link
34 * Transliterator} for details.
35 *
36 * @author Alan Liu
37 * @internal Use transliterator factory methods instead since this class will be removed in that release.
38 */
39 class U_I18N_API CompoundTransliterator : public Transliterator {
40
41 Transliterator** trans;
42
43 int32_t count;
44
45 int32_t numAnonymousRBTs;
46
47 public:
48
49 /**
50 * Constructs a new compound transliterator given an array of
51 * transliterators. The array of transliterators may be of any
52 * length, including zero or one, however, useful compound
53 * transliterators have at least two components.
54 * @param transliterators array of <code>Transliterator</code>
55 * objects
56 * @param transliteratorCount The number of
57 * <code>Transliterator</code> objects in transliterators.
58 * @param adoptedFilter the filter. Any character for which
59 * <tt>filter.contains()</tt> returns <tt>false</tt> will not be
60 * altered by this transliterator. If <tt>filter</tt> is
61 * <tt>null</tt> then no filtering is applied.
62 * @internal Use transliterator factory methods instead since this class will be removed in that release.
63 */
64 CompoundTransliterator(Transliterator* const transliterators[],
65 int32_t transliteratorCount,
66 UnicodeFilter* adoptedFilter = 0);
67
68 /**
69 * Constructs a new compound transliterator.
70 * @param id compound ID
71 * @param dir either UTRANS_FORWARD or UTRANS_REVERSE
72 * @param adoptedFilter a global filter for this compound transliterator
73 * or NULL
74 * @internal Use transliterator factory methods instead since this class will be removed in that release.
75 */
76 CompoundTransliterator(const UnicodeString& id,
77 UTransDirection dir,
78 UnicodeFilter* adoptedFilter,
79 UParseError& parseError,
80 UErrorCode& status);
81
82 /**
83 * Constructs a new compound transliterator in the FORWARD
84 * direction with a NULL filter.
85 * @internal Use transliterator factory methods instead since this class will be removed in that release.
86 */
87 CompoundTransliterator(const UnicodeString& id,
88 UParseError& parseError,
89 UErrorCode& status);
90 /**
91 * Destructor.
92 * @internal Use transliterator factory methods instead since this class will be removed in that release.
93 */
94 virtual ~CompoundTransliterator();
95
96 /**
97 * Copy constructor.
98 * @internal Use transliterator factory methods instead since this class will be removed in that release.
99 */
100 CompoundTransliterator(const CompoundTransliterator&);
101
102 /**
103 * Assignment operator.
104 * @internal Use transliterator factory methods instead since this class will be removed in that release.
105 */
106 CompoundTransliterator& operator=(const CompoundTransliterator&);
107
108 /**
109 * Transliterator API.
110 * @internal Use transliterator factory methods instead since this class will be removed in that release.
111 */
112 virtual Transliterator* clone(void) const;
113
114 /**
115 * Returns the number of transliterators in this chain.
116 * @return number of transliterators in this chain.
117 * @internal Use transliterator factory methods instead since this class will be removed in that release.
118 */
119 virtual int32_t getCount(void) const;
120
121 /**
122 * Returns the transliterator at the given index in this chain.
123 * @param index index into chain, from 0 to <code>getCount() - 1</code>
124 * @return transliterator at the given index
125 * @internal Use transliterator factory methods instead since this class will be removed in that release.
126 */
127 virtual const Transliterator& getTransliterator(int32_t index) const;
128
129 /**
130 * Sets the transliterators.
131 * @internal Use transliterator factory methods instead since this class will be removed in that release.
132 */
133 void setTransliterators(Transliterator* const transliterators[],
134 int32_t count);
135
136 /**
137 * Adopts the transliterators.
138 * @internal Use transliterator factory methods instead since this class will be removed in that release.
139 */
140 void adoptTransliterators(Transliterator* adoptedTransliterators[],
141 int32_t count);
142
143 /**
144 * Override Transliterator:
145 * Create a rule string that can be passed to createFromRules()
146 * to recreate this transliterator.
147 * @param result the string to receive the rules. Previous
148 * contents will be deleted.
149 * @param escapeUnprintable if TRUE then convert unprintable
150 * character to their hex escape representations, \uxxxx or
151 * \Uxxxxxxxx. Unprintable characters are those other than
152 * U+000A, U+0020..U+007E.
153 * @internal Use transliterator factory methods instead since this class will be removed in that release.
154 */
155 virtual UnicodeString& toRules(UnicodeString& result,
156 UBool escapeUnprintable) const;
157
158 protected:
159 /**
160 * Implement Transliterator framework
161 */
162 virtual void handleGetSourceSet(UnicodeSet& result) const;
163
164 public:
165 /**
166 * Override Transliterator framework
167 */
168 virtual UnicodeSet& getTargetSet(UnicodeSet& result) const;
169
170 protected:
171 /**
172 * Implements {@link Transliterator#handleTransliterate}.
173 * @internal Use transliterator factory methods instead since this class will be removed in that release.
174 */
175 virtual void handleTransliterate(Replaceable& text, UTransPosition& index,
176 UBool incremental) const;
177
178 public:
179
180 /**
181 * ICU "poor man's RTTI", returns a UClassID for the actual class.
182 *
183 * @draft ICU 2.2
184 */
185 virtual UClassID getDynamicClassID() const;
186
187 /**
188 * ICU "poor man's RTTI", returns a UClassID for this class.
189 *
190 * @draft ICU 2.2
191 */
192 static UClassID U_EXPORT2 getStaticClassID();
193
194 /* @internal */
195 static const UChar PASS_STRING[];
196
197 private:
198
199 friend class Transliterator;
200 friend class TransliteratorAlias; // to access private ct
201
202 /**
203 * Private constructor for Transliterator.
204 */
205 CompoundTransliterator(const UnicodeString& ID,
206 UVector& list,
207 UnicodeFilter* adoptedFilter,
208 int32_t numAnonymousRBTs,
209 UParseError& parseError,
210 UErrorCode& status);
211
212 CompoundTransliterator(UVector& list,
213 UParseError& parseError,
214 UErrorCode& status);
215
216 CompoundTransliterator(UVector& list,
217 int32_t anonymousRBTs,
218 UParseError& parseError,
219 UErrorCode& status);
220
221 void init(const UnicodeString& id,
222 UTransDirection direction,
223 UBool fixReverseID,
224 UErrorCode& status);
225
226 void init(UVector& list,
227 UTransDirection direction,
228 UBool fixReverseID,
229 UErrorCode& status);
230
231 /**
232 * Return the IDs of the given list of transliterators, concatenated
233 * with ';' delimiting them. Equivalent to the perlish expression
234 * join(';', map($_.getID(), transliterators).
235 */
236 UnicodeString joinIDs(Transliterator* const transliterators[],
237 int32_t transCount);
238
239 void freeTransliterators(void);
240
241 void computeMaximumContextLength(void);
242 };
243
244 U_NAMESPACE_END
245
246 #endif /* #if !UCONFIG_NO_TRANSLITERATION */
247
248 #endif