]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/quant.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
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 **********************************************************************
15 #include "unicode/utypes.h"
17 #if !UCONFIG_NO_TRANSLITERATION
19 #include "unicode/unifunct.h"
20 #include "unicode/unimatch.h"
24 class Quantifier
: public UnicodeFunctor
, public UnicodeMatcher
{
28 enum { MAX
= 0x7FFFFFFF };
30 Quantifier(UnicodeFunctor
*adoptedMatcher
,
31 uint32_t minCount
, uint32_t maxCount
);
33 Quantifier(const Quantifier
& o
);
35 virtual ~Quantifier();
38 * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer
39 * and return the pointer.
40 * @return the UnicodeMatcher pointer.
42 virtual UnicodeMatcher
* toMatcher() const;
45 * Implement UnicodeFunctor
46 * @return a copy of the object.
48 virtual UnicodeFunctor
* clone() const;
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
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.
72 virtual UMatchDegree
matches(const Replaceable
& text
,
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'.
83 virtual UnicodeString
& toPattern(UnicodeString
& result
,
84 UBool escapeUnprintable
= FALSE
) const;
87 * Implement UnicodeMatcher
88 * @param v the given index value.
89 * @return true if this rule matches the given index value.
91 virtual UBool
matchesIndexValue(uint8_t v
) const;
94 * Implement UnicodeMatcher
96 virtual void addMatchSetTo(UnicodeSet
& toUnionTo
) const;
101 virtual void setData(const TransliterationRuleData
*);
104 * ICU "poor man's RTTI", returns a UClassID for the actual class.
106 virtual UClassID
getDynamicClassID() const;
109 * ICU "poor man's RTTI", returns a UClassID for this class.
111 static UClassID U_EXPORT2
getStaticClassID();
115 UnicodeFunctor
* matcher
; // owned
124 #endif /* #if !UCONFIG_NO_TRANSLITERATION */