jpayne@69: // © 2016 and later: Unicode, Inc. and others. jpayne@69: // License & terms of use: http://www.unicode.org/copyright.html jpayne@69: /* jpayne@69: ********************************************************************** jpayne@69: * Copyright (C) 1999-2010, International Business Machines Corporation and others. jpayne@69: * All Rights Reserved. jpayne@69: ********************************************************************** jpayne@69: * Date Name Description jpayne@69: * 11/17/99 aliu Creation. jpayne@69: ********************************************************************** jpayne@69: */ jpayne@69: #ifndef UNIFILT_H jpayne@69: #define UNIFILT_H jpayne@69: jpayne@69: #include "unicode/utypes.h" jpayne@69: jpayne@69: #if U_SHOW_CPLUSPLUS_API jpayne@69: jpayne@69: #include "unicode/unifunct.h" jpayne@69: #include "unicode/unimatch.h" jpayne@69: jpayne@69: /** jpayne@69: * \file jpayne@69: * \brief C++ API: Unicode Filter jpayne@69: */ jpayne@69: jpayne@69: U_NAMESPACE_BEGIN jpayne@69: jpayne@69: /** jpayne@69: * U_ETHER is used to represent character values for positions outside jpayne@69: * a range. For example, transliterator uses this to represent jpayne@69: * characters outside the range contextStart..contextLimit-1. This jpayne@69: * allows explicit matching by rules and UnicodeSets of text outside a jpayne@69: * defined range. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: #define U_ETHER ((char16_t)0xFFFF) jpayne@69: jpayne@69: /** jpayne@69: * jpayne@69: * UnicodeFilter defines a protocol for selecting a jpayne@69: * subset of the full range (U+0000 to U+10FFFF) of Unicode characters. jpayne@69: * Currently, filters are used in conjunction with classes like {@link jpayne@69: * Transliterator} to only process selected characters through a jpayne@69: * transformation. jpayne@69: * jpayne@69: *

Note: UnicodeFilter currently stubs out two pure virtual methods jpayne@69: * of its base class, UnicodeMatcher. These methods are toPattern() jpayne@69: * and matchesIndexValue(). This is done so that filter classes that jpayne@69: * are not actually used as matchers -- specifically, those in the jpayne@69: * UnicodeFilterLogic component, and those in tests -- can continue to jpayne@69: * work without defining these methods. As long as a filter is not jpayne@69: * used in an RBT during real transliteration, these methods will not jpayne@69: * be called. However, this breaks the UnicodeMatcher base class jpayne@69: * protocol, and it is not a correct solution. jpayne@69: * jpayne@69: *

In the future we may revisit the UnicodeMatcher / UnicodeFilter jpayne@69: * hierarchy and either redesign it, or simply remove the stubs in jpayne@69: * UnicodeFilter and force subclasses to implement the full jpayne@69: * UnicodeMatcher protocol. jpayne@69: * jpayne@69: * @see UnicodeFilterLogic jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: class U_COMMON_API UnicodeFilter : public UnicodeFunctor, public UnicodeMatcher { jpayne@69: jpayne@69: public: jpayne@69: /** jpayne@69: * Destructor jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual ~UnicodeFilter(); jpayne@69: jpayne@69: /** jpayne@69: * Clones this object polymorphically. jpayne@69: * The caller owns the result and should delete it when done. jpayne@69: * @return clone, or nullptr if an error occurred jpayne@69: * @stable ICU 2.4 jpayne@69: */ jpayne@69: virtual UnicodeFilter* clone() const = 0; jpayne@69: jpayne@69: /** jpayne@69: * Returns true for characters that are in the selected jpayne@69: * subset. In other words, if a character is to be jpayne@69: * filtered, then contains() returns jpayne@69: * false. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual UBool contains(UChar32 c) const = 0; jpayne@69: jpayne@69: /** jpayne@69: * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer jpayne@69: * and return the pointer. jpayne@69: * @stable ICU 2.4 jpayne@69: */ jpayne@69: virtual UnicodeMatcher* toMatcher() const; jpayne@69: jpayne@69: /** jpayne@69: * Implement UnicodeMatcher API. jpayne@69: * @stable ICU 2.4 jpayne@69: */ jpayne@69: virtual UMatchDegree matches(const Replaceable& text, jpayne@69: int32_t& offset, jpayne@69: int32_t limit, jpayne@69: UBool incremental); jpayne@69: jpayne@69: /** jpayne@69: * UnicodeFunctor API. Nothing to do. jpayne@69: * @stable ICU 2.4 jpayne@69: */ jpayne@69: virtual void setData(const TransliterationRuleData*); jpayne@69: jpayne@69: /** jpayne@69: * ICU "poor man's RTTI", returns a UClassID for this class. jpayne@69: * jpayne@69: * @stable ICU 2.2 jpayne@69: */ jpayne@69: static UClassID U_EXPORT2 getStaticClassID(); jpayne@69: jpayne@69: protected: jpayne@69: jpayne@69: /* jpayne@69: * Since this class has pure virtual functions, jpayne@69: * a constructor can't be used. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: /* UnicodeFilter();*/ jpayne@69: }; jpayne@69: jpayne@69: /*inline UnicodeFilter::UnicodeFilter() {}*/ jpayne@69: jpayne@69: U_NAMESPACE_END jpayne@69: jpayne@69: #endif /* U_SHOW_CPLUSPLUS_API */ jpayne@69: jpayne@69: #endif