/*
**********************************************************************
-* Copyright (C) 1999-2003, International Business Machines
+* Copyright (C) 1999-2007, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
#include "unicode/translit.h"
#include "unicode/utypes.h"
#include "unicode/parseerr.h"
+#include "unicode/udata.h"
+
+#define U_ICUDATA_TRANSLIT U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "translit"
U_NAMESPACE_BEGIN
* @author Alan Liu
* @internal Use transliterator factory methods instead since this class will be removed in that release.
*/
-class U_I18N_API RuleBasedTransliterator : public Transliterator {
-
+class RuleBasedTransliterator : public Transliterator {
+private:
/**
* The data object is immutable, so we can freely share it with
* other instances of RBT, as long as we do NOT own this object.
+ * TODO: data is no longer immutable. See bugs #1866, 2155
*/
- TransliterationRuleData* data;
+ TransliterationRuleData* fData;
/**
* If true, we own the data object and must delete it.
* @exception IllegalArgumentException if rules are malformed.
* @internal Use transliterator factory methods instead since this class will be removed in that release.
*/
- RuleBasedTransliterator(const UnicodeString& id,
+ /*RuleBasedTransliterator(const UnicodeString& id,
const UnicodeString& rules,
UTransDirection direction,
UnicodeFilter* adoptedFilter,
- UErrorCode& status);
+ UErrorCode& status);*/
/**
* Covenience constructor with no filter.
* @internal Use transliterator factory methods instead since this class will be removed in that release.
*/
- RuleBasedTransliterator(const UnicodeString& id,
+ /*RuleBasedTransliterator(const UnicodeString& id,
const UnicodeString& rules,
UTransDirection direction,
- UErrorCode& status);
+ UErrorCode& status);*/
/**
* Covenience constructor with no filter and FORWARD direction.
* @internal Use transliterator factory methods instead since this class will be removed in that release.
*/
- RuleBasedTransliterator(const UnicodeString& id,
+ /*RuleBasedTransliterator(const UnicodeString& id,
const UnicodeString& rules,
- UErrorCode& status);
+ UErrorCode& status);*/
/**
* Covenience constructor with FORWARD direction.
* @internal Use transliterator factory methods instead since this class will be removed in that release.
*/
- RuleBasedTransliterator(const UnicodeString& id,
+ /*RuleBasedTransliterator(const UnicodeString& id,
const UnicodeString& rules,
UnicodeFilter* adoptedFilter,
- UErrorCode& status);
- private:
+ UErrorCode& status);*/
+private:
friend class TransliteratorRegistry; // to access TransliterationRuleData convenience ctor
/**
TransliterationRuleData* data,
UBool isDataAdopted);
- public:
+public:
/**
* Copy constructor.
* Implement Transliterator API.
* @internal Use transliterator factory methods instead since this class will be removed in that release.
*/
- Transliterator* clone(void) const;
+ virtual Transliterator* clone(void) const;
- protected:
+protected:
/**
* Implements {@link Transliterator#handleTransliterate}.
* @internal Use transliterator factory methods instead since this class will be removed in that release.
virtual void handleTransliterate(Replaceable& text, UTransPosition& offsets,
UBool isIncremental) const;
- public:
+public:
/**
* Return a representation of this transliterator as source rules.
* These rules will produce an equivalent transliterator if used
virtual UnicodeString& toRules(UnicodeString& result,
UBool escapeUnprintable) const;
- protected:
+protected:
/**
* Implement Transliterator framework
*/
virtual void handleGetSourceSet(UnicodeSet& result) const;
- public:
+public:
/**
* Override Transliterator framework
*/
* @return The class ID for all objects of this class.
* @internal Use transliterator factory methods instead since this class will be removed in that release.
*/
- static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
/**
* Returns a unique class ID <b>polymorphically</b>. This method
* compilers support genuine RTTI. Polymorphic operator==() and
* clone() methods call this method.
*
- * <p>Concrete subclasses of Transliterator that wish clients to
- * be able to identify them should implement getDynamicClassID()
- * and also a static method and data member:
- *
- * <pre>
- * static UClassID getStaticClassID() { return (UClassID)&fgClassID; }
- * static char fgClassID;
- * </pre>
- *
- * Subclasses that do not implement this method will have a
- * dynamic class ID of Transliterator::getStatisClassID().
- *
* @return The class ID for this object. All objects of a given
* class have the same class ID. Objects of other classes have
* different class IDs.
*/
- virtual UClassID getDynamicClassID(void) const { return getStaticClassID(); };
+ virtual UClassID getDynamicClassID(void) const;
private:
- /**
- * Class identifier for RuleBasedTransliterator.
- */
- static const char fgClassID;
-
void _construct(const UnicodeString& rules,
UTransDirection direction,
UParseError& parseError,
UErrorCode& status);
};
-/**
- * Constructs a new transliterator from the given rules.
- * @param id the id for the transliterator.
- * @param rules rules, separated by ';'
- * @param direction either FORWARD or REVERSE.
- * @param adoptedFilter the filter for this transliterator.
- * @param parseError Struct to recieve information on position
- * of error if an error is encountered
- * @param status Output param set to success/failure code.
- * @exception IllegalArgumentException if rules are malformed
- * or direction is invalid.
- */
-inline RuleBasedTransliterator::RuleBasedTransliterator(
- const UnicodeString& id,
- const UnicodeString& rules,
- UTransDirection direction,
- UnicodeFilter* adoptedFilter,
- UParseError& parseError,
- UErrorCode& status) :
- Transliterator(id, adoptedFilter) {
- _construct(rules, direction,parseError,status);
-}
-
-/**
- * Constructs a new transliterator from the given rules.
- * @param id the id for the transliterator.
- * @param rules rules, separated by ';'
- * @param direction either FORWARD or REVERSE.
- * @param adoptedFilter the filter for this transliterator.
- * @param status Output param set to success/failure code.
- * @exception IllegalArgumentException if rules are malformed
- * or direction is invalid.
- */
-inline RuleBasedTransliterator::RuleBasedTransliterator(
- const UnicodeString& id,
- const UnicodeString& rules,
- UTransDirection direction,
- UnicodeFilter* adoptedFilter,
- UErrorCode& status) :
- Transliterator(id, adoptedFilter) {
- UParseError parseError;
- _construct(rules, direction,parseError, status);
-}
-
-/**
- * Covenience constructor with no filter.
- */
-inline RuleBasedTransliterator::RuleBasedTransliterator(
- const UnicodeString& id,
- const UnicodeString& rules,
- UTransDirection direction,
- UErrorCode& status) :
- Transliterator(id, 0) {
- UParseError parseError;
- _construct(rules, direction,parseError, status);
-}
-
-/**
- * Covenience constructor with no filter and FORWARD direction.
- */
-inline RuleBasedTransliterator::RuleBasedTransliterator(
- const UnicodeString& id,
- const UnicodeString& rules,
- UErrorCode& status) :
- Transliterator(id, 0) {
- UParseError parseError;
- _construct(rules, UTRANS_FORWARD, parseError, status);
-}
-
-/**
- * Covenience constructor with FORWARD direction.
- */
-inline RuleBasedTransliterator::RuleBasedTransliterator(
- const UnicodeString& id,
- const UnicodeString& rules,
- UnicodeFilter* adoptedFilter,
- UErrorCode& status) :
- Transliterator(id, adoptedFilter) {
- UParseError parseError;
- _construct(rules, UTRANS_FORWARD,parseError, status);
-}
U_NAMESPACE_END