1999-12-28 23:57:50 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
2009-04-02 07:34:37 +00:00
|
|
|
* Copyright (C) 1999-2009, 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
|
|
|
|
|
2003-11-03 23:39:38 +00:00
|
|
|
class U_COMMON_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;
|
|
|
|
|
2005-06-09 17:30:48 +00:00
|
|
|
int32_t numAnonymousRBTs;
|
2001-07-13 21:17:11 +00:00
|
|
|
|
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&);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*/
|
2004-08-28 04:42:33 +00:00
|
|
|
virtual Transliterator* clone(void) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
2009-04-02 07:34:37 +00:00
|
|
|
* @param idx index into chain, from 0 to <code>getCount() - 1</code>
|
1999-12-28 23:57:50 +00:00
|
|
|
* @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
|
|
|
*/
|
2009-04-02 07:34:37 +00:00
|
|
|
virtual const Transliterator& getTransliterator(int32_t idx) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
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
|
|
|
*/
|
2009-04-02 07:34:37 +00:00
|
|
|
virtual void handleTransliterate(Replaceable& text, UTransPosition& idx,
|
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-08-31 20:53:46 +00:00
|
|
|
virtual 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
|
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static UClassID U_EXPORT2 getStaticClassID();
|
2002-06-29 00:04:16 +00:00
|
|
|
|
2005-06-21 16:55:19 +00:00
|
|
|
/* @internal */
|
|
|
|
static const UChar PASS_STRING[];
|
|
|
|
|
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
|
|
|
|
2007-06-08 22:31:20 +00:00
|
|
|
/**
|
|
|
|
* Assignment operator.
|
|
|
|
* @internal Use transliterator factory methods instead since this class will be removed in that release.
|
|
|
|
*/
|
|
|
|
CompoundTransliterator& operator=(const CompoundTransliterator&);
|
|
|
|
|
2001-07-13 21:17:11 +00:00
|
|
|
/**
|
2005-06-09 17:30:48 +00:00
|
|
|
* Private constructor for Transliterator.
|
2001-07-13 21:17:11 +00:00
|
|
|
*/
|
|
|
|
CompoundTransliterator(const UnicodeString& ID,
|
2005-06-09 17:30:48 +00:00
|
|
|
UVector& list,
|
|
|
|
UnicodeFilter* adoptedFilter,
|
|
|
|
int32_t numAnonymousRBTs,
|
|
|
|
UParseError& parseError,
|
2001-07-13 21:17:11 +00:00
|
|
|
UErrorCode& status);
|
2005-06-09 17:30:48 +00:00
|
|
|
|
|
|
|
CompoundTransliterator(UVector& list,
|
|
|
|
UParseError& parseError,
|
|
|
|
UErrorCode& status);
|
|
|
|
|
2002-02-07 01:07:55 +00:00
|
|
|
CompoundTransliterator(UVector& list,
|
2005-06-09 17:30:48 +00:00
|
|
|
int32_t anonymousRBTs,
|
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,
|
|
|
|
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
|
|
|
};
|
2001-09-22 03:36:34 +00:00
|
|
|
|
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
|