tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

quant.h (4021B)


      1 // © 2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html
      3 /*
      4 **********************************************************************
      5 * Copyright (C) 2001-2011, International Business Machines Corporation
      6 * and others. All Rights Reserved.
      7 **********************************************************************
      8 *   Date        Name        Description
      9 *   07/26/01    aliu        Creation.
     10 **********************************************************************
     11 */
     12 #ifndef QUANT_H
     13 #define QUANT_H
     14 
     15 #include "unicode/utypes.h"
     16 
     17 #if !UCONFIG_NO_TRANSLITERATION
     18 
     19 #include "unicode/unifunct.h"
     20 #include "unicode/unimatch.h"
     21 
     22 U_NAMESPACE_BEGIN
     23 
     24 class Quantifier : public UnicodeFunctor, public UnicodeMatcher {
     25 
     26 public:
     27 
     28    enum { MAX = 0x7FFFFFFF };
     29 
     30    Quantifier(UnicodeFunctor *adoptedMatcher,
     31               uint32_t minCount, uint32_t maxCount);
     32 
     33    Quantifier(const Quantifier& o);
     34 
     35    virtual ~Quantifier();
     36 
     37    /**
     38     * UnicodeFunctor API.  Cast 'this' to a UnicodeMatcher* pointer
     39     * and return the pointer.
     40     * @return the UnicodeMatcher pointer.
     41     */
     42    virtual UnicodeMatcher* toMatcher() const override;
     43 
     44    /**
     45     * Implement UnicodeFunctor
     46     * @return a copy of the object.
     47     */
     48    virtual Quantifier* clone() const override;
     49 
     50    /**
     51     * Implement UnicodeMatcher
     52     * @param text the text to be matched
     53     * @param offset on input, the index into text at which to begin
     54     * matching.  On output, the limit of the matched text.  The
     55     * number of matched characters is the output value of offset
     56     * minus the input value.  Offset should always point to the
     57     * HIGH SURROGATE (leading code unit) of a pair of surrogates,
     58     * both on entry and upon return.
     59     * @param limit the limit index of text to be matched.  Greater
     60     * than offset for a forward direction match, less than offset for
     61     * a backward direction match.  The last character to be
     62     * considered for matching will be text.charAt(limit-1) in the
     63     * forward direction or text.charAt(limit+1) in the backward
     64     * direction.
     65     * @param incremental  if true, then assume further characters may
     66     * be inserted at limit and check for partial matching.  Otherwise
     67     * assume the text as given is complete.
     68     * @return a match degree value indicating a full match, a partial
     69     * match, or a mismatch.  If incremental is false then
     70     * U_PARTIAL_MATCH should never be returned.
     71     */
     72    virtual UMatchDegree matches(const Replaceable& text,
     73                                 int32_t& offset,
     74                                 int32_t limit,
     75                                 UBool incremental) override;
     76 
     77    /**
     78     * Implement UnicodeMatcher
     79     * @param result            Output param to receive the pattern.
     80     * @param escapeUnprintable if True then escape the unprintable characters.
     81     * @return                  A reference to 'result'.
     82     */
     83    virtual UnicodeString& toPattern(UnicodeString& result,
     84                                     UBool escapeUnprintable = false) const override;
     85 
     86    /**
     87     * Implement UnicodeMatcher
     88     * @param v    the given index value.
     89     * @return     true if this rule matches the given index value.
     90     */
     91    virtual UBool matchesIndexValue(uint8_t v) const override;
     92 
     93    /**
     94     * Implement UnicodeMatcher
     95     */
     96    virtual void addMatchSetTo(UnicodeSet& toUnionTo) const override;
     97 
     98    /**
     99     * UnicodeFunctor API
    100     */
    101    virtual void setData(const TransliterationRuleData*) override;
    102 
    103    /**
    104     * ICU "poor man's RTTI", returns a UClassID for the actual class.
    105     */
    106    virtual UClassID getDynamicClassID() const override;
    107 
    108    /**
    109     * ICU "poor man's RTTI", returns a UClassID for this class.
    110     */
    111    static UClassID U_EXPORT2 getStaticClassID();
    112 
    113 private:
    114 
    115    UnicodeFunctor* matcher; // owned
    116 
    117    uint32_t minCount;
    118 
    119    uint32_t maxCount;
    120 };
    121 
    122 U_NAMESPACE_END
    123 
    124 #endif /* #if !UCONFIG_NO_TRANSLITERATION */
    125 
    126 #endif