1999-12-28 23:57:50 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
|
|
|
* Copyright (C) 1999, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
|
|
|
* Date Name Description
|
|
|
|
* 11/17/99 aliu Creation.
|
|
|
|
**********************************************************************
|
|
|
|
*/
|
|
|
|
#ifndef CPDTRANS_H
|
|
|
|
#define CPDTRANS_H
|
|
|
|
|
|
|
|
#include "unicode/translit.h"
|
|
|
|
|
2001-07-13 21:17:11 +00:00
|
|
|
class U_I18N_API UVector;
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* A transliterator that is composed of two or more other
|
|
|
|
* transliterator objects linked together. For example, if one
|
|
|
|
* transliterator transliterates from script A to script B, and
|
|
|
|
* another transliterates from script B to script C, the two may be
|
|
|
|
* combined to form a new transliterator from A to C.
|
|
|
|
*
|
|
|
|
* <p>Composed transliterators may not behave as expected. For
|
|
|
|
* example, inverses may not combine to form the identity
|
|
|
|
* transliterator. See the class documentation for {@link
|
|
|
|
* Transliterator} for details.
|
|
|
|
*
|
|
|
|
* <p>If a non-<tt>null</tt> <tt>UnicodeFilter</tt> is applied to a
|
|
|
|
* <tt>CompoundTransliterator</tt>, it has the effect of being
|
|
|
|
* logically <b>and</b>ed with the filter of each transliterator in
|
|
|
|
* the chain.
|
|
|
|
*
|
|
|
|
* <p>Copyright © IBM Corporation 1999. All rights reserved.
|
|
|
|
*
|
|
|
|
* @author Alan Liu
|
2001-07-17 00:16:02 +00:00
|
|
|
* @version $RCSfile: cpdtrans.h,v $ $Revision: 1.15 $ $Date: 2001/07/17 00:15:49 $
|
2000-03-22 19:19:33 +00:00
|
|
|
* @draft
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
class U_I18N_API CompoundTransliterator : public Transliterator {
|
|
|
|
|
|
|
|
Transliterator** trans;
|
|
|
|
|
|
|
|
int32_t count;
|
|
|
|
|
2001-07-13 21:17:11 +00:00
|
|
|
/**
|
|
|
|
* For compound RBTs (those with an ::id block before and/or after
|
|
|
|
* the main rule block) we record the index of the RBT here.
|
|
|
|
* Otherwise, this should have a value of -1. We need this
|
|
|
|
* information to implement toRules().
|
|
|
|
*/
|
|
|
|
int32_t compoundRBTIndex;
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a new compound transliterator given an array of
|
|
|
|
* transliterators. The array of transliterators may be of any
|
|
|
|
* length, including zero or one, however, useful compound
|
|
|
|
* transliterators have at least two components.
|
|
|
|
* @param transliterators array of <code>Transliterator</code>
|
|
|
|
* objects
|
2000-12-09 02:38:12 +00:00
|
|
|
* @param transliteratorCount The number of
|
|
|
|
* <code>Transliterator</code> objects in transliterators.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @param filter the filter. Any character for which
|
2000-01-18 20:00:56 +00:00
|
|
|
* <tt>filter.contains()</tt> returns <tt>false</tt> will not be
|
1999-12-28 23:57:50 +00:00
|
|
|
* altered by this transliterator. If <tt>filter</tt> is
|
|
|
|
* <tt>null</tt> then no filtering is applied.
|
2000-03-22 19:19:33 +00:00
|
|
|
* @draft
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2000-01-14 21:15:25 +00:00
|
|
|
CompoundTransliterator(Transliterator* const transliterators[],
|
2000-12-09 02:38:12 +00:00
|
|
|
int32_t transliteratorCount,
|
1999-12-28 23:57:50 +00:00
|
|
|
UnicodeFilter* adoptedFilter = 0);
|
|
|
|
|
2000-03-22 19:19:33 +00:00
|
|
|
/**
|
|
|
|
* Constructs a new compound transliterator.
|
|
|
|
* @param filter the filter. Any character for which
|
|
|
|
* <tt>filter.isIn()</tt> returns <tt>false</tt> will not be
|
|
|
|
* altered by this transliterator. If <tt>filter</tt> is
|
|
|
|
* <tt>null</tt> then no filtering is applied.
|
|
|
|
* @draft
|
|
|
|
*/
|
2000-09-25 22:03:13 +00:00
|
|
|
CompoundTransliterator(const UnicodeString& id,
|
2000-06-27 19:00:38 +00:00
|
|
|
UTransDirection dir,
|
2000-05-20 04:35:31 +00:00
|
|
|
UnicodeFilter* adoptedFilter,
|
|
|
|
UErrorCode& status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a new compound transliterator in the FORWARD
|
|
|
|
* direction with a NULL filter.
|
|
|
|
* @draft
|
|
|
|
*/
|
2000-09-25 22:03:13 +00:00
|
|
|
CompoundTransliterator(const UnicodeString& id,
|
2000-05-20 04:35:31 +00:00
|
|
|
UErrorCode& status);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor.
|
2000-03-22 19:19:33 +00:00
|
|
|
* @draft
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual ~CompoundTransliterator();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy constructor.
|
2000-03-22 19:19:33 +00:00
|
|
|
* @draft
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
CompoundTransliterator(const CompoundTransliterator&);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assignment operator.
|
2000-03-22 19:19:33 +00:00
|
|
|
* @draft
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
CompoundTransliterator& operator=(const CompoundTransliterator&);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transliterator API.
|
2000-03-22 19:19:33 +00:00
|
|
|
* @draft
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
Transliterator* clone(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of transliterators in this chain.
|
|
|
|
* @return number of transliterators in this chain.
|
2000-03-22 19:19:33 +00:00
|
|
|
* @draft
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual int32_t getCount(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the transliterator at the given index in this chain.
|
|
|
|
* @param index index into chain, from 0 to <code>getCount() - 1</code>
|
|
|
|
* @return transliterator at the given index
|
2000-03-22 19:19:33 +00:00
|
|
|
* @draft
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual const Transliterator& getTransliterator(int32_t index) const;
|
|
|
|
|
2000-03-22 19:19:33 +00:00
|
|
|
/**
|
|
|
|
* @draft
|
|
|
|
*/
|
1999-12-28 23:57:50 +00:00
|
|
|
void setTransliterators(Transliterator* const transliterators[],
|
|
|
|
int32_t count);
|
|
|
|
|
2000-03-22 19:19:33 +00:00
|
|
|
/**
|
|
|
|
* @draft
|
|
|
|
*/
|
1999-12-28 23:57:50 +00:00
|
|
|
void adoptTransliterators(Transliterator* adoptedTransliterators[],
|
|
|
|
int32_t count);
|
|
|
|
|
2001-07-13 21:17:11 +00:00
|
|
|
/**
|
|
|
|
* Override Transliterator:
|
|
|
|
* Create a rule string that can be passed to createFromRules()
|
|
|
|
* to recreate this transliterator.
|
|
|
|
* @param result the string to receive the rules. Previous
|
|
|
|
* contents will be deleted.
|
|
|
|
* @param escapeUnprintable if TRUE then convert unprintable
|
|
|
|
* character to their hex escape representations, \uxxxx or
|
|
|
|
* \Uxxxxxxxx. Unprintable characters are those other than
|
|
|
|
* U+000A, U+0020..U+007E.
|
|
|
|
*/
|
|
|
|
virtual UnicodeString& toRules(UnicodeString& result,
|
|
|
|
UBool escapeUnprintable) const;
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
2000-01-18 18:27:27 +00:00
|
|
|
* Implements {@link Transliterator#handleTransliterate}.
|
2000-03-22 19:19:33 +00:00
|
|
|
* @draft
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2000-06-27 19:00:38 +00:00
|
|
|
virtual void handleTransliterate(Replaceable& text, UTransPosition& index,
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool incremental) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2001-07-13 21:17:11 +00:00
|
|
|
friend Transliterator; // to access private ct
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Private constructor for compound RBTs. Construct a compound
|
|
|
|
* transliterator using the given idBlock, with the adoptedTrans
|
|
|
|
* inserted at the idSplitPoint.
|
|
|
|
*/
|
|
|
|
CompoundTransliterator(const UnicodeString& ID,
|
|
|
|
const UnicodeString& idBlock,
|
|
|
|
int32_t idSplitPoint,
|
|
|
|
Transliterator *adoptedTrans,
|
|
|
|
UErrorCode& status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Private constructor for Transliterator.
|
|
|
|
*/
|
2001-07-16 20:48:46 +00:00
|
|
|
CompoundTransliterator(UTransDirection dir,
|
2001-07-13 21:17:11 +00:00
|
|
|
UVector& list,
|
|
|
|
UErrorCode& status);
|
|
|
|
|
2000-09-25 22:03:13 +00:00
|
|
|
void init(const UnicodeString& id,
|
2001-07-13 21:17:11 +00:00
|
|
|
UTransDirection direction,
|
|
|
|
int32_t idSplitPoint,
|
|
|
|
Transliterator *adoptedRbt,
|
|
|
|
UBool fixReverseID,
|
|
|
|
UErrorCode& status);
|
|
|
|
|
|
|
|
void init(UVector& list,
|
|
|
|
UTransDirection direction,
|
|
|
|
UBool fixReverseID,
|
2000-05-20 04:35:31 +00:00
|
|
|
UErrorCode& status);
|
|
|
|
|
2000-01-14 21:15:25 +00:00
|
|
|
/**
|
|
|
|
* Return the IDs of the given list of transliterators, concatenated
|
|
|
|
* with ';' delimiting them. Equivalent to the perlish expression
|
|
|
|
* join(';', map($_.getID(), transliterators).
|
|
|
|
*/
|
|
|
|
UnicodeString joinIDs(Transliterator* const transliterators[],
|
2000-09-25 22:03:13 +00:00
|
|
|
int32_t transCount);
|
2000-01-14 21:15:25 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
void freeTransliterators(void);
|
2000-01-18 18:27:27 +00:00
|
|
|
|
|
|
|
void computeMaximumContextLength(void);
|
1999-12-28 23:57:50 +00:00
|
|
|
};
|
|
|
|
#endif
|