~ubuntu-branches/ubuntu/gutsy/icu/gutsy

« back to all changes in this revision

Viewing changes to source/i18n/unicode/cpdtrans.h

  • Committer: Package Import Robot
  • Author(s): Jay Berkenbilt
  • Date: 2005-11-19 11:29:31 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20051119112931-vcizkrp10tli4enw
Tags: 3.4-3
Explicitly build with g++ 3.4.  The current ICU fails its test suite
with 4.0 but not with 3.4.  Future versions should work properly with
4.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
**********************************************************************
3
 
*   Copyright (C) 1999-2002, 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/translit.h"
14
 
 
15
 
U_NAMESPACE_BEGIN
16
 
 
17
 
class U_I18N_API UVector;
18
 
class TransliteratorRegistry;
19
 
 
20
 
/**
21
 
 * A transliterator that is composed of two or more other
22
 
 * transliterator objects linked together.  For example, if one
23
 
 * transliterator transliterates from script A to script B, and
24
 
 * another transliterates from script B to script C, the two may be
25
 
 * combined to form a new transliterator from A to C.
26
 
 *
27
 
 * <p>Composed transliterators may not behave as expected.  For
28
 
 * example, inverses may not combine to form the identity
29
 
 * transliterator.  See the class documentation for {@link
30
 
 * Transliterator} for details.
31
 
 *
32
 
 * <p>Copyright &copy; IBM Corporation 1999.  All rights reserved.
33
 
 *
34
 
 * @author Alan Liu
35
 
 * @deprecated To be removed after 2002-sep-30.
36
 
 */
37
 
class U_I18N_API CompoundTransliterator : public Transliterator {
38
 
 
39
 
    Transliterator** trans;
40
 
 
41
 
    int32_t count;
42
 
 
43
 
    /**
44
 
     * For compound RBTs (those with an ::id block before and/or after
45
 
     * the main rule block) we record the index of the RBT here.
46
 
     * Otherwise, this should have a value of -1.  We need this
47
 
     * information to implement toRules().
48
 
     */
49
 
    int32_t compoundRBTIndex;
50
 
 
51
 
public:
52
 
 
53
 
    /**
54
 
     * Constructs a new compound transliterator given an array of
55
 
     * transliterators.  The array of transliterators may be of any
56
 
     * length, including zero or one, however, useful compound
57
 
     * transliterators have at least two components.
58
 
     * @param transliterators array of <code>Transliterator</code>
59
 
     * objects
60
 
     * @param transliteratorCount The number of
61
 
     * <code>Transliterator</code> objects in transliterators.
62
 
     * @param filter the filter.  Any character for which
63
 
     * <tt>filter.contains()</tt> returns <tt>false</tt> will not be
64
 
     * altered by this transliterator.  If <tt>filter</tt> is
65
 
     * <tt>null</tt> then no filtering is applied.
66
 
     * @deprecated To be removed after 2002-sep-30; use the Transliterator::createInstance factory method.
67
 
     */
68
 
    CompoundTransliterator(Transliterator* const transliterators[],
69
 
                           int32_t transliteratorCount,
70
 
                           UnicodeFilter* adoptedFilter = 0);
71
 
 
72
 
    /**
73
 
     * Constructs a new compound transliterator.
74
 
     * @param id compound ID
75
 
     * @param dir either UTRANS_FORWARD or UTRANS_REVERSE
76
 
     * @param adoptedFilter a global filter for this compound transliterator
77
 
     * or NULL
78
 
     * @deprecated To be removed after 2002-sep-30; use the Transliterator::createInstance factory method.
79
 
     */
80
 
    CompoundTransliterator(const UnicodeString& id,
81
 
                           UTransDirection dir,
82
 
                           UnicodeFilter* adoptedFilter,
83
 
                           UParseError& parseError,
84
 
                           UErrorCode& status);
85
 
 
86
 
    /**
87
 
     * Constructs a new compound transliterator in the FORWARD
88
 
     * direction with a NULL filter.
89
 
     * @deprecated To be removed after 2002-sep-30; use the Transliterator::createInstance factory method.
90
 
     */
91
 
    CompoundTransliterator(const UnicodeString& id,
92
 
                           UParseError& parseError,
93
 
                           UErrorCode& status);
94
 
    /**
95
 
     * Destructor.
96
 
     * @deprecated To be removed after 2002-sep-30.
97
 
     */
98
 
    virtual ~CompoundTransliterator();
99
 
 
100
 
    /**
101
 
     * Copy constructor.
102
 
     * @deprecated To be removed after 2002-sep-30; use the Transliterator::createInstance factory method.
103
 
     */
104
 
    CompoundTransliterator(const CompoundTransliterator&);
105
 
 
106
 
    /**
107
 
     * Assignment operator.
108
 
     * @deprecated To be removed after 2002-sep-30.
109
 
     */
110
 
    CompoundTransliterator& operator=(const CompoundTransliterator&);
111
 
 
112
 
    /**
113
 
     * Transliterator API.
114
 
     * @deprecated To be removed after 2002-sep-30.
115
 
     */
116
 
    Transliterator* clone(void) const;
117
 
 
118
 
    /**
119
 
     * Returns the number of transliterators in this chain.
120
 
     * @return number of transliterators in this chain.
121
 
     * @deprecated To be removed after 2002-sep-30.
122
 
     */
123
 
    virtual int32_t getCount(void) const;
124
 
 
125
 
    /**
126
 
     * Returns the transliterator at the given index in this chain.
127
 
     * @param index index into chain, from 0 to <code>getCount() - 1</code>
128
 
     * @return transliterator at the given index
129
 
     * @deprecated To be removed after 2002-sep-30.
130
 
     */
131
 
    virtual const Transliterator& getTransliterator(int32_t index) const;
132
 
 
133
 
    /**
134
 
     * Sets the transliterators.
135
 
     * @deprecated To be removed after 2002-sep-30.
136
 
     */
137
 
    void setTransliterators(Transliterator* const transliterators[],
138
 
                            int32_t count);
139
 
 
140
 
    /**
141
 
     * Adopts the transliterators.
142
 
     * @deprecated To be removed after 2002-sep-30.
143
 
     */
144
 
    void adoptTransliterators(Transliterator* adoptedTransliterators[],
145
 
                              int32_t count);
146
 
 
147
 
    /**
148
 
     * Override Transliterator:
149
 
     * Create a rule string that can be passed to createFromRules()
150
 
     * to recreate this transliterator.
151
 
     * @param result the string to receive the rules.  Previous
152
 
     * contents will be deleted.
153
 
     * @param escapeUnprintable if TRUE then convert unprintable
154
 
     * character to their hex escape representations, \uxxxx or
155
 
     * \Uxxxxxxxx.  Unprintable characters are those other than
156
 
     * U+000A, U+0020..U+007E.
157
 
     * @deprecated To be removed after 2002-sep-30.
158
 
     */
159
 
    virtual UnicodeString& toRules(UnicodeString& result,
160
 
                                   UBool escapeUnprintable) const;
161
 
 
162
 
    /**
163
 
     * Implements {@link Transliterator#handleTransliterate}.
164
 
     * @deprecated To be removed after 2002-sep-30.
165
 
     */
166
 
    virtual void handleTransliterate(Replaceable& text, UTransPosition& index,
167
 
                                     UBool incremental) const;
168
 
 
169
 
private:
170
 
 
171
 
    friend class Transliterator;
172
 
    friend class TransliteratorAlias; // to access private ct
173
 
 
174
 
    /**
175
 
     * Private constructor for compound RBTs.  Construct a compound
176
 
     * transliterator using the given idBlock, with the adoptedTrans
177
 
     * inserted at the idSplitPoint.
178
 
     */
179
 
    CompoundTransliterator(const UnicodeString& ID,
180
 
                           const UnicodeString& idBlock,
181
 
                           int32_t idSplitPoint,
182
 
                           Transliterator *adoptedTrans,
183
 
                           UErrorCode& status);
184
 
                           
185
 
