]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/cpdtrans.h
ICU-461.18.tar.gz
[apple/icu.git] / icuSources / i18n / cpdtrans.h
CommitLineData
b75a7d8f
A
1/*
2**********************************************************************
729e4ab9 3* Copyright (C) 1999-2009, International Business Machines
b75a7d8f
A
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
19U_NAMESPACE_BEGIN
20
374ca955 21class U_COMMON_API UVector;
b75a7d8f
A
22class 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 */
39class U_I18N_API CompoundTransliterator : public Transliterator {
40
41 Transliterator** trans;
42
43 int32_t count;
44
73c04bcf 45 int32_t numAnonymousRBTs;
b75a7d8f
A
46
47public:
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
b75a7d8f
A
102 /**
103 * Transliterator API.
104 * @internal Use transliterator factory methods instead since this class will be removed in that release.
105 */
374ca955 106 virtual Transliterator* clone(void) const;
b75a7d8f
A
107
108 /**
109 * Returns the number of transliterators in this chain.
110 * @return number of transliterators in this chain.
111 * @internal Use transliterator factory methods instead since this class will be removed in that release.
112 */
113 virtual int32_t getCount(void) const;
114
115 /**
116 * Returns the transliterator at the given index in this chain.
729e4ab9 117 * @param idx index into chain, from 0 to <code>getCount() - 1</code>
b75a7d8f
A
118 * @return transliterator at the given index
119 * @internal Use transliterator factory methods instead since this class will be removed in that release.
120 */
729e4ab9 121 virtual const Transliterator& getTransliterator(int32_t idx) const;
b75a7d8f
A
122
123 /**
124 * Sets the transliterators.
125 * @internal Use transliterator factory methods instead since this class will be removed in that release.
126 */
127 void setTransliterators(Transliterator* const transliterators[],
128 int32_t count);
129
130 /**
131 * Adopts the transliterators.
132 * @internal Use transliterator factory methods instead since this class will be removed in that release.
133 */
134 void adoptTransliterators(Transliterator* adoptedTransliterators[],
135 int32_t count);
136
137 /**
138 * Override Transliterator:
139 * Create a rule string that can be passed to createFromRules()
140 * to recreate this transliterator.
141 * @param result the string to receive the rules. Previous
142 * contents will be deleted.
143 * @param escapeUnprintable if TRUE then convert unprintable
144 * character to their hex escape representations, \uxxxx or
145 * \Uxxxxxxxx. Unprintable characters are those other than
146 * U+000A, U+0020..U+007E.
147 * @internal Use transliterator factory methods instead since this class will be removed in that release.
148 */
149 virtual UnicodeString& toRules(UnicodeString& result,
150 UBool escapeUnprintable) const;
151
152 protected:
153 /**
154 * Implement Transliterator framework
155 */
156 virtual void handleGetSourceSet(UnicodeSet& result) const;
157
158 public:
159 /**
160 * Override Transliterator framework
161 */
162 virtual UnicodeSet& getTargetSet(UnicodeSet& result) const;
163
164protected:
165 /**
166 * Implements {@link Transliterator#handleTransliterate}.
167 * @internal Use transliterator factory methods instead since this class will be removed in that release.
168 */
729e4ab9 169 virtual void handleTransliterate(Replaceable& text, UTransPosition& idx,
b75a7d8f
A
170 UBool incremental) const;
171
172public:
173
174 /**
175 * ICU "poor man's RTTI", returns a UClassID for the actual class.
176 *
177 * @draft ICU 2.2
178 */
374ca955 179 virtual UClassID getDynamicClassID() const;
b75a7d8f
A
180
181 /**
182 * ICU "poor man's RTTI", returns a UClassID for this class.
183 *
184 * @draft ICU 2.2
185 */
374ca955 186 static UClassID U_EXPORT2 getStaticClassID();
b75a7d8f 187
73c04bcf
A
188 /* @internal */
189 static const UChar PASS_STRING[];
190
b75a7d8f
A
191private:
192
193 friend class Transliterator;
194 friend class TransliteratorAlias; // to access private ct
195
46f4442e
A
196 /**
197 * Assignment operator.
198 * @internal Use transliterator factory methods instead since this class will be removed in that release.
199 */
200 CompoundTransliterator& operator=(const CompoundTransliterator&);
201
b75a7d8f 202 /**
73c04bcf 203 * Private constructor for Transliterator.
b75a7d8f
A
204 */
205 CompoundTransliterator(const UnicodeString& ID,
73c04bcf
A
206 UVector& list,
207 UnicodeFilter* adoptedFilter,
208 int32_t numAnonymousRBTs,
209 UParseError& parseError,
b75a7d8f 210 UErrorCode& status);
73c04bcf
A
211
212 CompoundTransliterator(UVector& list,
213 UParseError& parseError,
214 UErrorCode& status);
215
b75a7d8f 216 CompoundTransliterator(UVector& list,
73c04bcf 217 int32_t anonymousRBTs,
b75a7d8f
A
218 UParseError& parseError,
219 UErrorCode& status);
220
221 void init(const UnicodeString& id,
222 UTransDirection direction,
b75a7d8f
A
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);
b75a7d8f
A
242};
243
b75a7d8f
A
244U_NAMESPACE_END
245
246#endif /* #if !UCONFIG_NO_TRANSLITERATION */
247
248#endif