michael@0: /* michael@0: ********************************************************************** michael@0: * Copyright (C) 2001-2011, International Business Machines Corporation michael@0: * and others. All Rights Reserved. michael@0: ********************************************************************** michael@0: * Date Name Description michael@0: * 07/26/01 aliu Creation. michael@0: ********************************************************************** michael@0: */ michael@0: #ifndef QUANT_H michael@0: #define QUANT_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_TRANSLITERATION michael@0: michael@0: #include "unicode/unifunct.h" michael@0: #include "unicode/unimatch.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: class Quantifier : public UnicodeFunctor, public UnicodeMatcher { michael@0: michael@0: public: michael@0: michael@0: enum { MAX = 0x7FFFFFFF }; michael@0: michael@0: Quantifier(UnicodeFunctor *adoptedMatcher, michael@0: uint32_t minCount, uint32_t maxCount); michael@0: michael@0: Quantifier(const Quantifier& o); michael@0: michael@0: virtual ~Quantifier(); michael@0: michael@0: /** michael@0: * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer michael@0: * and return the pointer. michael@0: * @return the UnicodeMatcher pointer. michael@0: */ michael@0: virtual UnicodeMatcher* toMatcher() const; michael@0: michael@0: /** michael@0: * Implement UnicodeFunctor michael@0: * @return a copy of the object. michael@0: */ michael@0: virtual UnicodeFunctor* clone() const; michael@0: michael@0: /** michael@0: * Implement UnicodeMatcher michael@0: * @param text the text to be matched michael@0: * @param offset on input, the index into text at which to begin michael@0: * matching. On output, the limit of the matched text. The michael@0: * number of matched characters is the output value of offset michael@0: * minus the input value. Offset should always point to the michael@0: * HIGH SURROGATE (leading code unit) of a pair of surrogates, michael@0: * both on entry and upon return. michael@0: * @param limit the limit index of text to be matched. Greater michael@0: * than offset for a forward direction match, less than offset for michael@0: * a backward direction match. The last character to be michael@0: * considered for matching will be text.charAt(limit-1) in the michael@0: * forward direction or text.charAt(limit+1) in the backward michael@0: * direction. michael@0: * @param incremental if TRUE, then assume further characters may michael@0: * be inserted at limit and check for partial matching. Otherwise michael@0: * assume the text as given is complete. michael@0: * @return a match degree value indicating a full match, a partial michael@0: * match, or a mismatch. If incremental is FALSE then michael@0: * U_PARTIAL_MATCH should never be returned. michael@0: */ michael@0: virtual UMatchDegree matches(const Replaceable& text, michael@0: int32_t& offset, michael@0: int32_t limit, michael@0: UBool incremental); michael@0: michael@0: /** michael@0: * Implement UnicodeMatcher michael@0: * @param result Output param to receive the pattern. michael@0: * @param escapeUnprintable if True then escape the unprintable characters. michael@0: * @return A reference to 'result'. michael@0: */ michael@0: virtual UnicodeString& toPattern(UnicodeString& result, michael@0: UBool escapeUnprintable = FALSE) const; michael@0: michael@0: /** michael@0: * Implement UnicodeMatcher michael@0: * @param v the given index value. michael@0: * @return true if this rule matches the given index value. michael@0: */ michael@0: virtual UBool matchesIndexValue(uint8_t v) const; michael@0: michael@0: /** michael@0: * Implement UnicodeMatcher michael@0: */ michael@0: virtual void addMatchSetTo(UnicodeSet& toUnionTo) const; michael@0: michael@0: /** michael@0: * UnicodeFunctor API michael@0: */ michael@0: virtual void setData(const TransliterationRuleData*); michael@0: michael@0: /** michael@0: * ICU "poor man's RTTI", returns a UClassID for the actual class. michael@0: */ michael@0: virtual UClassID getDynamicClassID() const; michael@0: michael@0: /** michael@0: * ICU "poor man's RTTI", returns a UClassID for this class. michael@0: */ michael@0: static UClassID U_EXPORT2 getStaticClassID(); michael@0: michael@0: private: michael@0: michael@0: UnicodeFunctor* matcher; // owned michael@0: michael@0: uint32_t minCount; michael@0: michael@0: uint32_t maxCount; michael@0: }; michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* #if !UCONFIG_NO_TRANSLITERATION */ michael@0: michael@0: #endif