]> git.saurik.com Git - apple/icu.git/blob - icuSources/common/unicode/unifunct.h
ICU-62141.0.1.tar.gz
[apple/icu.git] / icuSources / common / unicode / unifunct.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
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 **********************************************************************
11 */
12 #ifndef UNIFUNCT_H
13 #define UNIFUNCT_H
14
15 #include "unicode/utypes.h"
16 #include "unicode/uobject.h"
17
18 /**
19 * \file
20 * \brief C++ API: Unicode Functor
21 */
22
23 #if U_SHOW_CPLUSPLUS_API
24 U_NAMESPACE_BEGIN
25
26 class UnicodeMatcher;
27 class UnicodeReplacer;
28 class TransliterationRuleData;
29
30 /**
31 * <code>UnicodeFunctor</code> is an abstract base class for objects
32 * that perform match and/or replace operations on Unicode strings.
33 * @author Alan Liu
34 * @stable ICU 2.4
35 */
36 class U_COMMON_API UnicodeFunctor : public UObject {
37
38 public:
39
40 /**
41 * Destructor
42 * @stable ICU 2.4
43 */
44 virtual ~UnicodeFunctor();
45
46 /**
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.
50 * @stable ICU 2.4
51 */
52 virtual UnicodeFunctor* clone() const = 0;
53
54 /**
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
61 * UnicodeFunctor.
62 * @stable ICU 2.4
63 */
64 virtual UnicodeMatcher* toMatcher() const;
65
66 /**
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
73 * UnicodeFunctor.
74 * @stable ICU 2.4
75 */
76 virtual UnicodeReplacer* toReplacer() const;
77
78 /**
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.
82 * @stable ICU 2.0
83 */
84 static UClassID U_EXPORT2 getStaticClassID(void);
85
86 /**
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.
91 *
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.
95 *
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.
99 * @stable ICU 2.4
100 */
101 virtual UClassID getDynamicClassID(void) const = 0;
102
103 /**
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.
109 * @internal ICU 2.1
110 */
111 virtual void setData(const TransliterationRuleData*) = 0;
112
113 protected:
114
115 /**
116 * Since this class has pure virtual functions,
117 * a constructor can't be used.
118 * @stable ICU 2.0
119 */
120 /*UnicodeFunctor();*/
121
122 };
123
124 /*inline UnicodeFunctor::UnicodeFunctor() {}*/
125
126 U_NAMESPACE_END
127 #endif // U_SHOW_CPLUSPLUS_API
128
129 #endif