    /**
186
 
     * Private constructor for Transliterator.
187
 
     */
188
 
    CompoundTransliterator(UVector& list,
189
 
                           UParseError& parseError,
190
 
                           UErrorCode& status);
191
 
 
192
 
    void init(const UnicodeString& id,
193
 
              UTransDirection direction,
194
 
              int32_t idSplitPoint,
195
 
              Transliterator *adoptedRbt,
196
 
              UBool fixReverseID,
197
 
              UErrorCode& status);
198
 
 
199
 
    void init(UVector& list,
200
 
              UTransDirection direction,
201
 
              UBool fixReverseID,
202
 
              UErrorCode& status);
203
 
 
204
 
    /**
205
 
     * Return the IDs of the given list of transliterators, concatenated
206
 
     * with ';' delimiting them.  Equivalent to the perlish expression
207
 
     * join(';', map($_.getID(), transliterators).
208
 
     */
209
 
    UnicodeString joinIDs(Transliterator* const transliterators[],
210
 
                          int32_t transCount);
211
 
 
212
 
    void freeTransliterators(void);
213
 
 
214
 
    void computeMaximumContextLength(void);
215
 
 
216
 
    
217
 
#ifdef U_USE_DEPRECATED_TRANSLITERATOR_API
218
 
 
219
 
public:
220
 
 
221
 
    /**
222
 
     * Constructs a new compound transliterator.
223
 
     * Use Transliterator::createInstance factory method.
224
 
     * @param filter the filter.  Any character for which
225
 
     * <tt>filter.isIn()</tt> returns <tt>false</tt> will not be
226
 
     * altered by this transliterator.  If <tt>filter</tt> is
227
 
     * <tt>null</tt> then no filtering is applied.
228
 
     * @deprecated Remove after Aug 2002. Use the constructor that takes
229
 
     * UParseError as one of the paramerters.
230
 
     */
231
 
    CompoundTransliterator(const UnicodeString& id,
232
 
                           UTransDirection dir,
233
 
                           UnicodeFilter* adoptedFilter,
234
 
                           UErrorCode& status);
235
 
 
236
 
    /**
237
 
     * Constructs a new compound transliterator in the FORWARD
238
 
     * direction with a NULL filter.
239
 
     * Use Transliterator::createInstance factory method.
240
 
     * @deprecated Remove after Aug 2002. Use the constructor that takes
241
 
     * UParseError as one of the parmeters.
242
 
     */
243
 
    CompoundTransliterator(const UnicodeString& id,
244
 
                           UErrorCode& status);
245
 
 
246
 
#endif
247
 
};
248
 
 
249
 
/**
250
 
 * Definitions for deprecated API
251
 
 * @deprecated Remove after Aug 2002
252
 
 */
253
 
 
254
 
#ifdef U_USE_DEPRECATED_TRANSLITERATOR_API
255
 
 
256
 
inline CompoundTransliterator::CompoundTransliterator( const UnicodeString& id,
257
 
                                                       UTransDirection dir,
258
 
                                                       UnicodeFilter* adoptedFilter,
259
 
                                                       UErrorCode& status):
260
 
                                            Transliterator(id, adoptedFilter),
261
 
                                            trans(0), compoundRBTIndex(-1) {
262
 
    UParseError parseError;
263
 
    init(id, dir, -1, 0, TRUE,parseError,status);
264
 
}
265
 
 
266
 
inline CompoundTransliterator::CompoundTransliterator(const UnicodeString& id,
267
 
                                                      UErrorCode& status) :
268
 
                                            Transliterator(id, 0), // set filter to 0 here!
269
 
                                            trans(0), compoundRBTIndex(-1) {
270
 
    UParseError parseError;
271
 
    init(id, UTRANS_FORWARD, -1, 0, TRUE,parseError,status);       
272
 
}
273
 
 
274
 
#endif
275
 
 
276
 
U_NAMESPACE_END
277
 
 
278
 
#endif