11cb0ef41Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others. 21cb0ef41Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html 31cb0ef41Sopenharmony_ci/* 41cb0ef41Sopenharmony_ci ********************************************************************** 51cb0ef41Sopenharmony_ci * Copyright (C) 2001-2011, International Business Machines Corporation 61cb0ef41Sopenharmony_ci * and others. All Rights Reserved. 71cb0ef41Sopenharmony_ci ********************************************************************** 81cb0ef41Sopenharmony_ci * Date Name Description 91cb0ef41Sopenharmony_ci * 07/26/01 aliu Creation. 101cb0ef41Sopenharmony_ci ********************************************************************** 111cb0ef41Sopenharmony_ci */ 121cb0ef41Sopenharmony_ci#ifndef QUANT_H 131cb0ef41Sopenharmony_ci#define QUANT_H 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci#include "unicode/utypes.h" 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci#if !UCONFIG_NO_TRANSLITERATION 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci#include "unicode/unifunct.h" 201cb0ef41Sopenharmony_ci#include "unicode/unimatch.h" 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciU_NAMESPACE_BEGIN 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciclass Quantifier : public UnicodeFunctor, public UnicodeMatcher { 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci public: 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci enum { MAX = 0x7FFFFFFF }; 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci Quantifier(UnicodeFunctor *adoptedMatcher, 311cb0ef41Sopenharmony_ci uint32_t minCount, uint32_t maxCount); 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci Quantifier(const Quantifier& o); 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci virtual ~Quantifier(); 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci /** 381cb0ef41Sopenharmony_ci * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer 391cb0ef41Sopenharmony_ci * and return the pointer. 401cb0ef41Sopenharmony_ci * @return the UnicodeMatcher pointer. 411cb0ef41Sopenharmony_ci */ 421cb0ef41Sopenharmony_ci virtual UnicodeMatcher* toMatcher() const override; 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci /** 451cb0ef41Sopenharmony_ci * Implement UnicodeFunctor 461cb0ef41Sopenharmony_ci * @return a copy of the object. 471cb0ef41Sopenharmony_ci */ 481cb0ef41Sopenharmony_ci virtual Quantifier* clone() const override; 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ci /** 511cb0ef41Sopenharmony_ci * Implement UnicodeMatcher 521cb0ef41Sopenharmony_ci * @param text the text to be matched 531cb0ef41Sopenharmony_ci * @param offset on input, the index into text at which to begin 541cb0ef41Sopenharmony_ci * matching. On output, the limit of the matched text. The 551cb0ef41Sopenharmony_ci * number of matched characters is the output value of offset 561cb0ef41Sopenharmony_ci * minus the input value. Offset should always point to the 571cb0ef41Sopenharmony_ci * HIGH SURROGATE (leading code unit) of a pair of surrogates, 581cb0ef41Sopenharmony_ci * both on entry and upon return. 591cb0ef41Sopenharmony_ci * @param limit the limit index of text to be matched. Greater 601cb0ef41Sopenharmony_ci * than offset for a forward direction match, less than offset for 611cb0ef41Sopenharmony_ci * a backward direction match. The last character to be 621cb0ef41Sopenharmony_ci * considered for matching will be text.charAt(limit-1) in the 631cb0ef41Sopenharmony_ci * forward direction or text.charAt(limit+1) in the backward 641cb0ef41Sopenharmony_ci * direction. 651cb0ef41Sopenharmony_ci * @param incremental if true, then assume further characters may 661cb0ef41Sopenharmony_ci * be inserted at limit and check for partial matching. Otherwise 671cb0ef41Sopenharmony_ci * assume the text as given is complete. 681cb0ef41Sopenharmony_ci * @return a match degree value indicating a full match, a partial 691cb0ef41Sopenharmony_ci * match, or a mismatch. If incremental is false then 701cb0ef41Sopenharmony_ci * U_PARTIAL_MATCH should never be returned. 711cb0ef41Sopenharmony_ci */ 721cb0ef41Sopenharmony_ci virtual UMatchDegree matches(const Replaceable& text, 731cb0ef41Sopenharmony_ci int32_t& offset, 741cb0ef41Sopenharmony_ci int32_t limit, 751cb0ef41Sopenharmony_ci UBool incremental) override; 761cb0ef41Sopenharmony_ci 771cb0ef41Sopenharmony_ci /** 781cb0ef41Sopenharmony_ci * Implement UnicodeMatcher 791cb0ef41Sopenharmony_ci * @param result Output param to receive the pattern. 801cb0ef41Sopenharmony_ci * @param escapeUnprintable if True then escape the unprintable characters. 811cb0ef41Sopenharmony_ci * @return A reference to 'result'. 821cb0ef41Sopenharmony_ci */ 831cb0ef41Sopenharmony_ci virtual UnicodeString& toPattern(UnicodeString& result, 841cb0ef41Sopenharmony_ci UBool escapeUnprintable = false) const override; 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ci /** 871cb0ef41Sopenharmony_ci * Implement UnicodeMatcher 881cb0ef41Sopenharmony_ci * @param v the given index value. 891cb0ef41Sopenharmony_ci * @return true if this rule matches the given index value. 901cb0ef41Sopenharmony_ci */ 911cb0ef41Sopenharmony_ci virtual UBool matchesIndexValue(uint8_t v) const override; 921cb0ef41Sopenharmony_ci 931cb0ef41Sopenharmony_ci /** 941cb0ef41Sopenharmony_ci * Implement UnicodeMatcher 951cb0ef41Sopenharmony_ci */ 961cb0ef41Sopenharmony_ci virtual void addMatchSetTo(UnicodeSet& toUnionTo) const override; 971cb0ef41Sopenharmony_ci 981cb0ef41Sopenharmony_ci /** 991cb0ef41Sopenharmony_ci * UnicodeFunctor API 1001cb0ef41Sopenharmony_ci */ 1011cb0ef41Sopenharmony_ci virtual void setData(const TransliterationRuleData*) override; 1021cb0ef41Sopenharmony_ci 1031cb0ef41Sopenharmony_ci /** 1041cb0ef41Sopenharmony_ci * ICU "poor man's RTTI", returns a UClassID for the actual class. 1051cb0ef41Sopenharmony_ci */ 1061cb0ef41Sopenharmony_ci virtual UClassID getDynamicClassID() const override; 1071cb0ef41Sopenharmony_ci 1081cb0ef41Sopenharmony_ci /** 1091cb0ef41Sopenharmony_ci * ICU "poor man's RTTI", returns a UClassID for this class. 1101cb0ef41Sopenharmony_ci */ 1111cb0ef41Sopenharmony_ci static UClassID U_EXPORT2 getStaticClassID(); 1121cb0ef41Sopenharmony_ci 1131cb0ef41Sopenharmony_ci private: 1141cb0ef41Sopenharmony_ci 1151cb0ef41Sopenharmony_ci UnicodeFunctor* matcher; // owned 1161cb0ef41Sopenharmony_ci 1171cb0ef41Sopenharmony_ci uint32_t minCount; 1181cb0ef41Sopenharmony_ci 1191cb0ef41Sopenharmony_ci uint32_t maxCount; 1201cb0ef41Sopenharmony_ci}; 1211cb0ef41Sopenharmony_ci 1221cb0ef41Sopenharmony_ciU_NAMESPACE_END 1231cb0ef41Sopenharmony_ci 1241cb0ef41Sopenharmony_ci#endif /* #if !UCONFIG_NO_TRANSLITERATION */ 1251cb0ef41Sopenharmony_ci 1261cb0ef41Sopenharmony_ci#endif 127