2 **********************************************************************
3 * Copyright (c) 2002-2004, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 **********************************************************************
6 * Date Name Description
7 * 01/14/2002 aliu Creation.
8 **********************************************************************
13 #include "unicode/utypes.h"
14 #include "unicode/uobject.h"
19 class UnicodeReplacer
;
20 class TransliterationRuleData
;
23 * <code>UnicodeFunctor</code> is an abstract base class for objects
24 * that perform match and/or replace operations on Unicode strings.
28 class U_COMMON_API UnicodeFunctor
: public UObject
{
36 virtual ~UnicodeFunctor();
39 * Return a copy of this object. All UnicodeFunctor objects
40 * have to support cloning in order to allow classes using
41 * UnicodeFunctor to implement cloning.
44 virtual UnicodeFunctor
* clone() const = 0;
47 * Cast 'this' to a UnicodeMatcher* pointer and return the
48 * pointer, or null if this is not a UnicodeMatcher*. Subclasses
49 * that mix in UnicodeMatcher as a base class must override this.
50 * This protocol is required because a pointer to a UnicodeFunctor
51 * cannot be cast to a pointer to a UnicodeMatcher, since
52 * UnicodeMatcher is a mixin that does not derive from
56 virtual UnicodeMatcher
* toMatcher() const;
59 * Cast 'this' to a UnicodeReplacer* pointer and return the
60 * pointer, or null if this is not a UnicodeReplacer*. Subclasses
61 * that mix in UnicodeReplacer as a base class must override this.
62 * This protocol is required because a pointer to a UnicodeFunctor
63 * cannot be cast to a pointer to a UnicodeReplacer, since
64 * UnicodeReplacer is a mixin that does not derive from
68 virtual UnicodeReplacer
* toReplacer() const;
71 * Return the class ID for this class. This is useful only for
72 * comparing to a return value from getDynamicClassID().
73 * @return The class ID for all objects of this class.
76 static UClassID U_EXPORT2
getStaticClassID(void);
79 * Returns a unique class ID <b>polymorphically</b>. This method
80 * is to implement a simple version of RTTI, since not all C++
81 * compilers support genuine RTTI. Polymorphic operator==() and
82 * clone() methods call this method.
84 * <p>Concrete subclasses of UnicodeFunctor should use the macro
85 * UOBJECT_DEFINE_RTTI_IMPLEMENTATION from uobject.h to
86 * provide definitios getStaticClassID and getDynamicClassID.
88 * @return The class ID for this object. All objects of a given
89 * class have the same class ID. Objects of other classes have
90 * different class IDs.
93 virtual UClassID
getDynamicClassID(void) const = 0;
96 * Set the data object associated with this functor. The data
97 * object provides context for functor-to-standin mapping. This
98 * method is required when assigning a functor to a different data
99 * object. This function MAY GO AWAY later if the architecture is
100 * changed to pass data object pointers through the API.
103 virtual void setData(const TransliterationRuleData
*) = 0;
108 * Since this class has pure virtual functions,
109 * a constructor can't be used.
112 /*UnicodeFunctor();*/
116 /*inline UnicodeFunctor::UnicodeFunctor() {}*/