X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..51004dcb01e06fef634b61be77ed73dd61cb6db9:/icuSources/i18n/strmatch.cpp diff --git a/icuSources/i18n/strmatch.cpp b/icuSources/i18n/strmatch.cpp index bfd2e672..7a455759 100644 --- a/icuSources/i18n/strmatch.cpp +++ b/icuSources/i18n/strmatch.cpp @@ -1,5 +1,7 @@ /* -* 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/23/01 aliu Creation. @@ -14,12 +16,11 @@ #include "rbt_data.h" #include "util.h" #include "unicode/uniset.h" +#include "unicode/utf16.h" U_NAMESPACE_BEGIN -const UChar EMPTY[] = { 0 }; // empty string: "" - -const char StringMatcher::fgClassID=0; +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringMatcher) StringMatcher::StringMatcher(const UnicodeString& theString, int32_t start, @@ -35,7 +36,9 @@ StringMatcher::StringMatcher(const UnicodeString& theString, } StringMatcher::StringMatcher(const StringMatcher& o) : + UnicodeFunctor(o), UnicodeMatcher(o), + UnicodeReplacer(o), pattern(o.pattern), data(o.data), segmentNumber(o.segmentNumber), @@ -62,7 +65,10 @@ UnicodeFunctor* StringMatcher::clone() const { * and return the pointer. */ UnicodeMatcher* StringMatcher::toMatcher() const { - return (UnicodeMatcher*) this; + StringMatcher *nonconst_this = const_cast(this); + UnicodeMatcher *nonconst_base = static_cast(nonconst_this); + + return nonconst_base; } /** @@ -70,7 +76,10 @@ UnicodeMatcher* StringMatcher::toMatcher() const { * and return the pointer. */ UnicodeReplacer* StringMatcher::toReplacer() const { - return (UnicodeReplacer*) this; + StringMatcher *nonconst_this = const_cast(this); + UnicodeReplacer *nonconst_base = static_cast(nonconst_this); + + return nonconst_base; } /** @@ -192,14 +201,14 @@ UBool StringMatcher::matchesIndexValue(uint8_t v) const { */ void StringMatcher::addMatchSetTo(UnicodeSet& toUnionTo) const { UChar32 ch; - for (int32_t i=0; ilookupMatcher(ch); - if (matcher == NULL) { - toUnionTo.add(ch); - } else { - matcher->addMatchSetTo(toUnionTo); - } + for (int32_t i=0; ilookupMatcher(ch); + if (matcher == NULL) { + toUnionTo.add(ch); + } else { + matcher->addMatchSetTo(toUnionTo); + } } } @@ -209,7 +218,7 @@ void StringMatcher::addMatchSetTo(UnicodeSet& toUnionTo) const { int32_t StringMatcher::replace(Replaceable& text, int32_t start, int32_t limit, - int32_t& cursor) { + int32_t& /*cursor*/) { int32_t outLen = 0; @@ -224,7 +233,7 @@ int32_t StringMatcher::replace(Replaceable& text, } } - text.handleReplaceBetween(start, limit, EMPTY); // delete original text + text.handleReplaceBetween(start, limit, UnicodeString()); // delete original text return outLen; } @@ -233,7 +242,7 @@ int32_t StringMatcher::replace(Replaceable& text, * UnicodeReplacer API */ UnicodeString& StringMatcher::toReplacerPattern(UnicodeString& rule, - UBool escapeUnprintable) const { + UBool /*escapeUnprintable*/) const { // assert(segmentNumber > 0); rule.truncate(0); rule.append((UChar)0x0024 /*$*/); @@ -254,7 +263,7 @@ UnicodeString& StringMatcher::toReplacerPattern(UnicodeString& rule, * into the given set. * @param toUnionTo the set into which to union the output characters */ -void StringMatcher::addReplacementSetTo(UnicodeSet& toUnionTo) const { +void StringMatcher::addReplacementSetTo(UnicodeSet& /*toUnionTo*/) const { // The output of this replacer varies; it is the source text between // matchStart and matchLimit. Since this varies depending on the // input text, we can't compute it here. We can either do nothing @@ -274,8 +283,8 @@ void StringMatcher::setData(const TransliterationRuleData* d) { if (f != NULL) { f->setData(data); } - i += UTF_CHAR_LENGTH(c); - } + i += U16_LENGTH(c); + } } U_NAMESPACE_END