michael@0: /* michael@0: ********************************************************************** michael@0: * Copyright (c) 2002-2005, International Business Machines Corporation michael@0: * and others. All Rights Reserved. michael@0: ********************************************************************** michael@0: * Date Name Description michael@0: * 01/14/2002 aliu Creation. michael@0: ********************************************************************** michael@0: */ michael@0: #ifndef UNIFUNCT_H michael@0: #define UNIFUNCT_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: #include "unicode/uobject.h" michael@0: michael@0: /** michael@0: * \file michael@0: * \brief C++ API: Unicode Functor michael@0: */ michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: class UnicodeMatcher; michael@0: class UnicodeReplacer; michael@0: class TransliterationRuleData; michael@0: michael@0: /** michael@0: * UnicodeFunctor is an abstract base class for objects michael@0: * that perform match and/or replace operations on Unicode strings. michael@0: * @author Alan Liu michael@0: * @stable ICU 2.4 michael@0: */ michael@0: class U_COMMON_API UnicodeFunctor : public UObject { michael@0: michael@0: public: michael@0: michael@0: /** michael@0: * Destructor michael@0: * @stable ICU 2.4 michael@0: */ michael@0: virtual ~UnicodeFunctor(); michael@0: michael@0: /** michael@0: * Return a copy of this object. All UnicodeFunctor objects michael@0: * have to support cloning in order to allow classes using michael@0: * UnicodeFunctor to implement cloning. michael@0: * @stable ICU 2.4 michael@0: */ michael@0: virtual UnicodeFunctor* clone() const = 0; michael@0: michael@0: /** michael@0: * Cast 'this' to a UnicodeMatcher* pointer and return the michael@0: * pointer, or null if this is not a UnicodeMatcher*. Subclasses michael@0: * that mix in UnicodeMatcher as a base class must override this. michael@0: * This protocol is required because a pointer to a UnicodeFunctor michael@0: * cannot be cast to a pointer to a UnicodeMatcher, since michael@0: * UnicodeMatcher is a mixin that does not derive from michael@0: * UnicodeFunctor. michael@0: * @stable ICU 2.4 michael@0: */ michael@0: virtual UnicodeMatcher* toMatcher() const; michael@0: michael@0: /** michael@0: * Cast 'this' to a UnicodeReplacer* pointer and return the michael@0: * pointer, or null if this is not a UnicodeReplacer*. Subclasses michael@0: * that mix in UnicodeReplacer as a base class must override this. michael@0: * This protocol is required because a pointer to a UnicodeFunctor michael@0: * cannot be cast to a pointer to a UnicodeReplacer, since michael@0: * UnicodeReplacer is a mixin that does not derive from michael@0: * UnicodeFunctor. michael@0: * @stable ICU 2.4 michael@0: */ michael@0: virtual UnicodeReplacer* toReplacer() const; michael@0: michael@0: /** michael@0: * Return the class ID for this class. This is useful only for michael@0: * comparing to a return value from getDynamicClassID(). michael@0: * @return The class ID for all objects of this class. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: static UClassID U_EXPORT2 getStaticClassID(void); michael@0: michael@0: /** michael@0: * Returns a unique class ID polymorphically. This method michael@0: * is to implement a simple version of RTTI, since not all C++ michael@0: * compilers support genuine RTTI. Polymorphic operator==() and michael@0: * clone() methods call this method. michael@0: * michael@0: *

Concrete subclasses of UnicodeFunctor should use the macro michael@0: * UOBJECT_DEFINE_RTTI_IMPLEMENTATION from uobject.h to michael@0: * provide definitios getStaticClassID and getDynamicClassID. michael@0: * michael@0: * @return The class ID for this object. All objects of a given michael@0: * class have the same class ID. Objects of other classes have michael@0: * different class IDs. michael@0: * @stable ICU 2.4 michael@0: */ michael@0: virtual UClassID getDynamicClassID(void) const = 0; michael@0: michael@0: /** michael@0: * Set the data object associated with this functor. The data michael@0: * object provides context for functor-to-standin mapping. This michael@0: * method is required when assigning a functor to a different data michael@0: * object. This function MAY GO AWAY later if the architecture is michael@0: * changed to pass data object pointers through the API. michael@0: * @internal ICU 2.1 michael@0: */ michael@0: virtual void setData(const TransliterationRuleData*) = 0; michael@0: michael@0: protected: michael@0: michael@0: /** michael@0: * Since this class has pure virtual functions, michael@0: * a constructor can't be used. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: /*UnicodeFunctor();*/ michael@0: michael@0: }; michael@0: michael@0: /*inline UnicodeFunctor::UnicodeFunctor() {}*/ michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif