intl/icu/source/i18n/quant.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial