]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/plurrule_impl.h
2 *******************************************************************************
3 * Copyright (C) 2007-2011, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 *******************************************************************************
9 *******************************************************************************
13 #ifndef PLURRULE_IMPLE
14 #define PLURRULE_IMPLE
16 // Internal definitions for the PluralRules implementation.
18 #if !UCONFIG_NO_FORMATTING
20 #include "unicode/format.h"
21 #include "unicode/locid.h"
22 #include "unicode/parseerr.h"
23 #include "unicode/utypes.h"
29 #define DOT ((UChar)0x002E)
30 #define SINGLE_QUOTE ((UChar)0x0027)
31 #define SLASH ((UChar)0x002F)
32 #define BACKSLASH ((UChar)0x005C)
33 #define SPACE ((UChar)0x0020)
34 #define QUOTATION_MARK ((UChar)0x0022)
35 #define NUMBER_SIGN ((UChar)0x0023)
36 #define ASTERISK ((UChar)0x002A)
37 #define COMMA ((UChar)0x002C)
38 #define HYPHEN ((UChar)0x002D)
39 #define U_ZERO ((UChar)0x0030)
40 #define U_ONE ((UChar)0x0031)
41 #define U_TWO ((UChar)0x0032)
42 #define U_THREE ((UChar)0x0033)
43 #define U_FOUR ((UChar)0x0034)
44 #define U_FIVE ((UChar)0x0035)
45 #define U_SIX ((UChar)0x0036)
46 #define U_SEVEN ((UChar)0x0037)
47 #define U_EIGHT ((UChar)0x0038)
48 #define U_NINE ((UChar)0x0039)
49 #define COLON ((UChar)0x003A)
50 #define SEMI_COLON ((UChar)0x003B)
51 #define CAP_A ((UChar)0x0041)
52 #define CAP_B ((UChar)0x0042)
53 #define CAP_R ((UChar)0x0052)
54 #define CAP_Z ((UChar)0x005A)
55 #define LOWLINE ((UChar)0x005F)
56 #define LEFTBRACE ((UChar)0x007B)
57 #define RIGHTBRACE ((UChar)0x007D)
59 #define LOW_A ((UChar)0x0061)
60 #define LOW_B ((UChar)0x0062)
61 #define LOW_C ((UChar)0x0063)
62 #define LOW_D ((UChar)0x0064)
63 #define LOW_E ((UChar)0x0065)
64 #define LOW_F ((UChar)0x0066)
65 #define LOW_G ((UChar)0x0067)
66 #define LOW_H ((UChar)0x0068)
67 #define LOW_I ((UChar)0x0069)
68 #define LOW_J ((UChar)0x006a)
69 #define LOW_K ((UChar)0x006B)
70 #define LOW_L ((UChar)0x006C)
71 #define LOW_M ((UChar)0x006D)
72 #define LOW_N ((UChar)0x006E)
73 #define LOW_O ((UChar)0x006F)
74 #define LOW_P ((UChar)0x0070)
75 #define LOW_Q ((UChar)0x0071)
76 #define LOW_R ((UChar)0x0072)
77 #define LOW_S ((UChar)0x0073)
78 #define LOW_T ((UChar)0x0074)
79 #define LOW_U ((UChar)0x0075)
80 #define LOW_V ((UChar)0x0076)
81 #define LOW_W ((UChar)0x0077)
82 #define LOW_Y ((UChar)0x0079)
83 #define LOW_Z ((UChar)0x007A)
86 #define PLURAL_RANGE_HIGH 0x7fffffff;
89 typedef enum PluralKey
{
99 typedef enum tokenType
{
128 class RuleParser
: public UMemory
{
131 virtual ~RuleParser();
132 void getNextToken(const UnicodeString
& ruleData
, int32_t *ruleIndex
, UnicodeString
& token
,
133 tokenType
& type
, UErrorCode
&status
);
134 void checkSyntax(tokenType prevType
, tokenType curType
, UErrorCode
&status
);
136 void getKeyType(const UnicodeString
& token
, tokenType
& type
, UErrorCode
&status
);
137 UBool
inRange(UChar ch
, tokenType
& type
);
138 UBool
isValidKeyword(const UnicodeString
& token
);
141 class AndConstraint
: public UMemory
{
143 typedef enum RuleOp
{
156 AndConstraint(const AndConstraint
& other
);
157 virtual ~AndConstraint();
158 AndConstraint
* add();
159 UBool
isFulfilled(double number
);
161 int32_t updateRepeatLimit(int32_t maxLimit
);
164 class OrConstraint
: public UMemory
{
166 AndConstraint
*childNode
;
170 OrConstraint(const OrConstraint
& other
);
171 virtual ~OrConstraint();
172 AndConstraint
* add();
173 UBool
isFulfilled(double number
);
177 class RuleChain
: public UMemory
{
179 OrConstraint
*ruleHeader
;
180 UnicodeString keyword
;
182 RuleChain(const RuleChain
& other
);
185 virtual ~RuleChain();
186 UnicodeString
select(double number
) const;
187 void dumpRules(UnicodeString
& result
);
188 int32_t getRepeatLimit();
190 UErrorCode
getKeywords(int32_t maxArraySize
, UnicodeString
*keywords
, int32_t& arraySize
) const;
191 UBool
isKeyword(const UnicodeString
& keyword
) const;
192 void setRepeatLimit();
197 class PluralKeywordEnumeration
: public StringEnumeration
{
199 PluralKeywordEnumeration(RuleChain
*header
, UErrorCode
& status
);
200 virtual ~PluralKeywordEnumeration();
201 static UClassID U_EXPORT2
getStaticClassID(void);
202 virtual UClassID
getDynamicClassID(void) const;
203 virtual const UnicodeString
* snext(UErrorCode
& status
);
204 virtual void reset(UErrorCode
& status
);
205 virtual int32_t count(UErrorCode
& status
) const;
208 UVector fKeywordNames
;
213 #endif /* #if !UCONFIG_NO_FORMATTING */
215 #endif // _PLURRULE_IMPL