Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | ********************************************************************** |
michael@0 | 3 | * Copyright (C) 1999-2011, International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ********************************************************************** |
michael@0 | 6 | * Date Name Description |
michael@0 | 7 | * 11/17/99 aliu Creation. |
michael@0 | 8 | ********************************************************************** |
michael@0 | 9 | */ |
michael@0 | 10 | #ifndef CPDTRANS_H |
michael@0 | 11 | #define CPDTRANS_H |
michael@0 | 12 | |
michael@0 | 13 | #include "unicode/utypes.h" |
michael@0 | 14 | |
michael@0 | 15 | #if !UCONFIG_NO_TRANSLITERATION |
michael@0 | 16 | |
michael@0 | 17 | #include "unicode/translit.h" |
michael@0 | 18 | |
michael@0 | 19 | U_NAMESPACE_BEGIN |
michael@0 | 20 | |
michael@0 | 21 | class U_COMMON_API UVector; |
michael@0 | 22 | class TransliteratorRegistry; |
michael@0 | 23 | |
michael@0 | 24 | /** |
michael@0 | 25 | * A transliterator that is composed of two or more other |
michael@0 | 26 | * transliterator objects linked together. For example, if one |
michael@0 | 27 | * transliterator transliterates from script A to script B, and |
michael@0 | 28 | * another transliterates from script B to script C, the two may be |
michael@0 | 29 | * combined to form a new transliterator from A to C. |
michael@0 | 30 | * |
michael@0 | 31 | * <p>Composed transliterators may not behave as expected. For |
michael@0 | 32 | * example, inverses may not combine to form the identity |
michael@0 | 33 | * transliterator. See the class documentation for {@link |
michael@0 | 34 | * Transliterator} for details. |
michael@0 | 35 | * |
michael@0 | 36 | * @author Alan Liu |
michael@0 | 37 | */ |
michael@0 | 38 | class U_I18N_API CompoundTransliterator : public Transliterator { |
michael@0 | 39 | |
michael@0 | 40 | Transliterator** trans; |
michael@0 | 41 | |
michael@0 | 42 | int32_t count; |
michael@0 | 43 | |
michael@0 | 44 | int32_t numAnonymousRBTs; |
michael@0 | 45 | |
michael@0 | 46 | public: |
michael@0 | 47 | |
michael@0 | 48 | /** |
michael@0 | 49 | * Constructs a new compound transliterator given an array of |
michael@0 | 50 | * transliterators. The array of transliterators may be of any |
michael@0 | 51 | * length, including zero or one, however, useful compound |
michael@0 | 52 | * transliterators have at least two components. |
michael@0 | 53 | * @param transliterators array of <code>Transliterator</code> |
michael@0 | 54 | * objects |
michael@0 | 55 | * @param transliteratorCount The number of |
michael@0 | 56 | * <code>Transliterator</code> objects in transliterators. |
michael@0 | 57 | * @param adoptedFilter the filter. Any character for which |
michael@0 | 58 | * <tt>filter.contains()</tt> returns <tt>false</tt> will not be |
michael@0 | 59 | * altered by this transliterator. If <tt>filter</tt> is |
michael@0 | 60 | * <tt>null</tt> then no filtering is applied. |
michael@0 | 61 | */ |
michael@0 | 62 | CompoundTransliterator(Transliterator* const transliterators[], |
michael@0 | 63 | int32_t transliteratorCount, |
michael@0 | 64 | UnicodeFilter* adoptedFilter = 0); |
michael@0 | 65 | |
michael@0 | 66 | /** |
michael@0 | 67 | * Constructs a new compound transliterator. |
michael@0 | 68 | * @param id compound ID |
michael@0 | 69 | * @param dir either UTRANS_FORWARD or UTRANS_REVERSE |
michael@0 | 70 | * @param adoptedFilter a global filter for this compound transliterator |
michael@0 | 71 | * or NULL |
michael@0 | 72 | */ |
michael@0 | 73 | CompoundTransliterator(const UnicodeString& id, |
michael@0 | 74 | UTransDirection dir, |
michael@0 | 75 | UnicodeFilter* adoptedFilter, |
michael@0 | 76 | UParseError& parseError, |
michael@0 | 77 | UErrorCode& status); |
michael@0 | 78 | |
michael@0 | 79 | /** |
michael@0 | 80 | * Constructs a new compound transliterator in the FORWARD |
michael@0 | 81 | * direction with a NULL filter. |
michael@0 | 82 | */ |
michael@0 | 83 | CompoundTransliterator(const UnicodeString& id, |
michael@0 | 84 | UParseError& parseError, |
michael@0 | 85 | UErrorCode& status); |
michael@0 | 86 | /** |
michael@0 | 87 | * Destructor. |
michael@0 | 88 | */ |
michael@0 | 89 | virtual ~CompoundTransliterator(); |
michael@0 | 90 | |
michael@0 | 91 | /** |
michael@0 | 92 | * Copy constructor. |
michael@0 | 93 | */ |
michael@0 | 94 | CompoundTransliterator(const CompoundTransliterator&); |
michael@0 | 95 | |
michael@0 | 96 | /** |
michael@0 | 97 | * Transliterator API. |
michael@0 | 98 | */ |
michael@0 | 99 | virtual Transliterator* clone(void) const; |
michael@0 | 100 | |
michael@0 | 101 | /** |
michael@0 | 102 | * Returns the number of transliterators in this chain. |
michael@0 | 103 | * @return number of transliterators in this chain. |
michael@0 | 104 | */ |
michael@0 | 105 | virtual int32_t getCount(void) const; |
michael@0 | 106 | |
michael@0 | 107 | /** |
michael@0 | 108 | * Returns the transliterator at the given index in this chain. |
michael@0 | 109 | * @param idx index into chain, from 0 to <code>getCount() - 1</code> |
michael@0 | 110 | * @return transliterator at the given index |
michael@0 | 111 | */ |
michael@0 | 112 | virtual const Transliterator& getTransliterator(int32_t idx) const; |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * Sets the transliterators. |
michael@0 | 116 | */ |
michael@0 | 117 | void setTransliterators(Transliterator* const transliterators[], |
michael@0 | 118 | int32_t count); |
michael@0 | 119 | |
michael@0 | 120 | /** |
michael@0 | 121 | * Adopts the transliterators. |
michael@0 | 122 | */ |
michael@0 | 123 | void adoptTransliterators(Transliterator* adoptedTransliterators[], |
michael@0 | 124 | int32_t count); |
michael@0 | 125 | |
michael@0 | 126 | /** |
michael@0 | 127 | * Override Transliterator: |
michael@0 | 128 | * Create a rule string that can be passed to createFromRules() |
michael@0 | 129 | * to recreate this transliterator. |
michael@0 | 130 | * @param result the string to receive the rules. Previous |
michael@0 | 131 | * contents will be deleted. |
michael@0 | 132 | * @param escapeUnprintable if TRUE then convert unprintable |
michael@0 | 133 | * character to their hex escape representations, \uxxxx or |
michael@0 | 134 | * \Uxxxxxxxx. Unprintable characters are those other than |
michael@0 | 135 | * U+000A, U+0020..U+007E. |
michael@0 | 136 | */ |
michael@0 | 137 | virtual UnicodeString& toRules(UnicodeString& result, |
michael@0 | 138 | UBool escapeUnprintable) const; |
michael@0 | 139 | |
michael@0 | 140 | protected: |
michael@0 | 141 | /** |
michael@0 | 142 | * Implement Transliterator framework |
michael@0 | 143 | */ |
michael@0 | 144 | virtual void handleGetSourceSet(UnicodeSet& result) const; |
michael@0 | 145 | |
michael@0 | 146 | public: |
michael@0 | 147 | /** |
michael@0 | 148 | * Override Transliterator framework |
michael@0 | 149 | */ |
michael@0 | 150 | virtual UnicodeSet& getTargetSet(UnicodeSet& result) const; |
michael@0 | 151 | |
michael@0 | 152 | protected: |
michael@0 | 153 | /** |
michael@0 | 154 | * Implements {@link Transliterator#handleTransliterate}. |
michael@0 | 155 | */ |
michael@0 | 156 | virtual void handleTransliterate(Replaceable& text, UTransPosition& idx, |
michael@0 | 157 | UBool incremental) const; |
michael@0 | 158 | |
michael@0 | 159 | public: |
michael@0 | 160 | |
michael@0 | 161 | /** |
michael@0 | 162 | * ICU "poor man's RTTI", returns a UClassID for the actual class. |
michael@0 | 163 | */ |
michael@0 | 164 | virtual UClassID getDynamicClassID() const; |
michael@0 | 165 | |
michael@0 | 166 | /** |
michael@0 | 167 | * ICU "poor man's RTTI", returns a UClassID for this class. |
michael@0 | 168 | */ |
michael@0 | 169 | static UClassID U_EXPORT2 getStaticClassID(); |
michael@0 | 170 | |
michael@0 | 171 | /* @internal */ |
michael@0 | 172 | static const UChar PASS_STRING[]; |
michael@0 | 173 | |
michael@0 | 174 | private: |
michael@0 | 175 | |
michael@0 | 176 | friend class Transliterator; |
michael@0 | 177 | friend class TransliteratorAlias; // to access private ct |
michael@0 | 178 | |
michael@0 | 179 | /** |
michael@0 | 180 | * Assignment operator. |
michael@0 | 181 | */ |
michael@0 | 182 | CompoundTransliterator& operator=(const CompoundTransliterator&); |
michael@0 | 183 | |
michael@0 | 184 | /** |
michael@0 | 185 | * Private constructor for Transliterator. |
michael@0 | 186 | */ |
michael@0 | 187 | CompoundTransliterator(const UnicodeString& ID, |
michael@0 | 188 | UVector& list, |
michael@0 | 189 | UnicodeFilter* adoptedFilter, |
michael@0 | 190 | int32_t numAnonymousRBTs, |
michael@0 | 191 | UParseError& parseError, |
michael@0 | 192 | UErrorCode& status); |
michael@0 | 193 | |
michael@0 | 194 | CompoundTransliterator(UVector& list, |
michael@0 | 195 | UParseError& parseError, |
michael@0 | 196 | UErrorCode& status); |
michael@0 | 197 | |
michael@0 | 198 | CompoundTransliterator(UVector& list, |
michael@0 | 199 | int32_t anonymousRBTs, |
michael@0 | 200 | UParseError& parseError, |
michael@0 | 201 | UErrorCode& status); |
michael@0 | 202 | |
michael@0 | 203 | void init(const UnicodeString& id, |
michael@0 | 204 | UTransDirection direction, |
michael@0 | 205 | UBool fixReverseID, |
michael@0 | 206 | UErrorCode& status); |
michael@0 | 207 | |
michael@0 | 208 | void init(UVector& list, |
michael@0 | 209 | UTransDirection direction, |
michael@0 | 210 | UBool fixReverseID, |
michael@0 | 211 | UErrorCode& status); |
michael@0 | 212 | |
michael@0 | 213 | /** |
michael@0 | 214 | * Return the IDs of the given list of transliterators, concatenated |
michael@0 | 215 | * with ';' delimiting them. Equivalent to the perlish expression |
michael@0 | 216 | * join(';', map($_.getID(), transliterators). |
michael@0 | 217 | */ |
michael@0 | 218 | UnicodeString joinIDs(Transliterator* const transliterators[], |
michael@0 | 219 | int32_t transCount); |
michael@0 | 220 | |
michael@0 | 221 | void freeTransliterators(void); |
michael@0 | 222 | |
michael@0 | 223 | void computeMaximumContextLength(void); |
michael@0 | 224 | }; |
michael@0 | 225 | |
michael@0 | 226 | U_NAMESPACE_END |
michael@0 | 227 | |
michael@0 | 228 | #endif /* #if !UCONFIG_NO_TRANSLITERATION */ |
michael@0 | 229 | |
michael@0 | 230 | #endif |