intl/icu/source/i18n/cpdtrans.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /*
     2 **********************************************************************
     3 *   Copyright (C) 1999-2011, 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
    13 #include "unicode/utypes.h"
    15 #if !UCONFIG_NO_TRANSLITERATION
    17 #include "unicode/translit.h"
    19 U_NAMESPACE_BEGIN
    21 class U_COMMON_API UVector;
    22 class TransliteratorRegistry;
    24 /**
    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.
    30  *
    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.
    35  *
    36  * @author Alan Liu
    37  */
    38 class U_I18N_API CompoundTransliterator : public Transliterator {
    40     Transliterator** trans;
    42     int32_t count;
    44     int32_t numAnonymousRBTs;
    46 public:
    48     /**
    49      * Constructs a new compound transliterator given an array of
    50      * transliterators.  The array of transliterators may be of any
    51      * length, including zero or one, however, useful compound
    52      * transliterators have at least two components.
    53      * @param transliterators array of <code>Transliterator</code>
    54      * objects
    55      * @param transliteratorCount The number of
    56      * <code>Transliterator</code> objects in transliterators.
    57      * @param adoptedFilter the filter.  Any character for which
    58      * <tt>filter.contains()</tt> returns <tt>false</tt> will not be
    59      * altered by this transliterator.  If <tt>filter</tt> is
    60      * <tt>null</tt> then no filtering is applied.
    61      */
    62     CompoundTransliterator(Transliterator* const transliterators[],
    63                            int32_t transliteratorCount,
    64                            UnicodeFilter* adoptedFilter = 0);
    66     /**
    67      * Constructs a new compound transliterator.
    68      * @param id compound ID
    69      * @param dir either UTRANS_FORWARD or UTRANS_REVERSE
    70      * @param adoptedFilter a global filter for this compound transliterator
    71      * or NULL
    72      */
    73     CompoundTransliterator(const UnicodeString& id,
    74                            UTransDirection dir,
    75                            UnicodeFilter* adoptedFilter,
    76                            UParseError& parseError,
    77                            UErrorCode& status);
    79     /**
    80      * Constructs a new compound transliterator in the FORWARD
    81      * direction with a NULL filter.
    82      */
    83     CompoundTransliterator(const UnicodeString& id,
    84                            UParseError& parseError,
    85                            UErrorCode& status);
    86     /**
    87      * Destructor.
    88      */
    89     virtual ~CompoundTransliterator();
    91     /**
    92      * Copy constructor.
    93      */
    94     CompoundTransliterator(const CompoundTransliterator&);
    96     /**
    97      * Transliterator API.
    98      */
    99     virtual Transliterator* clone(void) const;
   101     /**
   102      * Returns the number of transliterators in this chain.
   103      * @return number of transliterators in this chain.
   104      */
   105     virtual int32_t getCount(void) const;
   107     /**
   108      * Returns the transliterator at the given index in this chain.
   109      * @param idx index into chain, from 0 to <code>getCount() - 1</code>
   110      * @return transliterator at the given index
   111      */
   112     virtual const Transliterator& getTransliterator(int32_t idx) const;
   114     /**
   115      * Sets the transliterators.
   116      */
   117     void setTransliterators(Transliterator* const transliterators[],
   118                             int32_t count);
   120     /**
   121      * Adopts the transliterators.
   122      */
   123     void adoptTransliterators(Transliterator* adoptedTransliterators[],
   124                               int32_t count);
   126     /**
   127      * Override Transliterator:
   128      * Create a rule string that can be passed to createFromRules()
   129      * to recreate this transliterator.
   130      * @param result the string to receive the rules.  Previous
   131      * contents will be deleted.
   132      * @param escapeUnprintable if TRUE then convert unprintable
   133      * character to their hex escape representations, \uxxxx or
   134      * \Uxxxxxxxx.  Unprintable characters are those other than
   135      * U+000A, U+0020..U+007E.
   136      */
   137     virtual UnicodeString& toRules(UnicodeString& result,
   138                                    UBool escapeUnprintable) const;
   140  protected:
   141     /**
   142      * Implement Transliterator framework
   143      */
   144     virtual void handleGetSourceSet(UnicodeSet& result) const;
   146  public:
   147     /**
   148      * Override Transliterator framework
   149      */
   150     virtual UnicodeSet& getTargetSet(UnicodeSet& result) const;
   152 protected:
   153     /**
   154      * Implements {@link Transliterator#handleTransliterate}.
   155      */
   156     virtual void handleTransliterate(Replaceable& text, UTransPosition& idx,
   157                                      UBool incremental) const;
   159 public:
   161     /**
   162      * ICU "poor man's RTTI", returns a UClassID for the actual class.
   163      */
   164     virtual UClassID getDynamicClassID() const;
   166     /**
   167      * ICU "poor man's RTTI", returns a UClassID for this class.
   168      */
   169     static UClassID U_EXPORT2 getStaticClassID();
   171     /* @internal */
   172     static const UChar PASS_STRING[];
   174 private:
   176     friend class Transliterator;
   177     friend class TransliteratorAlias; // to access private ct
   179     /**
   180      * Assignment operator.
   181      */
   182     CompoundTransliterator& operator=(const CompoundTransliterator&);
   184     /**
   185      * Private constructor for Transliterator.
   186      */
   187     CompoundTransliterator(const UnicodeString& ID,
   188                            UVector& list,
   189                            UnicodeFilter* adoptedFilter,
   190                            int32_t numAnonymousRBTs,
   191                            UParseError& parseError,
   192                            UErrorCode& status);
   194     CompoundTransliterator(UVector& list,
   195                            UParseError& parseError,
   196                            UErrorCode& status);
   198     CompoundTransliterator(UVector& list,
   199                            int32_t anonymousRBTs,
   200                            UParseError& parseError,
   201                            UErrorCode& status);
   203     void init(const UnicodeString& id,
   204               UTransDirection direction,
   205               UBool fixReverseID,
   206               UErrorCode& status);
   208     void init(UVector& list,
   209               UTransDirection direction,
   210               UBool fixReverseID,
   211               UErrorCode& status);
   213     /**
   214      * Return the IDs of the given list of transliterators, concatenated
   215      * with ';' delimiting them.  Equivalent to the perlish expression
   216      * join(';', map($_.getID(), transliterators).
   217      */
   218     UnicodeString joinIDs(Transliterator* const transliterators[],
   219                           int32_t transCount);
   221     void freeTransliterators(void);
   223     void computeMaximumContextLength(void);
   224 };
   226 U_NAMESPACE_END
   228 #endif /* #if !UCONFIG_NO_TRANSLITERATION */
   230 #endif

mercurial