]> git.saurik.com Git - apple/icu.git/blob - icuSources/common/unicode/unifilt.h
ICU-59117.0.1.tar.gz
[apple/icu.git] / icuSources / common / unicode / unifilt.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) 1999-2010, International Business Machines Corporation and others.
6 * All Rights Reserved.
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
18 /**
19 * \file
20 * \brief C++ API: Unicode Filter
21 */
22
23 #if U_SHOW_CPLUSPLUS_API
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.
32 * @stable ICU 3.0
33 */
34 #define U_ETHER ((char16_t)0xFFFF)
35
36 /**
37 *
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.
83 * @stable ICU 2.4
84 */
85 virtual UnicodeMatcher* toMatcher() const;
86
87 /**
88 * Implement UnicodeMatcher API.
89 * @stable ICU 2.4
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.
98 * @stable ICU 2.4
99 */
100 virtual void setData(const TransliterationRuleData*);
101
102 /**
103 * ICU "poor man's RTTI", returns a UClassID for this class.
104 *
105 * @stable ICU 2.2
106 */
107 static UClassID U_EXPORT2 getStaticClassID();
108
109 protected:
110
111 /*
112 * Since this class has pure virtual functions,
113 * a constructor can't be used.
114 * @stable ICU 2.0
115 */
116 /* UnicodeFilter();*/
117 };
118
119 /*inline UnicodeFilter::UnicodeFilter() {}*/
120
121 U_NAMESPACE_END
122 #endif // U_SHOW_CPLUSPLUS_API
123
124 #endif