OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * Copyright (C) 1997-2008, International Business Machines | 3 * Copyright (C) 1997-2014, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ******************************************************************************* | 5 ******************************************************************************* |
6 */ | 6 */ |
7 | 7 |
8 #ifndef NFRULE_H | 8 #ifndef NFRULE_H |
9 #define NFRULE_H | 9 #define NFRULE_H |
10 | 10 |
11 #include "unicode/rbnf.h" | 11 #include "unicode/rbnf.h" |
12 | 12 |
13 #if U_HAVE_RBNF | 13 #if U_HAVE_RBNF |
14 | 14 |
15 #include "unicode/utypes.h" | 15 #include "unicode/utypes.h" |
16 #include "unicode/uobject.h" | 16 #include "unicode/uobject.h" |
17 #include "unicode/unistr.h" | 17 #include "unicode/unistr.h" |
18 #include "putilimp.h" | 18 #include "putilimp.h" |
19 | 19 |
20 U_NAMESPACE_BEGIN | 20 U_NAMESPACE_BEGIN |
21 | 21 |
22 class FieldPosition; | 22 class FieldPosition; |
23 class Formattable; | 23 class Formattable; |
24 class NFRuleList; | 24 class NFRuleList; |
25 class NFRuleSet; | 25 class NFRuleSet; |
26 class NFSubstitution; | 26 class NFSubstitution; |
27 class ParsePosition; | 27 class ParsePosition; |
| 28 class PluralFormat; |
28 class RuleBasedNumberFormat; | 29 class RuleBasedNumberFormat; |
29 class UnicodeString; | 30 class UnicodeString; |
30 | 31 |
31 class NFRule : public UMemory { | 32 class NFRule : public UMemory { |
32 public: | 33 public: |
33 | 34 |
34 enum ERuleType { | 35 enum ERuleType { |
35 kNoBase = 0, | 36 kNoBase = 0, |
36 kNegativeNumberRule = -1, | 37 kNegativeNumberRule = -1, |
37 kImproperFractionRule = -2, | 38 kImproperFractionRule = -2, |
(...skipping 16 matching lines...) Expand all Loading... |
54 UBool operator!=(const NFRule& rhs) const { return !operator==(rhs); } | 55 UBool operator!=(const NFRule& rhs) const { return !operator==(rhs); } |
55 | 56 |
56 ERuleType getType() const { return (ERuleType)(baseValue <= kNoBase ? (ERule
Type)baseValue : kOtherRule); } | 57 ERuleType getType() const { return (ERuleType)(baseValue <= kNoBase ? (ERule
Type)baseValue : kOtherRule); } |
57 void setType(ERuleType ruleType) { baseValue = (int32_t)ruleType; } | 58 void setType(ERuleType ruleType) { baseValue = (int32_t)ruleType; } |
58 | 59 |
59 int64_t getBaseValue() const { return baseValue; } | 60 int64_t getBaseValue() const { return baseValue; } |
60 void setBaseValue(int64_t value, UErrorCode& status); | 61 void setBaseValue(int64_t value, UErrorCode& status); |
61 | 62 |
62 double getDivisor() const { return uprv_pow(radix, exponent); } | 63 double getDivisor() const { return uprv_pow(radix, exponent); } |
63 | 64 |
64 void doFormat(int64_t number, UnicodeString& toAppendTo, int32_t pos) const; | 65 void doFormat(int64_t number, UnicodeString& toAppendTo, int32_t pos, UError
Code& status) const; |
65 void doFormat(double number, UnicodeString& toAppendTo, int32_t pos) const; | 66 void doFormat(double number, UnicodeString& toAppendTo, int32_t pos, UError
Code& status) const; |
66 | 67 |
67 UBool doParse(const UnicodeString& text, | 68 UBool doParse(const UnicodeString& text, |
68 ParsePosition& pos, | 69 ParsePosition& pos, |
69 UBool isFractional, | 70 UBool isFractional, |
70 double upperBound, | 71 double upperBound, |
71 Formattable& result) const; | 72 Formattable& result) const; |
72 | 73 |
73 UBool shouldRollBack(double number) const; | 74 UBool shouldRollBack(double number) const; |
74 | 75 |
75 void _appendRuleText(UnicodeString& result) const; | 76 void _appendRuleText(UnicodeString& result) const; |
76 | 77 |
| 78 int32_t findTextLenient(const UnicodeString& str, const UnicodeString& key, |
| 79 int32_t startingAt, int32_t* resultCount) const; |
| 80 |
77 private: | 81 private: |
78 void parseRuleDescriptor(UnicodeString& descriptor, UErrorCode& status); | 82 void parseRuleDescriptor(UnicodeString& descriptor, UErrorCode& status); |
79 void extractSubstitutions(const NFRuleSet* ruleSet, const NFRule* predecesso
r, const RuleBasedNumberFormat* rbnf, UErrorCode& status); | 83 void extractSubstitutions(const NFRuleSet* ruleSet, const UnicodeString &rul
eText, const NFRule* predecessor, UErrorCode& status); |
80 NFSubstitution* extractSubstitution(const NFRuleSet* ruleSet, const NFRule*
predecessor, const RuleBasedNumberFormat* rbnf, UErrorCode& status); | 84 NFSubstitution* extractSubstitution(const NFRuleSet* ruleSet, const NFRule*
predecessor, UErrorCode& status); |
81 | 85 |
82 int16_t expectedExponent() const; | 86 int16_t expectedExponent() const; |
83 int32_t indexOfAny(const UChar* const strings[]) const; | 87 int32_t indexOfAny(const UChar* const strings[]) const; |
84 double matchToDelimiter(const UnicodeString& text, int32_t startPos, double
baseValue, | 88 double matchToDelimiter(const UnicodeString& text, int32_t startPos, double
baseValue, |
85 const UnicodeString& delimiter, ParsePosition& pp, c
onst NFSubstitution* sub, | 89 const UnicodeString& delimiter, ParsePosition& pp, c
onst NFSubstitution* sub, |
86 double upperBound) const; | 90 double upperBound) const; |
87 void stripPrefix(UnicodeString& text, const UnicodeString& prefix, ParsePosi
tion& pp) const; | 91 void stripPrefix(UnicodeString& text, const UnicodeString& prefix, ParsePosi
tion& pp) const; |
88 | 92 |
89 int32_t prefixLength(const UnicodeString& str, const UnicodeString& prefix,
UErrorCode& status) const; | 93 int32_t prefixLength(const UnicodeString& str, const UnicodeString& prefix,
UErrorCode& status) const; |
90 UBool allIgnorable(const UnicodeString& str, UErrorCode& status) const; | 94 UBool allIgnorable(const UnicodeString& str, UErrorCode& status) const; |
91 int32_t findText(const UnicodeString& str, const UnicodeString& key, | 95 int32_t findText(const UnicodeString& str, const UnicodeString& key, |
92 int32_t startingAt, int32_t* resultCount) const; | 96 int32_t startingAt, int32_t* resultCount) const; |
93 | 97 |
94 private: | 98 private: |
95 int64_t baseValue; | 99 int64_t baseValue; |
96 int32_t radix; | 100 int32_t radix; |
97 int16_t exponent; | 101 int16_t exponent; |
98 UnicodeString ruleText; | 102 UnicodeString ruleText; |
99 NFSubstitution* sub1; | 103 NFSubstitution* sub1; |
100 NFSubstitution* sub2; | 104 NFSubstitution* sub2; |
101 const RuleBasedNumberFormat* formatter; | 105 const RuleBasedNumberFormat* formatter; |
| 106 const PluralFormat* rulePatternFormat; |
102 | 107 |
103 NFRule(const NFRule &other); // forbid copying of this class | 108 NFRule(const NFRule &other); // forbid copying of this class |
104 NFRule &operator=(const NFRule &other); // forbid copying of this class | 109 NFRule &operator=(const NFRule &other); // forbid copying of this class |
105 }; | 110 }; |
106 | 111 |
107 U_NAMESPACE_END | 112 U_NAMESPACE_END |
108 | 113 |
109 /* U_HAVE_RBNF */ | 114 /* U_HAVE_RBNF */ |
110 #endif | 115 #endif |
111 | 116 |
112 // NFRULE_H | 117 // NFRULE_H |
113 #endif | 118 #endif |
114 | 119 |
OLD | NEW |