]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
b75a7d8f | 3 | /* |
73c04bcf | 4 | ********************************************************************** |
729e4ab9 | 5 | * Copyright (C) 1999-2010, International Business Machines Corporation and others. |
374ca955 | 6 | * All Rights Reserved. |
b75a7d8f A |
7 | ********************************************************************** |
8 | * Date Name Description | |
9 | * 11/17/99 aliu Creation. | |
10 | ********************************************************************** | |
11 | */ | |
12 | #ifndef UNIFILT_H | |
13 | #define UNIFILT_H | |
14 | ||
15 | #include "unicode/unifunct.h" | |
16 | #include "unicode/unimatch.h" | |
17 | ||
73c04bcf A |
18 | /** |
19 | * \file | |
20 | * \brief C++ API: Unicode Filter | |
21 | */ | |
22 | ||
f3c0d7a5 | 23 | #if U_SHOW_CPLUSPLUS_API |
b75a7d8f A |
24 | U_NAMESPACE_BEGIN |
25 | ||
26 | /** | |
27 | * U_ETHER is used to represent character values for positions outside | |
28 | * a range. For example, transliterator uses this to represent | |
29 | * characters outside the range contextStart..contextLimit-1. This | |
30 | * allows explicit matching by rules and UnicodeSets of text outside a | |
31 | * defined range. | |
73c04bcf | 32 | * @stable ICU 3.0 |
b75a7d8f | 33 | */ |
f3c0d7a5 | 34 | #define U_ETHER ((char16_t)0xFFFF) |
b75a7d8f A |
35 | |
36 | /** | |
73c04bcf | 37 | * |
b75a7d8f A |
38 | * <code>UnicodeFilter</code> defines a protocol for selecting a |
39 | * subset of the full range (U+0000 to U+10FFFF) of Unicode characters. | |
40 | * Currently, filters are used in conjunction with classes like {@link | |
41 | * Transliterator} to only process selected characters through a | |
42 | * transformation. | |
43 | * | |
44 | * <p>Note: UnicodeFilter currently stubs out two pure virtual methods | |
45 | * of its base class, UnicodeMatcher. These methods are toPattern() | |
46 | * and matchesIndexValue(). This is done so that filter classes that | |
47 | * are not actually used as matchers -- specifically, those in the | |
48 | * UnicodeFilterLogic component, and those in tests -- can continue to | |
49 | * work without defining these methods. As long as a filter is not | |
50 | * used in an RBT during real transliteration, these methods will not | |
51 | * be called. However, this breaks the UnicodeMatcher base class | |
52 | * protocol, and it is not a correct solution. | |
53 | * | |
54 | * <p>In the future we may revisit the UnicodeMatcher / UnicodeFilter | |
55 | * hierarchy and either redesign it, or simply remove the stubs in | |
56 | * UnicodeFilter and force subclasses to implement the full | |
57 | * UnicodeMatcher protocol. | |
58 | * | |
59 | * @see UnicodeFilterLogic | |
60 | * @stable ICU 2.0 | |
61 | */ | |
62 | class U_COMMON_API UnicodeFilter : public UnicodeFunctor, public UnicodeMatcher { | |
63 | ||
64 | public: | |
65 | /** | |
66 | * Destructor | |
67 | * @stable ICU 2.0 | |
68 | */ | |
69 | virtual ~UnicodeFilter(); | |
70 | ||
71 | /** | |
72 | * Returns <tt>true</tt> for characters that are in the selected | |
73 | * subset. In other words, if a character is <b>to be | |
74 | * filtered</b>, then <tt>contains()</tt> returns | |
75 | * <b><tt>false</tt></b>. | |
76 | * @stable ICU 2.0 | |
77 | */ | |
78 | virtual UBool contains(UChar32 c) const = 0; | |
79 | ||
80 | /** | |
81 | * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer | |
82 | * and return the pointer. | |
374ca955 | 83 | * @stable ICU 2.4 |
b75a7d8f A |
84 | */ |
85 | virtual UnicodeMatcher* toMatcher() const; | |
86 | ||
87 | /** | |
88 | * Implement UnicodeMatcher API. | |
374ca955 | 89 | * @stable ICU 2.4 |
b75a7d8f A |
90 | */ |
91 | virtual UMatchDegree matches(const Replaceable& text, | |
92 | int32_t& offset, | |
93 | int32_t limit, | |
94 | UBool incremental); | |
95 | ||
96 | /** | |
97 | * UnicodeFunctor API. Nothing to do. | |
374ca955 | 98 | * @stable ICU 2.4 |
b75a7d8f | 99 | */ |
374ca955 | 100 | virtual void setData(const TransliterationRuleData*); |
b75a7d8f | 101 | |
b75a7d8f A |
102 | /** |
103 | * ICU "poor man's RTTI", returns a UClassID for this class. | |
104 | * | |
374ca955 | 105 | * @stable ICU 2.2 |
b75a7d8f | 106 | */ |
374ca955 | 107 | static UClassID U_EXPORT2 getStaticClassID(); |
b75a7d8f A |
108 | |
109 | protected: | |
110 | ||
374ca955 A |
111 | /* |
112 | * Since this class has pure virtual functions, | |
113 | * a constructor can't be used. | |
b75a7d8f A |
114 | * @stable ICU 2.0 |
115 | */ | |
374ca955 | 116 | /* UnicodeFilter();*/ |
b75a7d8f A |
117 | }; |
118 | ||
374ca955 | 119 | /*inline UnicodeFilter::UnicodeFilter() {}*/ |
b75a7d8f A |
120 | |
121 | U_NAMESPACE_END | |
f3c0d7a5 | 122 | #endif // U_SHOW_CPLUSPLUS_API |
b75a7d8f A |
123 | |
124 | #endif |