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

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

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