/*
-* 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.
#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,
}
StringMatcher::StringMatcher(const StringMatcher& o) :
+ UnicodeFunctor(o),
UnicodeMatcher(o),
+ UnicodeReplacer(o),
pattern(o.pattern),
data(o.data),
segmentNumber(o.segmentNumber),
* and return the pointer.
*/
UnicodeMatcher* StringMatcher::toMatcher() const {
- return (UnicodeMatcher*) this;
+ StringMatcher *nonconst_this = const_cast<StringMatcher *>(this);
+ UnicodeMatcher *nonconst_base = static_cast<UnicodeMatcher *>(nonconst_this);
+
+ return nonconst_base;
}
/**
* and return the pointer.
*/
UnicodeReplacer* StringMatcher::toReplacer() const {
- return (UnicodeReplacer*) this;
+ StringMatcher *nonconst_this = const_cast<StringMatcher *>(this);
+ UnicodeReplacer *nonconst_base = static_cast<UnicodeReplacer *>(nonconst_this);
+
+ return nonconst_base;
}
/**
*/
void StringMatcher::addMatchSetTo(UnicodeSet& toUnionTo) const {
UChar32 ch;
- for (int32_t i=0; i<pattern.length(); i+=UTF_CHAR_LENGTH(ch)) {
- ch = pattern.char32At(i);
- const UnicodeMatcher* matcher = data->lookupMatcher(ch);
- if (matcher == NULL) {
- toUnionTo.add(ch);
- } else {
- matcher->addMatchSetTo(toUnionTo);
- }
+ for (int32_t i=0; i<pattern.length(); i+=U16_LENGTH(ch)) {
+ ch = pattern.char32At(i);
+ const UnicodeMatcher* matcher = data->lookupMatcher(ch);
+ if (matcher == NULL) {
+ toUnionTo.add(ch);
+ } else {
+ matcher->addMatchSetTo(toUnionTo);
+ }
}
}
int32_t StringMatcher::replace(Replaceable& text,
int32_t start,
int32_t limit,
- int32_t& cursor) {
+ int32_t& /*cursor*/) {
int32_t outLen = 0;
}
}
- text.handleReplaceBetween(start, limit, EMPTY); // delete original text
+ text.handleReplaceBetween(start, limit, UnicodeString()); // delete original text
return outLen;
}
* UnicodeReplacer API
*/
UnicodeString& StringMatcher::toReplacerPattern(UnicodeString& rule,
- UBool escapeUnprintable) const {
+ UBool /*escapeUnprintable*/) const {
// assert(segmentNumber > 0);
rule.truncate(0);
rule.append((UChar)0x0024 /*$*/);
* 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
if (f != NULL) {
f->setData(data);
}
- i += UTF_CHAR_LENGTH(c);
- }
+ i += U16_LENGTH(c);
+ }
}
U_NAMESPACE_END