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