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