2 **********************************************************************
3 * Copyright (C) 1999-2004, 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
;
46 * For compound RBTs (those with an ::id block before and/or after
47 * the main rule block) we record the index of the RBT here.
48 * Otherwise, this should have a value of -1. We need this
49 * information to implement toRules().
51 int32_t compoundRBTIndex
;
56 * Constructs a new compound transliterator given an array of
57 * transliterators. The array of transliterators may be of any
58 * length, including zero or one, however, useful compound
59 * transliterators have at least two components.
60 * @param transliterators array of <code>Transliterator</code>
62 * @param transliteratorCount The number of
63 * <code>Transliterator</code> objects in transliterators.
64 * @param adoptedFilter the filter. Any character for which
65 * <tt>filter.contains()</tt> returns <tt>false</tt> will not be
66 * altered by this transliterator. If <tt>filter</tt> is
67 * <tt>null</tt> then no filtering is applied.
68 * @internal Use transliterator factory methods instead since this class will be removed in that release.
70 CompoundTransliterator(Transliterator
* const transliterators
[],
71 int32_t transliteratorCount
,
72 UnicodeFilter
* adoptedFilter
= 0);
75 * Constructs a new compound transliterator.
76 * @param id compound ID
77 * @param dir either UTRANS_FORWARD or UTRANS_REVERSE
78 * @param adoptedFilter a global filter for this compound transliterator
80 * @internal Use transliterator factory methods instead since this class will be removed in that release.
82 CompoundTransliterator(const UnicodeString
& id
,
84 UnicodeFilter
* adoptedFilter
,
85 UParseError
& parseError
,
89 * Constructs a new compound transliterator in the FORWARD
90 * direction with a NULL filter.
91 * @internal Use transliterator factory methods instead since this class will be removed in that release.
93 CompoundTransliterator(const UnicodeString
& id
,
94 UParseError
& parseError
,
98 * @internal Use transliterator factory methods instead since this class will be removed in that release.
100 virtual ~CompoundTransliterator();
104 * @internal Use transliterator factory methods instead since this class will be removed in that release.
106 CompoundTransliterator(const CompoundTransliterator
&);
109 * Assignment operator.
110 * @internal Use transliterator factory methods instead since this class will be removed in that release.
112 CompoundTransliterator
& operator=(const CompoundTransliterator
&);
115 * Transliterator API.
116 * @internal Use transliterator factory methods instead since this class will be removed in that release.
118 virtual Transliterator
* clone(void) const;
121 * Returns the number of transliterators in this chain.
122 * @return number of transliterators in this chain.
123 * @internal Use transliterator factory methods instead since this class will be removed in that release.
125 virtual int32_t getCount(void) const;
128 * Returns the transliterator at the given index in this chain.
129 * @param index index into chain, from 0 to <code>getCount() - 1</code>
130 * @return transliterator at the given index
131 * @internal Use transliterator factory methods instead since this class will be removed in that release.
133 virtual const Transliterator
& getTransliterator(int32_t index
) const;
136 * Sets the transliterators.
137 * @internal Use transliterator factory methods instead since this class will be removed in that release.
139 void setTransliterators(Transliterator
* const transliterators
[],
143 * Adopts the transliterators.
144 * @internal Use transliterator factory methods instead since this class will be removed in that release.
146 void adoptTransliterators(Transliterator
* adoptedTransliterators
[],
150 * Override Transliterator:
151 * Create a rule string that can be passed to createFromRules()
152 * to recreate this transliterator.
153 * @param result the string to receive the rules. Previous
154 * contents will be deleted.
155 * @param escapeUnprintable if TRUE then convert unprintable
156 * character to their hex escape representations, \uxxxx or
157 * \Uxxxxxxxx. Unprintable characters are those other than
158 * U+000A, U+0020..U+007E.
159 * @internal Use transliterator factory methods instead since this class will be removed in that release.
161 virtual UnicodeString
& toRules(UnicodeString
& result
,
162 UBool escapeUnprintable
) const;
166 * Implement Transliterator framework
168 virtual void handleGetSourceSet(UnicodeSet
& result
) const;
172 * Override Transliterator framework
174 virtual UnicodeSet
& getTargetSet(UnicodeSet
& result
) const;
178 * Implements {@link Transliterator#handleTransliterate}.
179 * @internal Use transliterator factory methods instead since this class will be removed in that release.
181 virtual void handleTransliterate(Replaceable
& text
, UTransPosition
& index
,
182 UBool incremental
) const;
187 * ICU "poor man's RTTI", returns a UClassID for the actual class.
191 virtual UClassID
getDynamicClassID() const;
194 * ICU "poor man's RTTI", returns a UClassID for this class.
198 static UClassID U_EXPORT2
getStaticClassID();
202 friend class Transliterator
;
203 friend class TransliteratorAlias
; // to access private ct
206 * Private constructor for compound RBTs. Construct a compound
207 * transliterator using the given idBlock, with the adoptedTrans
208 * inserted at the idSplitPoint.
210 CompoundTransliterator(const UnicodeString
& ID
,
211 const UnicodeString
& idBlock
,
212 int32_t idSplitPoint
,
213 Transliterator
*adoptedTrans
,
217 * Private constructor for Transliterator.
219 CompoundTransliterator(UVector
& list
,
220 UParseError
& parseError
,
223 void init(const UnicodeString
& id
,
224 UTransDirection direction
,
225 int32_t idSplitPoint
,
226 Transliterator
*adoptedRbt
,
230 void init(UVector
& list
,
231 UTransDirection direction
,
236 * Return the IDs of the given list of transliterators, concatenated
237 * with ';' delimiting them. Equivalent to the perlish expression
238 * join(';', map($_.getID(), transliterators).
240 UnicodeString
joinIDs(Transliterator
* const transliterators
[],
243 void freeTransliterators(void);
245 void computeMaximumContextLength(void);
250 #endif /* #if !UCONFIG_NO_TRANSLITERATION */