2
* Copyright (C) 2001, International Business Machines Corporation and others. All Rights Reserved.
3
**********************************************************************
4
* Date Name Description
5
* 07/18/01 aliu Creation.
6
**********************************************************************
9
#include "unicode/unifilt.h"
10
#include "unicode/rep.h"
16
* UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer
17
* and return the pointer.
19
UnicodeMatcher* UnicodeFilter::toMatcher() const {
20
return (UnicodeMatcher*) this;
24
* Default implementation of UnicodeMatcher::matches() for Unicode
25
* filters. Matches a single code point at offset (either one or
26
* two 16-bit code units).
28
UMatchDegree UnicodeFilter::matches(const Replaceable& text,
34
contains(c = text.char32At(offset))) {
35
offset += UTF_CHAR_LENGTH(c);
39
contains(c = text.char32At(offset))) {
40
// Backup offset by 1, unless the preceding character is a
41
// surrogate pair -- then backup by 2 (keep offset pointing at
42
// the lead surrogate).
45
offset -= UTF_CHAR_LENGTH(text.char32At(offset)) - 1;
49
if (incremental && offset == limit) {
50
return U_PARTIAL_MATCH;
55
// Stub this out for filters that do not implement a pattern
56
UnicodeString& UnicodeFilter::toPattern(UnicodeString& result,
57
UBool escapeUnprintable) const {
61
// Stub this out for filters that do not implement indexing
62
UBool UnicodeFilter::matchesIndexValue(uint8_t v) const {