diff --git a/icu4c/source/i18n/unicode/rbt.h b/icu4c/source/i18n/unicode/rbt.h index c4e3e980a36..0f800583110 100644 --- a/icu4c/source/i18n/unicode/rbt.h +++ b/icu4c/source/i18n/unicode/rbt.h @@ -375,6 +375,57 @@ public: virtual void handleTransliterate(Replaceable& text, UTransPosition& offsets, UBool isIncremental) const; + /** + * Return a representation of this transliterator as source rules. + * These rules will produce an equivalent transliterator if used + * to construct a new 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; + + /** + * Return the class ID for this class. This is useful only for + * comparing to a return value from getDynamicClassID(). For example: + *
+     * .      Base* polymorphic_pointer = createPolymorphicObject();
+     * .      if (polymorphic_pointer->getDynamicClassID() ==
+     * .          Derived::getStaticClassID()) ...
+     * 
+ * @return The class ID for all objects of this class. + * @stable + */ + static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; } + + /** + * Returns a unique class ID polymorphically. This method + * is to implement a simple version of RTTI, since not all C++ + * compilers support genuine RTTI. Polymorphic operator==() and + * clone() methods call this method. + * + *

Concrete subclasses of Transliterator that wish clients to + * be able to identify them should implement getDynamicClassID() + * and also a static method and data member: + * + *

+     * static UClassID getStaticClassID() { return (UClassID)&fgClassID; }
+     * static char fgClassID;
+     * 
+ * + * 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(); }; + /** * Parse error codes generated by RuleBasedTransliterator. * See parseerr.h. @@ -405,6 +456,11 @@ public: private: + /** + * Class identifier for RuleBasedTransliterator. + */ + static char fgClassID; + void _construct(const UnicodeString& rules, UTransDirection direction, UErrorCode& status,