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-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.
|
|
|
|
*
|
|
|
|
* <p>Copyright © IBM Corporation 1999. All rights reserved.
|
|
|
|
*
|
|
|
|
* @author Alan Liu
|
2001-11-19 19:53:10 +00:00
|
|
|
* @version $RCSfile: cpdtrans.h,v $ $Revision: 1.25 $ $Date: 2001/11/19 19:53:10 $
|
2001-11-16 23:50:18 +00:00
|
|
|
* @deprecated To be removed after 2002-sep-30.
|
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.
|
2001-11-16 23:50:18 +00:00
|
|
|
* @deprecated To be removed after 2002-sep-30; use the Transliterator::createInstance factory method.
|
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
|
2001-11-17 00:25:26 +00:00
|
|
|
* @deprecated To be removed after 2002-sep-30; use the Transliterator::createInstance factory method.
|
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.
|
2001-11-17 00:25:26 +00:00
|
|
|
* @deprecated To be removed after 2002-sep-30; use the Transliterator::createInstance factory method.
|
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.
|
2001-11-17 00:25:26 +00:00
|
|
|
* @deprecated To be removed after 2002-sep-30.
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual ~CompoundTransliterator();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy constructor.
|
2001-11-16 23:50:18 +00:00
|
|
|
* @deprecated To be removed after 2002-sep-30; use the Transliterator::createInstance factory method.
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
CompoundTransliterator(const CompoundTransliterator&);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assignment operator.
|
2001-11-16 23:50:18 +00:00
|
|
|
* @deprecated To be removed after 2002-sep-30.
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
CompoundTransliterator& operator=(const CompoundTransliterator&);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transliterator API.
|
2001-11-16 23:50:18 +00:00
|
|
|
* @deprecated To be removed after 2002-sep-30.
|
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.
|
2001-11-16 23:50:18 +00:00
|
|
|
* @deprecated To be removed after 2002-sep-30.
|
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
|
2001-11-16 23:50:18 +00:00
|
|
|
* @deprecated To be removed after 2002-sep-30.
|
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.
|
|
|
|
* @deprecated To be removed after 2002-sep-30.
|
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.
|
|
|
|
* @deprecated To be removed after 2002-sep-30.
|
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.
|
2001-11-16 23:50:18 +00:00
|
|
|
* @deprecated To be removed after 2002-sep-30.
|
2001-07-13 21:17:11 +00:00
|
|
|
*/
|
|
|
|
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}.
|
2001-11-16 23:50:18 +00:00
|
|
|
* @deprecated To be removed after 2002-sep-30.
|
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-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,
|
2001-08-31 03:23:39 +00:00
|
|
|
UParseError& parseError,
|
2001-07-13 21:17:11 +00:00
|
|
|
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,
|
2001-08-31 03:23:39 +00:00
|
|
|
UParseError& parseError,
|
2001-07-13 21:17:11 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
#ifdef U_USE_DEPRECATED_TRANSLITERATOR_API
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a new compound transliterator.
|
2001-11-16 23:50:18 +00:00
|
|
|
* Use Transliterator::createInstance factory method.
|
2001-09-22 03:36:34 +00:00
|
|
|
* @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.
|
|
|
|
* @deprecated Remove after Aug 2002. Use the constructor that takes
|
|
|
|
* UParseError as one of the paramerters.
|
|
|
|
*/
|
|
|
|
CompoundTransliterator(const UnicodeString& id,
|
|
|
|
UTransDirection dir,
|
|
|
|
UnicodeFilter* adoptedFilter,
|
|
|
|
UErrorCode& status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a new compound transliterator in the FORWARD
|
|
|
|
* direction with a NULL filter.
|
2001-11-16 23:50:18 +00:00
|
|
|
* Use Transliterator::createInstance factory method.
|
2001-09-22 03:36:34 +00:00
|
|
|
* @deprecated Remove after Aug 2002. Use the constructor that takes
|
|
|
|
* UParseError as one of the parmeters.
|
|
|
|
*/
|
|
|
|
CompoundTransliterator(const UnicodeString& id,
|
|
|
|
UErrorCode& status);
|
|
|
|
|
|
|
|
#endif
|
1999-12-28 23:57:50 +00:00
|
|
|
};
|
2001-09-22 03:36:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Definitions for deprecated API
|
|
|
|
* @deprecated Remove after Aug 2002
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef U_USE_DEPRECATED_TRANSLITERATOR_API
|
|
|
|
|
|
|
|
inline CompoundTransliterator::CompoundTransliterator( const UnicodeString& id,
|
|
|
|
UTransDirection dir,
|
|
|
|
UnicodeFilter* adoptedFilter,
|
|
|
|
UErrorCode& status):
|
|
|
|
Transliterator(id, adoptedFilter),
|
|
|
|
trans(0), compoundRBTIndex(-1) {
|
|
|
|
UParseError parseError;
|
|
|
|
init(id, dir, -1, 0, TRUE,parseError,status);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline CompoundTransliterator::CompoundTransliterator(const UnicodeString& id,
|
|
|
|
UErrorCode& status) :
|
|
|
|
Transliterator(id, 0), // set filter to 0 here!
|
|
|
|
trans(0), compoundRBTIndex(-1) {
|
|
|
|
UParseError parseError;
|
|
|
|
init(id, UTRANS_FORWARD, -1, 0, TRUE,parseError,status);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#endif
|