1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 **********************************************************************
5 * Copyright (c) 2002-2005, International Business Machines Corporation
6 * and others. All Rights Reserved.
7 **********************************************************************
8 * Date Name Description
9 * 01/14/2002 aliu Creation.
10 **********************************************************************
15 #include "unicode/utypes.h"
17 #if U_SHOW_CPLUSPLUS_API
19 #include "unicode/uobject.h"
23 * \brief C++ API: Unicode Functor
29 class UnicodeReplacer
;
30 class TransliterationRuleData
;
33 * <code>UnicodeFunctor</code> is an abstract base class for objects
34 * that perform match and/or replace operations on Unicode strings.
38 class U_COMMON_API UnicodeFunctor
: public UObject
{
46 virtual ~UnicodeFunctor();
49 * Return a copy of this object. All UnicodeFunctor objects
50 * have to support cloning in order to allow classes using
51 * UnicodeFunctor to implement cloning.
54 virtual UnicodeFunctor
* clone() const = 0;
57 * Cast 'this' to a UnicodeMatcher* pointer and return the
58 * pointer, or null if this is not a UnicodeMatcher*. Subclasses
59 * that mix in UnicodeMatcher as a base class must override this.
60 * This protocol is required because a pointer to a UnicodeFunctor
61 * cannot be cast to a pointer to a UnicodeMatcher, since
62 * UnicodeMatcher is a mixin that does not derive from
66 virtual UnicodeMatcher
* toMatcher() const;
69 * Cast 'this' to a UnicodeReplacer* pointer and return the
70 * pointer, or null if this is not a UnicodeReplacer*. Subclasses
71 * that mix in UnicodeReplacer as a base class must override this.
72 * This protocol is required because a pointer to a UnicodeFunctor
73 * cannot be cast to a pointer to a UnicodeReplacer, since
74 * UnicodeReplacer is a mixin that does not derive from
78 virtual UnicodeReplacer
* toReplacer() const;
81 * Return the class ID for this class. This is useful only for
82 * comparing to a return value from getDynamicClassID().
83 * @return The class ID for all objects of this class.
86 static UClassID U_EXPORT2
getStaticClassID(void);
89 * Returns a unique class ID <b>polymorphically</b>. This method
90 * is to implement a simple version of RTTI, since not all C++
91 * compilers support genuine RTTI. Polymorphic operator==() and
92 * clone() methods call this method.
94 * <p>Concrete subclasses of UnicodeFunctor should use the macro
95 * UOBJECT_DEFINE_RTTI_IMPLEMENTATION from uobject.h to
96 * provide definitios getStaticClassID and getDynamicClassID.
98 * @return The class ID for this object. All objects of a given
99 * class have the same class ID. Objects of other classes have
100 * different class IDs.
103 virtual UClassID
getDynamicClassID(void) const = 0;
106 * Set the data object associated with this functor. The data
107 * object provides context for functor-to-standin mapping. This
108 * method is required when assigning a functor to a different data
109 * object. This function MAY GO AWAY later if the architecture is
110 * changed to pass data object pointers through the API.
113 virtual void setData(const TransliterationRuleData
*) = 0;
118 * Since this class has pure virtual functions,
119 * a constructor can't be used.
122 /*UnicodeFunctor();*/
126 /*inline UnicodeFunctor::UnicodeFunctor() {}*/
130 #endif /* U_SHOW_CPLUSPLUS_API */