]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/quant.h
2 * Copyright (C) 2001, International Business Machines Corporation and others. All Rights Reserved.
3 **********************************************************************
4 * Date Name Description
5 * 07/26/01 aliu Creation.
6 **********************************************************************
11 #include "unicode/utypes.h"
13 #if !UCONFIG_NO_TRANSLITERATION
15 #include "unicode/unifunct.h"
16 #include "unicode/unimatch.h"
20 class Quantifier
: public UnicodeFunctor
, public UnicodeMatcher
{
24 enum { MAX
= 0x7FFFFFFF };
26 Quantifier(UnicodeFunctor
*adoptedMatcher
,
27 uint32_t minCount
, uint32_t maxCount
);
29 Quantifier(const Quantifier
& o
);
31 virtual ~Quantifier();
34 * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer
35 * and return the pointer.
36 * @return the UnicodeMatcher pointer.
38 virtual UnicodeMatcher
* toMatcher() const;
41 * Implement UnicodeFunctor
42 * @return a copy of the object.
44 virtual UnicodeFunctor
* clone() const;
47 * Implement UnicodeMatcher
48 * @param text the text to be matched
49 * @param offset on input, the index into text at which to begin
50 * matching. On output, the limit of the matched text. The
51 * number of matched characters is the output value of offset
52 * minus the input value. Offset should always point to the
53 * HIGH SURROGATE (leading code unit) of a pair of surrogates,
54 * both on entry and upon return.
55 * @param limit the limit index of text to be matched. Greater
56 * than offset for a forward direction match, less than offset for
57 * a backward direction match. The last character to be
58 * considered for matching will be text.charAt(limit-1) in the
59 * forward direction or text.charAt(limit+1) in the backward
61 * @param incremental if TRUE, then assume further characters may
62 * be inserted at limit and check for partial matching. Otherwise
63 * assume the text as given is complete.
64 * @return a match degree value indicating a full match, a partial
65 * match, or a mismatch. If incremental is FALSE then
66 * U_PARTIAL_MATCH should never be returned.
68 virtual UMatchDegree
matches(const Replaceable
& text
,
74 * Implement UnicodeMatcher
75 * @param result Output param to receive the pattern.
76 * @param escapeUnprintable if True then escape the unprintable characters.
77 * @return A reference to 'result'.
79 virtual UnicodeString
& toPattern(UnicodeString
& result
,
80 UBool escapeUnprintable
= FALSE
) const;
83 * Implement UnicodeMatcher
84 * @param v the given index value.
85 * @return true if this rule matches the given index value.
87 virtual UBool
matchesIndexValue(uint8_t v
) const;
90 * Implement UnicodeMatcher
92 virtual void addMatchSetTo(UnicodeSet
& toUnionTo
) const;
97 virtual void setData(const TransliterationRuleData
*);
100 * ICU "poor man's RTTI", returns a UClassID for the actual class.
104 virtual inline UClassID
getDynamicClassID() const { return getStaticClassID(); }
107 * ICU "poor man's RTTI", returns a UClassID for this class.
111 static inline UClassID
getStaticClassID() { return (UClassID
)&fgClassID
; }
115 static void appendNumber(UnicodeString
& result
, int32_t n
);
117 UnicodeFunctor
* matcher
; // owned
124 * The address of this static class variable serves as this class's ID
125 * for ICU "poor man's RTTI".
127 static const char fgClassID
;
132 #endif /* #if !UCONFIG_NO_TRANSLITERATION */