2 **********************************************************************
3 * Copyright (C) 1999-2009, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 * Date Name Description
7 * 11/17/99 aliu Creation.
8 **********************************************************************
13 #include "unicode/utypes.h"
15 #if !UCONFIG_NO_TRANSLITERATION
17 #include "unicode/translit.h"
21 class U_COMMON_API UVector
;
22 class TransliteratorRegistry
;
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.
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.
37 * @internal Use transliterator factory methods instead since this class will be removed in that release.
39 class U_I18N_API CompoundTransliterator
: public Transliterator
{
41 Transliterator
** trans
;
45 int32_t numAnonymousRBTs
;
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>
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.
64 CompoundTransliterator(Transliterator
* const transliterators
[],
65 int32_t transliteratorCount
,
66 UnicodeFilter
* adoptedFilter
= 0);
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
74 * @internal Use transliterator factory methods instead since this class will be removed in that release.
76 CompoundTransliterator(const UnicodeString
& id
,
78 UnicodeFilter
* adoptedFilter
,
79 UParseError
& parseError
,
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.
87 CompoundTransliterator(const UnicodeString
& id
,
88 UParseError
& parseError
,
92 * @internal Use transliterator factory methods instead since this class will be removed in that release.
94 virtual ~CompoundTransliterator();
98 * @internal Use transliterator factory methods instead since this class will be removed in that release.
100 CompoundTransliterator(const CompoundTransliterator
&);
103 * Transliterator API.
104 * @internal Use transliterator factory methods instead since this class will be removed in that release.
106 virtual Transliterator
* clone(void) const;
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.
113 virtual int32_t getCount(void) const;
116 * Returns the transliterator at the given index in this chain.
117 * @param idx index into chain, from 0 to <code>getCount() - 1</code>
118 * @return transliterator at the given index
119 * @internal Use transliterator factory methods instead since this class will be removed in that release.
121 virtual const Transliterator
& getTransliterator(int32_t idx
) const;
124 * Sets the transliterators.
125 * @internal Use transliterator factory methods instead since this class will be removed in that release.
127 void setTransliterators(Transliterator
* const transliterators
[],
131 * Adopts the transliterators.
132 * @internal Use transliterator factory methods instead since this class will be removed in that release.
134 void adoptTransliterators(Transliterator
* adoptedTransliterators
[],
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.
149 virtual UnicodeString
& toRules(UnicodeString
& result
,
150 UBool escapeUnprintable
) const;
154 * Implement Transliterator framework
156 virtual void handleGetSourceSet(UnicodeSet
& result
) const;
160 * Override Transliterator framework
162 virtual UnicodeSet
& getTargetSet(UnicodeSet
& result
) const;
166 * Implements {@link Transliterator#handleTransliterate}.
167 * @internal Use transliterator factory methods instead since this class will be removed in that release.
169 virtual void handleTransliterate(Replaceable
& text
, UTransPosition
& idx
,
170 UBool incremental
) const;
175 * ICU "poor man's RTTI", returns a UClassID for the actual class.
179 virtual UClassID
getDynamicClassID() const;
182 * ICU "poor man's RTTI", returns a UClassID for this class.
186 static UClassID U_EXPORT2
getStaticClassID();
189 static const UChar PASS_STRING
[];
193 friend class Transliterator
;
194 friend class TransliteratorAlias
; // to access private ct
197 * Assignment operator.
198 * @internal Use transliterator factory methods instead since this class will be removed in that release.
200 CompoundTransliterator
& operator=(const CompoundTransliterator
&);
203 * Private constructor for Transliterator.
205 CompoundTransliterator(const UnicodeString
& ID
,
207 UnicodeFilter
* adoptedFilter
,
208 int32_t numAnonymousRBTs
,
209 UParseError
& parseError
,
212 CompoundTransliterator(UVector
& list
,
213 UParseError
& parseError
,
216 CompoundTransliterator(UVector
& list
,
217 int32_t anonymousRBTs
,
218 UParseError
& parseError
,
221 void init(const UnicodeString
& id
,
222 UTransDirection direction
,
226 void init(UVector
& list
,
227 UTransDirection direction
,
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).
236 UnicodeString
joinIDs(Transliterator
* const transliterators
[],
239 void freeTransliterators(void);
241 void computeMaximumContextLength(void);
246 #endif /* #if !UCONFIG_NO_TRANSLITERATION */