]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/unifilt.cpp
   2 ********************************************************************** 
   3 * Copyright (c) 2001-2004, International Business Machines 
   4 * Corporation and others.  All Rights Reserved. 
   5 ********************************************************************** 
   6 *   Date        Name        Description 
   7 *   07/18/01    aliu        Creation. 
   8 ********************************************************************** 
  11 #include "unicode/unifilt.h" 
  12 #include "unicode/rep.h" 
  15 UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(UnicodeFilter
) 
  18 /* Define this here due to the lack of another file. 
  19    It can't be defined in the header */ 
  20 UnicodeMatcher::~UnicodeMatcher() {} 
  22 UnicodeFilter::~UnicodeFilter() {} 
  25  * UnicodeFunctor API.  Cast 'this' to a UnicodeMatcher* pointer 
  26  * and return the pointer. 
  28 UnicodeMatcher
* UnicodeFilter::toMatcher() const { 
  29     return (UnicodeMatcher
*) this; 
  32 void UnicodeFilter::setData(const TransliterationRuleData
*) {} 
  35  * Default implementation of UnicodeMatcher::matches() for Unicode 
  36  * filters.  Matches a single code point at offset (either one or 
  37  * two 16-bit code units). 
  39 UMatchDegree 
UnicodeFilter::matches(const Replaceable
& text
, 
  45         contains(c 
= text
.char32At(offset
))) { 
  46         offset 
+= UTF_CHAR_LENGTH(c
); 
  50         contains(c 
= text
.char32At(offset
))) { 
  51         // Backup offset by 1, unless the preceding character is a 
  52         // surrogate pair -- then backup by 2 (keep offset pointing at 
  53         // the lead surrogate). 
  56             offset 
-= UTF_CHAR_LENGTH(text
.char32At(offset
)) - 1; 
  60     if (incremental 
&& offset 
== limit
) { 
  61         return U_PARTIAL_MATCH
;