1 // © 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
23 #if U_SHOW_CPLUSPLUS_API
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
34 #define U_ETHER ((char16_t)0xFFFF)
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
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.
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.
59 * @see UnicodeFilterLogic
62 class U_COMMON_API UnicodeFilter
: public UnicodeFunctor
, public UnicodeMatcher
{
69 virtual ~UnicodeFilter();
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>.
78 virtual UBool
contains(UChar32 c
) const = 0;
81 * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer
82 * and return the pointer.
85 virtual UnicodeMatcher
* toMatcher() const;
88 * Implement UnicodeMatcher API.
91 virtual UMatchDegree
matches(const Replaceable
& text
,
97 * UnicodeFunctor API. Nothing to do.
100 virtual void setData(const TransliterationRuleData
*);
103 * ICU "poor man's RTTI", returns a UClassID for this class.
107 static UClassID U_EXPORT2
getStaticClassID();
112 * Since this class has pure virtual functions,
113 * a constructor can't be used.
116 /* UnicodeFilter();*/
119 /*inline UnicodeFilter::UnicodeFilter() {}*/
122 #endif // U_SHOW_CPLUSPLUS_API