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 **********************************************************************
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 * Assignment operator.
104 * @internal Use transliterator factory methods instead since this class will be removed in that release.
106 CompoundTransliterator
& operator=(const CompoundTransliterator
&);
109 * Transliterator API.
110 * @internal Use transliterator factory methods instead since this class will be removed in that release.
112 virtual Transliterator
* clone(void) const;
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.
119 virtual int32_t getCount(void) const;
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.
127 virtual const Transliterator
& getTransliterator(int32_t index
) const;
130 * Sets the transliterators.
131 * @internal Use transliterator factory methods instead since this class will be removed in that release.
133 void setTransliterators(Transliterator
* const transliterators
[],
137 * Adopts the transliterators.
138 * @internal Use transliterator factory methods instead since this class will be removed in that release.
140 void adoptTransliterators(Transliterator
* adoptedTransliterators
[],
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.
155 virtual UnicodeString
& toRules(UnicodeString
& result
,
156 UBool escapeUnprintable
) const;
160 * Implement Transliterator framework
162 virtual void handleGetSourceSet(UnicodeSet
& result
) const;
166 * Override Transliterator framework
168 virtual UnicodeSet
& getTargetSet(UnicodeSet
& result
) const;
172 * Implements {@link Transliterator#handleTransliterate}.
173 * @internal Use transliterator factory methods instead since this class will be removed in that release.
175 virtual void handleTransliterate(Replaceable
& text
, UTransPosition
& index
,
176 UBool incremental
) const;
181 * ICU "poor man's RTTI", returns a UClassID for the actual class.
185 virtual UClassID
getDynamicClassID() const;
188 * ICU "poor man's RTTI", returns a UClassID for this class.
192 static UClassID U_EXPORT2
getStaticClassID();
195 static const UChar PASS_STRING
[];
199 friend class Transliterator
;
200 friend class TransliteratorAlias
; // to access private ct
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 */