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
**********************************************************************
11
#include "unicode/unifunct.h"
12
#include "unicode/unimatch.h"
17
* <code>UnicodeFilter</code> defines a protocol for selecting a
18
* subset of the full range (U+0000 to U+10FFFF) of Unicode characters.
19
* Currently, filters are used in conjunction with classes like {@link
20
* Transliterator} to only process selected characters through a
23
* <p>Note: UnicodeFilter currently stubs out two pure virtual methods
24
* of its base class, UnicodeMatcher. These methods are toPattern()
25
* and matchesIndexValue(). This is done so that filter classes that
26
* are not actually used as matchers -- specifically, those in the
27
* UnicodeFilterLogic component, and those in tests -- can continue to
28
* work without defining these methods. As long as a filter is not
29
* used in an RBT during real transliteration, these methods will not
30
* be called. However, this breaks the UnicodeMatcher base class
31
* protocol, and it is not a correct solution.
33
* <p>In the future we may revisit the UnicodeMatcher / UnicodeFilter
34
* hierarchy and either redesign it, or simply remove the stubs in
35
* UnicodeFilter and force subclasses to implement the full
36
* UnicodeMatcher protocol.
38
* @see UnicodeFilterLogic
41
class U_I18N_API UnicodeFilter : public UnicodeFunctor, public UnicodeMatcher {
48
virtual ~UnicodeFilter();
51
* Returns <tt>true</tt> for characters that are in the selected
52
* subset. In other words, if a character is <b>to be
53
* filtered</b>, then <tt>contains()</tt> returns
54
* <b><tt>false</tt></b>.
57
virtual UBool contains(UChar32 c) const = 0;
60
* UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer
61
* and return the pointer.
63
virtual UnicodeMatcher* toMatcher() const;
66
* UnicodeMatcher API. This class stubs this out.
68
UnicodeString& toPattern(UnicodeString& result,
69
UBool escapeUnprintable) const;
72
* UnicodeMatcher API. This class stubs this out.
74
UBool matchesIndexValue(uint8_t v) const;
77
* Implement UnicodeMatcher API.
79
virtual UMatchDegree matches(const Replaceable& text,
85
* UnicodeFunctor API. Nothing to do.
87
virtual void setData(const TransliterationRuleData*) {}
94
inline UnicodeFilter::UnicodeFilter() {}
95
inline UnicodeFilter::~UnicodeFilter() {}