jpayne@69
|
1 // © 2016 and later: Unicode, Inc. and others.
|
jpayne@69
|
2 // License & terms of use: http://www.unicode.org/copyright.html
|
jpayne@69
|
3 /*
|
jpayne@69
|
4 **********************************************************************
|
jpayne@69
|
5 * Copyright (c) 2002-2005, International Business Machines Corporation
|
jpayne@69
|
6 * and others. All Rights Reserved.
|
jpayne@69
|
7 **********************************************************************
|
jpayne@69
|
8 * Date Name Description
|
jpayne@69
|
9 * 01/14/2002 aliu Creation.
|
jpayne@69
|
10 **********************************************************************
|
jpayne@69
|
11 */
|
jpayne@69
|
12 #ifndef UNIFUNCT_H
|
jpayne@69
|
13 #define UNIFUNCT_H
|
jpayne@69
|
14
|
jpayne@69
|
15 #include "unicode/utypes.h"
|
jpayne@69
|
16
|
jpayne@69
|
17 #if U_SHOW_CPLUSPLUS_API
|
jpayne@69
|
18
|
jpayne@69
|
19 #include "unicode/uobject.h"
|
jpayne@69
|
20
|
jpayne@69
|
21 /**
|
jpayne@69
|
22 * \file
|
jpayne@69
|
23 * \brief C++ API: Unicode Functor
|
jpayne@69
|
24 */
|
jpayne@69
|
25
|
jpayne@69
|
26 U_NAMESPACE_BEGIN
|
jpayne@69
|
27
|
jpayne@69
|
28 class UnicodeMatcher;
|
jpayne@69
|
29 class UnicodeReplacer;
|
jpayne@69
|
30 class TransliterationRuleData;
|
jpayne@69
|
31
|
jpayne@69
|
32 /**
|
jpayne@69
|
33 * <code>UnicodeFunctor</code> is an abstract base class for objects
|
jpayne@69
|
34 * that perform match and/or replace operations on Unicode strings.
|
jpayne@69
|
35 * @author Alan Liu
|
jpayne@69
|
36 * @stable ICU 2.4
|
jpayne@69
|
37 */
|
jpayne@69
|
38 class U_COMMON_API UnicodeFunctor : public UObject {
|
jpayne@69
|
39
|
jpayne@69
|
40 public:
|
jpayne@69
|
41
|
jpayne@69
|
42 /**
|
jpayne@69
|
43 * Destructor
|
jpayne@69
|
44 * @stable ICU 2.4
|
jpayne@69
|
45 */
|
jpayne@69
|
46 virtual ~UnicodeFunctor();
|
jpayne@69
|
47
|
jpayne@69
|
48 /**
|
jpayne@69
|
49 * Return a copy of this object. All UnicodeFunctor objects
|
jpayne@69
|
50 * have to support cloning in order to allow classes using
|
jpayne@69
|
51 * UnicodeFunctor to implement cloning.
|
jpayne@69
|
52 * @stable ICU 2.4
|
jpayne@69
|
53 */
|
jpayne@69
|
54 virtual UnicodeFunctor* clone() const = 0;
|
jpayne@69
|
55
|
jpayne@69
|
56 /**
|
jpayne@69
|
57 * Cast 'this' to a UnicodeMatcher* pointer and return the
|
jpayne@69
|
58 * pointer, or null if this is not a UnicodeMatcher*. Subclasses
|
jpayne@69
|
59 * that mix in UnicodeMatcher as a base class must override this.
|
jpayne@69
|
60 * This protocol is required because a pointer to a UnicodeFunctor
|
jpayne@69
|
61 * cannot be cast to a pointer to a UnicodeMatcher, since
|
jpayne@69
|
62 * UnicodeMatcher is a mixin that does not derive from
|
jpayne@69
|
63 * UnicodeFunctor.
|
jpayne@69
|
64 * @stable ICU 2.4
|
jpayne@69
|
65 */
|
jpayne@69
|
66 virtual UnicodeMatcher* toMatcher() const;
|
jpayne@69
|
67
|
jpayne@69
|
68 /**
|
jpayne@69
|
69 * Cast 'this' to a UnicodeReplacer* pointer and return the
|
jpayne@69
|
70 * pointer, or null if this is not a UnicodeReplacer*. Subclasses
|
jpayne@69
|
71 * that mix in UnicodeReplacer as a base class must override this.
|
jpayne@69
|
72 * This protocol is required because a pointer to a UnicodeFunctor
|
jpayne@69
|
73 * cannot be cast to a pointer to a UnicodeReplacer, since
|
jpayne@69
|
74 * UnicodeReplacer is a mixin that does not derive from
|
jpayne@69
|
75 * UnicodeFunctor.
|
jpayne@69
|
76 * @stable ICU 2.4
|
jpayne@69
|
77 */
|
jpayne@69
|
78 virtual UnicodeReplacer* toReplacer() const;
|
jpayne@69
|
79
|
jpayne@69
|
80 /**
|
jpayne@69
|
81 * Return the class ID for this class. This is useful only for
|
jpayne@69
|
82 * comparing to a return value from getDynamicClassID().
|
jpayne@69
|
83 * @return The class ID for all objects of this class.
|
jpayne@69
|
84 * @stable ICU 2.0
|
jpayne@69
|
85 */
|
jpayne@69
|
86 static UClassID U_EXPORT2 getStaticClassID(void);
|
jpayne@69
|
87
|
jpayne@69
|
88 /**
|
jpayne@69
|
89 * Returns a unique class ID <b>polymorphically</b>. This method
|
jpayne@69
|
90 * is to implement a simple version of RTTI, since not all C++
|
jpayne@69
|
91 * compilers support genuine RTTI. Polymorphic operator==() and
|
jpayne@69
|
92 * clone() methods call this method.
|
jpayne@69
|
93 *
|
jpayne@69
|
94 * <p>Concrete subclasses of UnicodeFunctor should use the macro
|
jpayne@69
|
95 * UOBJECT_DEFINE_RTTI_IMPLEMENTATION from uobject.h to
|
jpayne@69
|
96 * provide definitios getStaticClassID and getDynamicClassID.
|
jpayne@69
|
97 *
|
jpayne@69
|
98 * @return The class ID for this object. All objects of a given
|
jpayne@69
|
99 * class have the same class ID. Objects of other classes have
|
jpayne@69
|
100 * different class IDs.
|
jpayne@69
|
101 * @stable ICU 2.4
|
jpayne@69
|
102 */
|
jpayne@69
|
103 virtual UClassID getDynamicClassID(void) const = 0;
|
jpayne@69
|
104
|
jpayne@69
|
105 /**
|
jpayne@69
|
106 * Set the data object associated with this functor. The data
|
jpayne@69
|
107 * object provides context for functor-to-standin mapping. This
|
jpayne@69
|
108 * method is required when assigning a functor to a different data
|
jpayne@69
|
109 * object. This function MAY GO AWAY later if the architecture is
|
jpayne@69
|
110 * changed to pass data object pointers through the API.
|
jpayne@69
|
111 * @internal ICU 2.1
|
jpayne@69
|
112 */
|
jpayne@69
|
113 virtual void setData(const TransliterationRuleData*) = 0;
|
jpayne@69
|
114
|
jpayne@69
|
115 protected:
|
jpayne@69
|
116
|
jpayne@69
|
117 /**
|
jpayne@69
|
118 * Since this class has pure virtual functions,
|
jpayne@69
|
119 * a constructor can't be used.
|
jpayne@69
|
120 * @stable ICU 2.0
|
jpayne@69
|
121 */
|
jpayne@69
|
122 /*UnicodeFunctor();*/
|
jpayne@69
|
123
|
jpayne@69
|
124 };
|
jpayne@69
|
125
|
jpayne@69
|
126 /*inline UnicodeFunctor::UnicodeFunctor() {}*/
|
jpayne@69
|
127
|
jpayne@69
|
128 U_NAMESPACE_END
|
jpayne@69
|
129
|
jpayne@69
|
130 #endif /* U_SHOW_CPLUSPLUS_API */
|
jpayne@69
|
131
|
jpayne@69
|
132 #endif
|