1999-12-28 23:57:50 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
2003-06-03 20:58:22 +00:00
|
|
|
* Copyright (C) 1999-2003, International Business Machines
|
1999-12-28 23:57:50 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
|
|
|
* Date Name Description
|
|
|
|
* 11/17/99 aliu Creation.
|
|
|
|
**********************************************************************
|
|
|
|
*/
|
|
|
|
#ifndef CPDTRANS_H
|
|
|
|
#define CPDTRANS_H
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
|
|
|
#if !UCONFIG_NO_TRANSLITERATION
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/translit.h"
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2001-07-13 21:17:11 +00:00
|
|
|
class U_I18N_API UVector;
|
2001-10-08 23:26:58 +00:00
|
|
|
class TransliteratorRegistry;
|
2001-07-13 21:17:11 +00:00
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* @author Alan Liu
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
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.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @param adoptedFilter 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.
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
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);
|
2001-11-17 00:25:26 +00:00
|
|
|
|
2000-03-22 19:19:33 +00:00
|
|
|
/**
|
|
|
|
* Constructs a new compound transliterator.
|
2001-11-19 19:53:10 +00:00
|
|
|
* @param id compound ID
|
|
|
|
* @param dir either UTRANS_FORWARD or UTRANS_REVERSE
|
|
|
|
* @param adoptedFilter a global filter for this compound transliterator
|
|
|
|
* or NULL
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
2000-03-22 19:19:33 +00:00
|
|
|
*/
|
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,
|
2001-08-31 03:23:39 +00:00
|
|
|
UParseError& parseError,
|
2000-05-20 04:35:31 +00:00
|
|
|
UErrorCode& status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a new compound transliterator in the FORWARD
|
|
|
|
* direction with a NULL filter.
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
2000-05-20 04:35:31 +00:00
|
|
|
*/
|
2000-09-25 22:03:13 +00:00
|
|
|
CompoundTransliterator(const UnicodeString& id,
|
2001-08-31 03:23:39 +00:00
|
|
|
UParseError& parseError,
|
2000-05-20 04:35:31 +00:00
|
|
|
UErrorCode& status);
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Destructor.
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual ~CompoundTransliterator();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy constructor.
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
CompoundTransliterator(const CompoundTransliterator&);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assignment operator.
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
CompoundTransliterator& operator=(const CompoundTransliterator&);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transliterator API.
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
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.
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
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
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual const Transliterator& getTransliterator(int32_t index) const;
|
|
|
|
|
2000-03-22 19:19:33 +00:00
|
|
|
/**
|
2001-11-16 23:50:18 +00:00
|
|
|
* Sets the transliterators.
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
2000-03-22 19:19:33 +00:00
|
|
|
*/
|
1999-12-28 23:57:50 +00:00
|
|
|
void setTransliterators(Transliterator* const transliterators[],
|
|
|
|
int32_t count);
|
|
|
|
|
2000-03-22 19:19:33 +00:00
|
|
|
/**
|
2001-11-16 23:50:18 +00:00
|
|
|
* Adopts the transliterators.
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
2000-03-22 19:19:33 +00:00
|
|
|
*/
|
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.
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
2001-07-13 21:17:11 +00:00
|
|
|
*/
|
|
|
|
virtual UnicodeString& toRules(UnicodeString& result,
|
|
|
|
UBool escapeUnprintable) const;
|
|
|
|
|
2002-06-28 21:13:54 +00:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Implement Transliterator framework
|
|
|
|
*/
|
|
|
|
virtual void handleGetSourceSet(UnicodeSet& result) const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Override Transliterator framework
|
|
|
|
*/
|
|
|
|
virtual UnicodeSet& getTargetSet(UnicodeSet& result) const;
|
|
|
|
|
2003-02-14 01:44:49 +00:00
|
|
|
protected:
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
2000-01-18 18:27:27 +00:00
|
|
|
* Implements {@link Transliterator#handleTransliterate}.
|
2003-05-01 01:31:28 +00:00
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
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
|
|
|
|
2003-02-14 01:44:49 +00:00
|
|
|
public:
|
2002-11-27 00:19:55 +00:00
|
|
|
|
2002-06-29 00:04:16 +00:00
|
|
|
/**
|
|
|
|
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
|
|
|
*
|
|
|
|
* @draft ICU 2.2
|
|
|
|
*/
|
2003-02-06 22:03:58 +00:00
|
|
|
virtual inline UClassID getDynamicClassID() const;
|
2002-06-29 00:04:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ICU "poor man's RTTI", returns a UClassID for this class.
|
|
|
|
*
|
|
|
|
* @draft ICU 2.2
|
|
|
|
*/
|
2003-02-06 22:03:58 +00:00
|
|
|
static inline UClassID getStaticClassID();
|
2002-06-29 00:04:16 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
private:
|
|
|
|
|
2001-08-15 19:06:40 +00:00
|
|
|
friend class Transliterator;
|
2001-10-04 22:20:46 +00:00
|
|
|
friend class TransliteratorAlias; // to access private ct
|
2001-07-13 21:17:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2002-02-07 01:07:55 +00:00
|
|
|
CompoundTransliterator(UVector& list,
|
2002-03-01 21:56:40 +00:00
|
|
|
UParseError& parseError,
|
2001-07-13 21:17:11 +00:00
|
|
|
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);
|
2001-09-22 03:36:34 +00:00
|
|
|
|
2002-06-29 00:04:16 +00:00
|
|
|
/**
|
|
|
|
* The address of this static class variable serves as this class's ID
|
|
|
|
* for ICU "poor man's RTTI".
|
|
|
|
*/
|
|
|
|
static const char fgClassID;
|
1999-12-28 23:57:50 +00:00
|
|
|
};
|
2001-09-22 03:36:34 +00:00
|
|
|
|
2003-02-06 22:03:58 +00:00
|
|
|
inline UClassID
|
|
|
|
CompoundTransliterator::getStaticClassID()
|
|
|
|
{ return (UClassID)&fgClassID; }
|
|
|
|
|
|
|
|
inline UClassID
|
|
|
|
CompoundTransliterator::getDynamicClassID() const
|
|
|
|
{ return CompoundTransliterator::getStaticClassID(); }
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_TRANSLITERATION */
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#endif
|