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