intl/icu/source/i18n/quant.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/i18n/quant.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,124 @@
     1.4 +/*
     1.5 + **********************************************************************
     1.6 + * Copyright (C) 2001-2011, International Business Machines Corporation
     1.7 + * and others. All Rights Reserved.
     1.8 + **********************************************************************
     1.9 + *   Date        Name        Description
    1.10 + *   07/26/01    aliu        Creation.
    1.11 + **********************************************************************
    1.12 + */
    1.13 +#ifndef QUANT_H
    1.14 +#define QUANT_H
    1.15 +
    1.16 +#include "unicode/utypes.h"
    1.17 +
    1.18 +#if !UCONFIG_NO_TRANSLITERATION
    1.19 +
    1.20 +#include "unicode/unifunct.h"
    1.21 +#include "unicode/unimatch.h"
    1.22 +
    1.23 +U_NAMESPACE_BEGIN
    1.24 +
    1.25 +class Quantifier : public UnicodeFunctor, public UnicodeMatcher {
    1.26 +
    1.27 + public:
    1.28 +
    1.29 +    enum { MAX = 0x7FFFFFFF };
    1.30 +
    1.31 +    Quantifier(UnicodeFunctor *adoptedMatcher,
    1.32 +               uint32_t minCount, uint32_t maxCount);
    1.33 +
    1.34 +    Quantifier(const Quantifier& o);
    1.35 +
    1.36 +    virtual ~Quantifier();
    1.37 +
    1.38 +    /**
    1.39 +     * UnicodeFunctor API.  Cast 'this' to a UnicodeMatcher* pointer
    1.40 +     * and return the pointer.
    1.41 +     * @return the UnicodeMatcher pointer.
    1.42 +     */
    1.43 +    virtual UnicodeMatcher* toMatcher() const;
    1.44 +
    1.45 +    /**
    1.46 +     * Implement UnicodeFunctor
    1.47 +     * @return a copy of the object.
    1.48 +     */
    1.49 +    virtual UnicodeFunctor* clone() const;
    1.50 +
    1.51 +    /**
    1.52 +     * Implement UnicodeMatcher
    1.53 +     * @param text the text to be matched
    1.54 +     * @param offset on input, the index into text at which to begin
    1.55 +     * matching.  On output, the limit of the matched text.  The
    1.56 +     * number of matched characters is the output value of offset
    1.57 +     * minus the input value.  Offset should always point to the
    1.58 +     * HIGH SURROGATE (leading code unit) of a pair of surrogates,
    1.59 +     * both on entry and upon return.
    1.60 +     * @param limit the limit index of text to be matched.  Greater
    1.61 +     * than offset for a forward direction match, less than offset for
    1.62 +     * a backward direction match.  The last character to be
    1.63 +     * considered for matching will be text.charAt(limit-1) in the
    1.64 +     * forward direction or text.charAt(limit+1) in the backward
    1.65 +     * direction.
    1.66 +     * @param incremental  if TRUE, then assume further characters may
    1.67 +     * be inserted at limit and check for partial matching.  Otherwise
    1.68 +     * assume the text as given is complete.
    1.69 +     * @return a match degree value indicating a full match, a partial
    1.70 +     * match, or a mismatch.  If incremental is FALSE then
    1.71 +     * U_PARTIAL_MATCH should never be returned.
    1.72 +     */
    1.73 +    virtual UMatchDegree matches(const Replaceable& text,
    1.74 +                                 int32_t& offset,
    1.75 +                                 int32_t limit,
    1.76 +                                 UBool incremental);
    1.77 +
    1.78 +    /**
    1.79 +     * Implement UnicodeMatcher
    1.80 +     * @param result            Output param to receive the pattern.
    1.81 +     * @param escapeUnprintable if True then escape the unprintable characters.
    1.82 +     * @return                  A reference to 'result'.
    1.83 +     */
    1.84 +    virtual UnicodeString& toPattern(UnicodeString& result,
    1.85 +                                     UBool escapeUnprintable = FALSE) const;
    1.86 +
    1.87 +    /**
    1.88 +     * Implement UnicodeMatcher
    1.89 +     * @param v    the given index value.
    1.90 +     * @return     true if this rule matches the given index value.
    1.91 +     */
    1.92 +    virtual UBool matchesIndexValue(uint8_t v) const;
    1.93 +
    1.94 +    /**
    1.95 +     * Implement UnicodeMatcher
    1.96 +     */
    1.97 +    virtual void addMatchSetTo(UnicodeSet& toUnionTo) const;
    1.98 +
    1.99 +    /**
   1.100 +     * UnicodeFunctor API
   1.101 +     */
   1.102 +    virtual void setData(const TransliterationRuleData*);
   1.103 +
   1.104 +    /**
   1.105 +     * ICU "poor man's RTTI", returns a UClassID for the actual class.
   1.106 +     */
   1.107 +    virtual UClassID getDynamicClassID() const;
   1.108 +
   1.109 +    /**
   1.110 +     * ICU "poor man's RTTI", returns a UClassID for this class.
   1.111 +     */
   1.112 +    static UClassID U_EXPORT2 getStaticClassID();
   1.113 +
   1.114 + private:
   1.115 +
   1.116 +    UnicodeFunctor* matcher; // owned
   1.117 +
   1.118 +    uint32_t minCount;
   1.119 +
   1.120 +    uint32_t maxCount;
   1.121 +};
   1.122 +
   1.123 +U_NAMESPACE_END
   1.124 +
   1.125 +#endif /* #if !UCONFIG_NO_TRANSLITERATION */
   1.126 +
   1.127 +#endif

mercurial