1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 **********************************************************************
5 * Copyright (C) 1999-2010, International Business Machines Corporation and others.
7 **********************************************************************
8 * Date Name Description
9 * 11/17/99 aliu Creation.
10 **********************************************************************
15 #include "unicode/unifunct.h"
16 #include "unicode/unimatch.h"
20 * \brief C++ API: Unicode Filter
26 * U_ETHER is used to represent character values for positions outside
27 * a range. For example, transliterator uses this to represent
28 * characters outside the range contextStart..contextLimit-1. This
29 * allows explicit matching by rules and UnicodeSets of text outside a
33 #define U_ETHER ((UChar)0xFFFF)
37 * <code>UnicodeFilter</code> defines a protocol for selecting a
38 * subset of the full range (U+0000 to U+10FFFF) of Unicode characters.
39 * Currently, filters are used in conjunction with classes like {@link
40 * Transliterator} to only process selected characters through a
43 * <p>Note: UnicodeFilter currently stubs out two pure virtual methods
44 * of its base class, UnicodeMatcher. These methods are toPattern()
45 * and matchesIndexValue(). This is done so that filter classes that
46 * are not actually used as matchers -- specifically, those in the
47 * UnicodeFilterLogic component, and those in tests -- can continue to
48 * work without defining these methods. As long as a filter is not
49 * used in an RBT during real transliteration, these methods will not
50 * be called. However, this breaks the UnicodeMatcher base class
51 * protocol, and it is not a correct solution.
53 * <p>In the future we may revisit the UnicodeMatcher / UnicodeFilter
54 * hierarchy and either redesign it, or simply remove the stubs in
55 * UnicodeFilter and force subclasses to implement the full
56 * UnicodeMatcher protocol.
58 * @see UnicodeFilterLogic
61 class U_COMMON_API UnicodeFilter : public UnicodeFunctor, public UnicodeMatcher {
68 virtual ~UnicodeFilter();
71 * Returns <tt>true</tt> for characters that are in the selected
72 * subset. In other words, if a character is <b>to be
73 * filtered</b>, then <tt>contains()</tt> returns
74 * <b><tt>false</tt></b>.
77 virtual UBool contains(UChar32 c) const = 0;
80 * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer
81 * and return the pointer.
84 virtual UnicodeMatcher* toMatcher() const;
87 * Implement UnicodeMatcher API.
90 virtual UMatchDegree matches(const Replaceable& text,
96 * UnicodeFunctor API. Nothing to do.
99 virtual void setData(const TransliterationRuleData*);
102 * ICU "poor man's RTTI", returns a UClassID for this class.
106 static UClassID U_EXPORT2 getStaticClassID();
111 * Since this class has pure virtual functions,
112 * a constructor can't be used.
115 /* UnicodeFilter();*/
118 /*inline UnicodeFilter::UnicodeFilter() {}*/