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
17#if U_SHOW_CPLUSPLUS_API
18
19#include "unicode/uobject.h"
20
21/**
22 * \file
23 * \brief C++ API: Unicode Functor
24 */
25
26U_NAMESPACE_BEGIN
27
28class UnicodeMatcher;
29class UnicodeReplacer;
30class TransliterationRuleData;
31
32/**
33 * <code>UnicodeFunctor</code> is an abstract base class for objects
34 * that perform match and/or replace operations on Unicode strings.
35 * @author Alan Liu
36 * @stable ICU 2.4
37 */
38class U_COMMON_API UnicodeFunctor : public UObject {
39
40public:
41
42 /**
43 * Destructor
44 * @stable ICU 2.4
45 */
46 virtual ~UnicodeFunctor();
47
48 /**
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.
52 * @stable ICU 2.4
53 */
54 virtual UnicodeFunctor* clone() const = 0;
55
56 /**
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
63 * UnicodeFunctor.
64 * @stable ICU 2.4
65 */
66 virtual UnicodeMatcher* toMatcher() const;
67
68 /**
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
75 * UnicodeFunctor.
76 * @stable ICU 2.4
77 */
78 virtual UnicodeReplacer* toReplacer() const;
79
80 /**
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.
84 * @stable ICU 2.0
85 */
86 static UClassID U_EXPORT2 getStaticClassID(void);
87
88 /**
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.
93 *
94 * <p>Concrete subclasses of UnicodeFunctor should use the macro
95 * UOBJECT_DEFINE_RTTI_IMPLEMENTATION from uobject.h to
96 * provide definitions getStaticClassID and getDynamicClassID.
97 *
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.
101 * @stable ICU 2.4
102 */
103 virtual UClassID getDynamicClassID(void) const override = 0;
104
105 /**
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.
111 * @internal ICU 2.1
112 */
113 virtual void setData(const TransliterationRuleData*) = 0;
114
115protected:
116
117 /**
118 * Since this class has pure virtual functions,
119 * a constructor can't be used.
120 * @stable ICU 2.0
121 */
122 /*UnicodeFunctor();*/
123
124};
125
126/*inline UnicodeFunctor::UnicodeFunctor() {}*/
127
128U_NAMESPACE_END
129
130#endif /* U_SHOW_CPLUSPLUS_API */
131
132#endif
133

source code of include/unicode/unifunct.h