1 // Copyright (C) 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
26 class UnicodeReplacer;
27 class TransliterationRuleData;
30 * <code>UnicodeFunctor</code> is an abstract base class for objects
31 * that perform match and/or replace operations on Unicode strings.
35 class U_COMMON_API UnicodeFunctor : public UObject {
43 virtual ~UnicodeFunctor();
46 * Return a copy of this object. All UnicodeFunctor objects
47 * have to support cloning in order to allow classes using
48 * UnicodeFunctor to implement cloning.
51 virtual UnicodeFunctor* clone() const = 0;
54 * Cast 'this' to a UnicodeMatcher* pointer and return the
55 * pointer, or null if this is not a UnicodeMatcher*. Subclasses
56 * that mix in UnicodeMatcher as a base class must override this.
57 * This protocol is required because a pointer to a UnicodeFunctor
58 * cannot be cast to a pointer to a UnicodeMatcher, since
59 * UnicodeMatcher is a mixin that does not derive from
63 virtual UnicodeMatcher* toMatcher() const;
66 * Cast 'this' to a UnicodeReplacer* pointer and return the
67 * pointer, or null if this is not a UnicodeReplacer*. Subclasses
68 * that mix in UnicodeReplacer as a base class must override this.
69 * This protocol is required because a pointer to a UnicodeFunctor
70 * cannot be cast to a pointer to a UnicodeReplacer, since
71 * UnicodeReplacer is a mixin that does not derive from
75 virtual UnicodeReplacer* toReplacer() const;
78 * Return the class ID for this class. This is useful only for
79 * comparing to a return value from getDynamicClassID().
80 * @return The class ID for all objects of this class.
83 static UClassID U_EXPORT2 getStaticClassID(void);
86 * Returns a unique class ID <b>polymorphically</b>. This method
87 * is to implement a simple version of RTTI, since not all C++
88 * compilers support genuine RTTI. Polymorphic operator==() and
89 * clone() methods call this method.
91 * <p>Concrete subclasses of UnicodeFunctor should use the macro
92 * UOBJECT_DEFINE_RTTI_IMPLEMENTATION from uobject.h to
93 * provide definitios getStaticClassID and getDynamicClassID.
95 * @return The class ID for this object. All objects of a given
96 * class have the same class ID. Objects of other classes have
97 * different class IDs.
100 virtual UClassID getDynamicClassID(void) const = 0;
103 * Set the data object associated with this functor. The data
104 * object provides context for functor-to-standin mapping. This
105 * method is required when assigning a functor to a different data
106 * object. This function MAY GO AWAY later if the architecture is
107 * changed to pass data object pointers through the API.
110 virtual void setData(const TransliterationRuleData*) = 0;
115 * Since this class has pure virtual functions,
116 * a constructor can't be used.
119 /*UnicodeFunctor();*/
123 /*inline UnicodeFunctor::UnicodeFunctor() {}*/