1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/common/unicode/unifilt.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,120 @@ 1.4 +/* 1.5 +********************************************************************** 1.6 +* Copyright (C) 1999-2010, International Business Machines Corporation and others. 1.7 +* All Rights Reserved. 1.8 +********************************************************************** 1.9 +* Date Name Description 1.10 +* 11/17/99 aliu Creation. 1.11 +********************************************************************** 1.12 +*/ 1.13 +#ifndef UNIFILT_H 1.14 +#define UNIFILT_H 1.15 + 1.16 +#include "unicode/unifunct.h" 1.17 +#include "unicode/unimatch.h" 1.18 + 1.19 +/** 1.20 + * \file 1.21 + * \brief C++ API: Unicode Filter 1.22 + */ 1.23 + 1.24 +U_NAMESPACE_BEGIN 1.25 + 1.26 +/** 1.27 + * U_ETHER is used to represent character values for positions outside 1.28 + * a range. For example, transliterator uses this to represent 1.29 + * characters outside the range contextStart..contextLimit-1. This 1.30 + * allows explicit matching by rules and UnicodeSets of text outside a 1.31 + * defined range. 1.32 + * @stable ICU 3.0 1.33 + */ 1.34 +#define U_ETHER ((UChar)0xFFFF) 1.35 + 1.36 +/** 1.37 + * 1.38 + * <code>UnicodeFilter</code> defines a protocol for selecting a 1.39 + * subset of the full range (U+0000 to U+10FFFF) of Unicode characters. 1.40 + * Currently, filters are used in conjunction with classes like {@link 1.41 + * Transliterator} to only process selected characters through a 1.42 + * transformation. 1.43 + * 1.44 + * <p>Note: UnicodeFilter currently stubs out two pure virtual methods 1.45 + * of its base class, UnicodeMatcher. These methods are toPattern() 1.46 + * and matchesIndexValue(). This is done so that filter classes that 1.47 + * are not actually used as matchers -- specifically, those in the 1.48 + * UnicodeFilterLogic component, and those in tests -- can continue to 1.49 + * work without defining these methods. As long as a filter is not 1.50 + * used in an RBT during real transliteration, these methods will not 1.51 + * be called. However, this breaks the UnicodeMatcher base class 1.52 + * protocol, and it is not a correct solution. 1.53 + * 1.54 + * <p>In the future we may revisit the UnicodeMatcher / UnicodeFilter 1.55 + * hierarchy and either redesign it, or simply remove the stubs in 1.56 + * UnicodeFilter and force subclasses to implement the full 1.57 + * UnicodeMatcher protocol. 1.58 + * 1.59 + * @see UnicodeFilterLogic 1.60 + * @stable ICU 2.0 1.61 + */ 1.62 +class U_COMMON_API UnicodeFilter : public UnicodeFunctor, public UnicodeMatcher { 1.63 + 1.64 +public: 1.65 + /** 1.66 + * Destructor 1.67 + * @stable ICU 2.0 1.68 + */ 1.69 + virtual ~UnicodeFilter(); 1.70 + 1.71 + /** 1.72 + * Returns <tt>true</tt> for characters that are in the selected 1.73 + * subset. In other words, if a character is <b>to be 1.74 + * filtered</b>, then <tt>contains()</tt> returns 1.75 + * <b><tt>false</tt></b>. 1.76 + * @stable ICU 2.0 1.77 + */ 1.78 + virtual UBool contains(UChar32 c) const = 0; 1.79 + 1.80 + /** 1.81 + * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer 1.82 + * and return the pointer. 1.83 + * @stable ICU 2.4 1.84 + */ 1.85 + virtual UnicodeMatcher* toMatcher() const; 1.86 + 1.87 + /** 1.88 + * Implement UnicodeMatcher API. 1.89 + * @stable ICU 2.4 1.90 + */ 1.91 + virtual UMatchDegree matches(const Replaceable& text, 1.92 + int32_t& offset, 1.93 + int32_t limit, 1.94 + UBool incremental); 1.95 + 1.96 + /** 1.97 + * UnicodeFunctor API. Nothing to do. 1.98 + * @stable ICU 2.4 1.99 + */ 1.100 + virtual void setData(const TransliterationRuleData*); 1.101 + 1.102 + /** 1.103 + * ICU "poor man's RTTI", returns a UClassID for this class. 1.104 + * 1.105 + * @stable ICU 2.2 1.106 + */ 1.107 + static UClassID U_EXPORT2 getStaticClassID(); 1.108 + 1.109 +protected: 1.110 + 1.111 + /* 1.112 + * Since this class has pure virtual functions, 1.113 + * a constructor can't be used. 1.114 + * @stable ICU 2.0 1.115 + */ 1.116 +/* UnicodeFilter();*/ 1.117 +}; 1.118 + 1.119 +/*inline UnicodeFilter::UnicodeFilter() {}*/ 1.120 + 1.121 +U_NAMESPACE_END 1.122 + 1.123 +#endif