ICU-1406 make UnicodeMatcher::matches non-const
X-SVN-Rev: 6503
This commit is contained in:
parent
8513e76562
commit
02f44eee5c
@ -42,7 +42,7 @@ UnicodeMatcher* Quantifier::clone() const {
|
||||
UMatchDegree Quantifier::matches(const Replaceable& text,
|
||||
int32_t& offset,
|
||||
int32_t limit,
|
||||
UBool incremental) const {
|
||||
UBool incremental) {
|
||||
int32_t start = offset;
|
||||
uint32_t count = 0;
|
||||
while (count < maxCount) {
|
||||
|
@ -36,7 +36,7 @@ class Quantifier : public UnicodeMatcher {
|
||||
virtual UMatchDegree matches(const Replaceable& text,
|
||||
int32_t& offset,
|
||||
int32_t limit,
|
||||
UBool incremental) const;
|
||||
UBool incremental);
|
||||
|
||||
/**
|
||||
* Implement UnicodeMatcher
|
||||
|
@ -69,7 +69,7 @@ TransliterationRuleData::~TransliterationRuleData() {
|
||||
}
|
||||
}
|
||||
|
||||
const UnicodeMatcher*
|
||||
UnicodeMatcher*
|
||||
TransliterationRuleData::lookup(UChar32 standIn) const {
|
||||
int32_t i = standIn - variablesBase;
|
||||
return (i >= 0 && i < variablesLength) ? variables[i] : 0;
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
* Given a stand-in character, return the UnicodeMatcher that it
|
||||
* represents, or NULL.
|
||||
*/
|
||||
const UnicodeMatcher* lookup(UChar32 standIn) const;
|
||||
UnicodeMatcher* lookup(UChar32 standIn) const;
|
||||
|
||||
/**
|
||||
* Return the zero-based index of the segment represented by the given
|
||||
|
@ -336,7 +336,7 @@ UMatchDegree TransliterationRule::matchAndReplace(Replaceable& text,
|
||||
|
||||
for (oPattern=anteContextLength-1; oPattern>=0; --oPattern) {
|
||||
UChar keyChar = pattern.charAt(oPattern);
|
||||
const UnicodeMatcher* matcher = data->lookup(keyChar);
|
||||
UnicodeMatcher* matcher = data->lookup(keyChar);
|
||||
if (matcher == 0) {
|
||||
if (oText >= pos.contextStart &&
|
||||
keyChar == text.charAt(oText)) {
|
||||
@ -394,7 +394,7 @@ UMatchDegree TransliterationRule::matchAndReplace(Replaceable& text,
|
||||
int32_t matchLimit = (oPattern < keyLength) ? pos.limit : pos.contextLimit;
|
||||
|
||||
UChar keyChar = pattern.charAt(anteContextLength + oPattern++);
|
||||
const UnicodeMatcher* matcher = data->lookup(keyChar);
|
||||
UnicodeMatcher* matcher = data->lookup(keyChar);
|
||||
if (matcher == 0) {
|
||||
// Don't need the oText < pos.contextLimit check if
|
||||
// incremental is TRUE (because it's done above); do need
|
||||
|
@ -54,14 +54,14 @@ UnicodeMatcher* StringMatcher::clone() const {
|
||||
UMatchDegree StringMatcher::matches(const Replaceable& text,
|
||||
int32_t& offset,
|
||||
int32_t limit,
|
||||
UBool incremental) const {
|
||||
UBool incremental) {
|
||||
int32_t i;
|
||||
int32_t cursor = offset;
|
||||
if (limit < cursor) {
|
||||
// Match in the reverse direction
|
||||
for (i=pattern.length()-1; i>=0; --i) {
|
||||
UChar keyChar = pattern.charAt(i);
|
||||
const UnicodeMatcher* subm = data.lookup(keyChar);
|
||||
UnicodeMatcher* subm = data.lookup(keyChar);
|
||||
if (subm == 0) {
|
||||
if (cursor >= limit &&
|
||||
keyChar == text.charAt(cursor)) {
|
||||
@ -81,9 +81,8 @@ UMatchDegree StringMatcher::matches(const Replaceable& text,
|
||||
// forward start, limit, and only if a prior match does not
|
||||
// exist -- we want the rightmost match.
|
||||
if (matchStart < 0) {
|
||||
// cast away const -- should modify method to be non-const
|
||||
((StringMatcher*)this)->matchStart = cursor+1;
|
||||
((StringMatcher*)this)->matchLimit = offset+1;
|
||||
matchStart = cursor+1;
|
||||
matchLimit = offset+1;
|
||||
}
|
||||
} else {
|
||||
for (i=0; i<pattern.length(); ++i) {
|
||||
@ -93,7 +92,7 @@ UMatchDegree StringMatcher::matches(const Replaceable& text,
|
||||
return U_PARTIAL_MATCH;
|
||||
}
|
||||
UChar keyChar = pattern.charAt(i);
|
||||
const UnicodeMatcher* subm = data.lookup(keyChar);
|
||||
UnicodeMatcher* subm = data.lookup(keyChar);
|
||||
if (subm == 0) {
|
||||
// Don't need the cursor < limit check if
|
||||
// incremental is TRUE (because it's done above); do need
|
||||
@ -113,9 +112,8 @@ UMatchDegree StringMatcher::matches(const Replaceable& text,
|
||||
}
|
||||
}
|
||||
// Record the match position
|
||||
// cast away const -- should modify method to be non-const
|
||||
((StringMatcher*)this)->matchStart = offset;
|
||||
((StringMatcher*)this)->matchLimit = cursor;
|
||||
matchStart = offset;
|
||||
matchLimit = cursor;
|
||||
}
|
||||
|
||||
offset = cursor;
|
||||
|
@ -46,7 +46,7 @@ class StringMatcher : public UnicodeMatcher {
|
||||
virtual UMatchDegree matches(const Replaceable& text,
|
||||
int32_t& offset,
|
||||
int32_t limit,
|
||||
UBool incremental) const;
|
||||
UBool incremental);
|
||||
|
||||
/**
|
||||
* Implement UnicodeMatcher
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
virtual UMatchDegree matches(const Replaceable& text,
|
||||
int32_t& offset,
|
||||
int32_t limit,
|
||||
UBool incremental) const;
|
||||
UBool incremental);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -91,6 +91,9 @@ public:
|
||||
* reverse direction, this will be the index of the last matched
|
||||
* character minus one.
|
||||
*
|
||||
* <p>Note: This method is not const because some classes may
|
||||
* modify their state as the result of a match.
|
||||
*
|
||||
* @param text the text to be matched
|
||||
* @param offset on input, the index into text at which to begin
|
||||
* matching. On output, the limit of the matched text. The
|
||||
@ -114,7 +117,7 @@ public:
|
||||
virtual UMatchDegree matches(const Replaceable& text,
|
||||
int32_t& offset,
|
||||
int32_t limit,
|
||||
UBool incremental) const = 0;
|
||||
UBool incremental) = 0;
|
||||
|
||||
/**
|
||||
* Returns a string representation of this matcher. If the result of
|
||||
|
@ -432,7 +432,7 @@ public:
|
||||
UMatchDegree matches(const Replaceable& text,
|
||||
int32_t& offset,
|
||||
int32_t limit,
|
||||
UBool incremental) const;
|
||||
UBool incremental);
|
||||
|
||||
/**
|
||||
* Adds the specified range to this set if it is not already
|
||||
|
@ -19,7 +19,7 @@ U_NAMESPACE_BEGIN
|
||||
UMatchDegree UnicodeFilter::matches(const Replaceable& text,
|
||||
int32_t& offset,
|
||||
int32_t limit,
|
||||
UBool incremental) const {
|
||||
UBool incremental) {
|
||||
UChar32 c;
|
||||
if (offset < limit &&
|
||||
contains(c = text.char32At(offset))) {
|
||||
|
@ -598,7 +598,7 @@ UBool UnicodeSet::matchesIndexValue(uint8_t v) const {
|
||||
UMatchDegree UnicodeSet::matches(const Replaceable& text,
|
||||
int32_t& offset,
|
||||
int32_t limit,
|
||||
UBool incremental) const {
|
||||
UBool incremental) {
|
||||
if (offset == limit) {
|
||||
if (contains(TransliterationRule::ETHER)) {
|
||||
return incremental ? U_PARTIAL_MATCH : U_MATCH;
|
||||
|
Loading…
Reference in New Issue
Block a user