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"
16 #include "unicode/uobject.h"
20 * \brief C++ API: Unicode Functor
23 #if U_SHOW_CPLUSPLUS_API
27 class UnicodeReplacer
;
28 class TransliterationRuleData
;
31 * <code>UnicodeFunctor</code> is an abstract base class for objects
32 * that perform match and/or replace operations on Unicode strings.
36 class U_COMMON_API UnicodeFunctor
: public UObject
{
44 virtual ~UnicodeFunctor();
47 * Return a copy of this object. All UnicodeFunctor objects
48 * have to support cloning in order to allow classes using
49 * UnicodeFunctor to implement cloning.
52 virtual UnicodeFunctor
* clone() const = 0;
55 * Cast 'this' to a UnicodeMatcher* pointer and return the
56 * pointer, or null if this is not a UnicodeMatcher*. Subclasses
57 * that mix in UnicodeMatcher as a base class must override this.
58 * This protocol is required because a pointer to a UnicodeFunctor
59 * cannot be cast to a pointer to a UnicodeMatcher, since
60 * UnicodeMatcher is a mixin that does not derive from
64 virtual UnicodeMatcher
* toMatcher() const;
67 * Cast 'this' to a UnicodeReplacer* pointer and return the
68 * pointer, or null if this is not a UnicodeReplacer*. Subclasses
69 * that mix in UnicodeReplacer as a base class must override this.
70 * This protocol is required because a pointer to a UnicodeFunctor
71 * cannot be cast to a pointer to a UnicodeReplacer, since
72 * UnicodeReplacer is a mixin that does not derive from
76 virtual UnicodeReplacer
* toReplacer() const;
79 * Return the class ID for this class. This is useful only for
80 * comparing to a return value from getDynamicClassID().
81 * @return The class ID for all objects of this class.
84 static UClassID U_EXPORT2
getStaticClassID(void);
87 * Returns a unique class ID <b>polymorphically</b>. This method
88 * is to implement a simple version of RTTI, since not all C++
89 * compilers support genuine RTTI. Polymorphic operator==() and
90 * clone() methods call this method.
92 * <p>Concrete subclasses of UnicodeFunctor should use the macro
93 * UOBJECT_DEFINE_RTTI_IMPLEMENTATION from uobject.h to
94 * provide definitios getStaticClassID and getDynamicClassID.
96 * @return The class ID for this object. All objects of a given
97 * class have the same class ID. Objects of other classes have
98 * different class IDs.
101 virtual UClassID
getDynamicClassID(void) const = 0;
104 * Set the data object associated with this functor. The data
105 * object provides context for functor-to-standin mapping. This
106 * method is required when assigning a functor to a different data
107 * object. This function MAY GO AWAY later if the architecture is
108 * changed to pass data object pointers through the API.
111 virtual void setData(const TransliterationRuleData
*) = 0;
116 * Since this class has pure virtual functions,
117 * a constructor can't be used.
120 /*UnicodeFunctor();*/
124 /*inline UnicodeFunctor::UnicodeFunctor() {}*/
127 #endif // U_SHOW_CPLUSPLUS_API