2001-07-27 00:18:53 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2001, International Business Machines Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
|
|
|
* Date Name Description
|
|
|
|
* 07/23/01 aliu Creation.
|
|
|
|
**********************************************************************
|
|
|
|
*/
|
|
|
|
#ifndef STRMATCH_H
|
|
|
|
#define STRMATCH_H
|
|
|
|
|
|
|
|
#include "unicode/unistr.h"
|
|
|
|
#include "unicode/unimatch.h"
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2001-07-27 00:18:53 +00:00
|
|
|
class TransliterationRuleData;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An object that matches a string.
|
|
|
|
*/
|
|
|
|
class StringMatcher : public UnicodeMatcher {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
StringMatcher(const UnicodeString& string,
|
|
|
|
int32_t start,
|
|
|
|
int32_t limit,
|
2001-07-30 23:23:16 +00:00
|
|
|
UBool isSegment,
|
2001-07-27 00:18:53 +00:00
|
|
|
const TransliterationRuleData& data);
|
|
|
|
|
|
|
|
StringMatcher(const StringMatcher& o);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
virtual ~StringMatcher();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implement UnicodeMatcher
|
|
|
|
*/
|
|
|
|
virtual UnicodeMatcher* clone() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implement UnicodeMatcher
|
|
|
|
*/
|
|
|
|
virtual UMatchDegree matches(const Replaceable& text,
|
|
|
|
int32_t& offset,
|
|
|
|
int32_t limit,
|
2001-10-30 23:55:09 +00:00
|
|
|
UBool incremental);
|
2001-07-27 00:18:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implement UnicodeMatcher
|
|
|
|
*/
|
|
|
|
virtual UnicodeString& toPattern(UnicodeString& result,
|
|
|
|
UBool escapeUnprintable = FALSE) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implement UnicodeMatcher
|
|
|
|
*/
|
|
|
|
virtual UBool matchesIndexValue(uint8_t v) const;
|
|
|
|
|
2001-10-30 18:08:53 +00:00
|
|
|
/**
|
|
|
|
* Remove any match data. This must be called before performing a
|
|
|
|
* set of matches with this segment.
|
|
|
|
*/
|
|
|
|
void resetMatch();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the start offset, in the match text, of the <em>rightmost</em>
|
|
|
|
* match. This method may get moved up into the UnicodeMatcher if
|
|
|
|
* it turns out to be useful to generalize this.
|
|
|
|
*/
|
|
|
|
int32_t getMatchStart() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the limit offset, in the match text, of the <em>rightmost</em>
|
|
|
|
* match. This method may get moved up into the UnicodeMatcher if
|
|
|
|
* it turns out to be useful to generalize this.
|
|
|
|
*/
|
|
|
|
int32_t getMatchLimit() const;
|
|
|
|
|
2001-07-27 00:18:53 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
UnicodeString pattern;
|
|
|
|
|
|
|
|
const TransliterationRuleData& data;
|
2001-07-30 23:23:16 +00:00
|
|
|
|
|
|
|
UBool isSegment;
|
2001-10-30 18:08:53 +00:00
|
|
|
|
|
|
|
int32_t matchStart;
|
|
|
|
|
|
|
|
int32_t matchLimit;
|
2001-07-27 00:18:53 +00:00
|
|
|
};
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2001-07-27 00:18:53 +00:00
|
|
|
#endif
|