X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..4f1e1a09ce4daed860e35d359ce2fceccb0764e8:/icuSources/common/unifilt.cpp diff --git a/icuSources/common/unifilt.cpp b/icuSources/common/unifilt.cpp index 88727e2c..4ab0d9b5 100644 --- a/icuSources/common/unifilt.cpp +++ b/icuSources/common/unifilt.cpp @@ -1,5 +1,9 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* -* Copyright (C) 2001, International Business Machines Corporation and others. All Rights Reserved. +********************************************************************** +* Copyright (c) 2001-2012, International Business Machines +* Corporation and others. All Rights Reserved. ********************************************************************** * Date Name Description * 07/18/01 aliu Creation. @@ -8,19 +12,28 @@ #include "unicode/unifilt.h" #include "unicode/rep.h" +#include "unicode/utf16.h" U_NAMESPACE_BEGIN +UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(UnicodeFilter) + -const char UnicodeFilter::fgClassID=0; +/* Define this here due to the lack of another file. + It can't be defined in the header */ +UnicodeMatcher::~UnicodeMatcher() {} + +UnicodeFilter::~UnicodeFilter() {} /** - * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer - * and return the pointer. + * UnicodeFunctor API. + * Note that UnicodeMatcher is a base class of UnicodeFilter. */ UnicodeMatcher* UnicodeFilter::toMatcher() const { - return (UnicodeMatcher*) this; + return const_cast(this); } +void UnicodeFilter::setData(const TransliterationRuleData*) {} + /** * Default implementation of UnicodeMatcher::matches() for Unicode * filters. Matches a single code point at offset (either one or @@ -33,7 +46,7 @@ UMatchDegree UnicodeFilter::matches(const Replaceable& text, UChar32 c; if (offset < limit && contains(c = text.char32At(offset))) { - offset += UTF_CHAR_LENGTH(c); + offset += U16_LENGTH(c); return U_MATCH; } if (offset > limit && @@ -43,7 +56,7 @@ UMatchDegree UnicodeFilter::matches(const Replaceable& text, // the lead surrogate). --offset; if (offset >= 0) { - offset -= UTF_CHAR_LENGTH(text.char32At(offset)) - 1; + offset -= U16_LENGTH(text.char32At(offset)) - 1; } return U_MATCH; }