OLD | NEW |
1 /* | 1 /* |
2 ****************************************************************************** | 2 ****************************************************************************** |
3 * Copyright (C) 1997-2014, International Business Machines | 3 * Copyright (C) 1997-2015, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ****************************************************************************** | 5 ****************************************************************************** |
6 * file name: nfsubs.h | 6 * file name: nfsubs.h |
7 * encoding: US-ASCII | 7 * encoding: US-ASCII |
8 * tab size: 8 (not used) | 8 * tab size: 8 (not used) |
9 * indentation:4 | 9 * indentation:4 |
10 * | 10 * |
11 * Modification history | 11 * Modification history |
12 * Date Name Comments | 12 * Date Name Comments |
13 * 10/11/2001 Doug Ported from ICU4J | 13 * 10/11/2001 Doug Ported from ICU4J |
(...skipping 11 matching lines...) Expand all Loading... |
25 #include "unicode/utypes.h" | 25 #include "unicode/utypes.h" |
26 #include "unicode/decimfmt.h" | 26 #include "unicode/decimfmt.h" |
27 #include "nfrs.h" | 27 #include "nfrs.h" |
28 #include <float.h> | 28 #include <float.h> |
29 | 29 |
30 U_NAMESPACE_BEGIN | 30 U_NAMESPACE_BEGIN |
31 | 31 |
32 class NFSubstitution : public UObject { | 32 class NFSubstitution : public UObject { |
33 int32_t pos; | 33 int32_t pos; |
34 const NFRuleSet* ruleSet; | 34 const NFRuleSet* ruleSet; |
35 const DecimalFormat* numberFormat; | 35 DecimalFormat* numberFormat; |
36 | 36 |
37 protected: | 37 protected: |
38 NFSubstitution(int32_t pos, | 38 NFSubstitution(int32_t pos, |
39 const NFRuleSet* ruleSet, | 39 const NFRuleSet* ruleSet, |
40 const RuleBasedNumberFormat* rbnf, | |
41 const UnicodeString& description, | 40 const UnicodeString& description, |
42 UErrorCode& status); | 41 UErrorCode& status); |
43 | 42 |
44 /** | 43 /** |
45 * Get the Ruleset of the object. | 44 * Get the Ruleset of the object. |
46 * @return the Ruleset of the object. | 45 * @return the Ruleset of the object. |
47 */ | 46 */ |
48 const NFRuleSet* getRuleSet() const { return ruleSet; } | 47 const NFRuleSet* getRuleSet() const { return ruleSet; } |
49 | 48 |
50 /** | 49 /** |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 * @param exponent The exponent of the divisor | 90 * @param exponent The exponent of the divisor |
92 */ | 91 */ |
93 virtual void setDivisor(int32_t radix, int32_t exponent, UErrorCode& status)
; | 92 virtual void setDivisor(int32_t radix, int32_t exponent, UErrorCode& status)
; |
94 | 93 |
95 /** | 94 /** |
96 * Replaces result with the string describing the substitution. | 95 * Replaces result with the string describing the substitution. |
97 * @param result Output param which will receive the string. | 96 * @param result Output param which will receive the string. |
98 */ | 97 */ |
99 virtual void toString(UnicodeString& result) const; | 98 virtual void toString(UnicodeString& result) const; |
100 | 99 |
| 100 void setDecimalFormatSymbols(const DecimalFormatSymbols &newSymbols, UErrorC
ode& status); |
| 101 |
101 //----------------------------------------------------------------------- | 102 //----------------------------------------------------------------------- |
102 // formatting | 103 // formatting |
103 //----------------------------------------------------------------------- | 104 //----------------------------------------------------------------------- |
104 | 105 |
105 /** | 106 /** |
106 * Performs a mathematical operation on the number, formats it using | 107 * Performs a mathematical operation on the number, formats it using |
107 * either ruleSet or decimalFormat, and inserts the result into | 108 * either ruleSet or decimalFormat, and inserts the result into |
108 * toInsertInto. | 109 * toInsertInto. |
109 * @param number The number being formatted. | 110 * @param number The number being formatted. |
110 * @param toInsertInto The string we insert the result into | 111 * @param toInsertInto The string we insert the result into |
111 * @param pos The position in toInsertInto where the owning rule's | 112 * @param pos The position in toInsertInto where the owning rule's |
112 * rule text begins (this value is added to this substitution's | 113 * rule text begins (this value is added to this substitution's |
113 * position to determine exactly where to insert the new text) | 114 * position to determine exactly where to insert the new text) |
114 */ | 115 */ |
115 virtual void doSubstitution(int64_t number, UnicodeString& toInsertInto, int
32_t pos, UErrorCode& status) const; | 116 virtual void doSubstitution(int64_t number, UnicodeString& toInsertInto, int
32_t pos, int32_t recursionCount, UErrorCode& status) const; |
116 | 117 |
117 /** | 118 /** |
118 * Performs a mathematical operation on the number, formats it using | 119 * Performs a mathematical operation on the number, formats it using |
119 * either ruleSet or decimalFormat, and inserts the result into | 120 * either ruleSet or decimalFormat, and inserts the result into |
120 * toInsertInto. | 121 * toInsertInto. |
121 * @param number The number being formatted. | 122 * @param number The number being formatted. |
122 * @param toInsertInto The string we insert the result into | 123 * @param toInsertInto The string we insert the result into |
123 * @param pos The position in toInsertInto where the owning rule's | 124 * @param pos The position in toInsertInto where the owning rule's |
124 * rule text begins (this value is added to this substitution's | 125 * rule text begins (this value is added to this substitution's |
125 * position to determine exactly where to insert the new text) | 126 * position to determine exactly where to insert the new text) |
126 */ | 127 */ |
127 virtual void doSubstitution(double number, UnicodeString& toInsertInto, int3
2_t pos, UErrorCode& status) const; | 128 virtual void doSubstitution(double number, UnicodeString& toInsertInto, int3
2_t pos, int32_t recursionCount, UErrorCode& status) const; |
128 | 129 |
129 protected: | 130 protected: |
130 /** | 131 /** |
131 * Subclasses override this function to perform some kind of | 132 * Subclasses override this function to perform some kind of |
132 * mathematical operation on the number. The result of this operation | 133 * mathematical operation on the number. The result of this operation |
133 * is formatted using the rule set or DecimalFormat that this | 134 * is formatted using the rule set or DecimalFormat that this |
134 * substitution refers to, and the result is inserted into the result | 135 * substitution refers to, and the result is inserted into the result |
135 * string. | 136 * string. |
136 * @param The number being formatted | 137 * @param The number being formatted |
137 * @return The result of performing the opreration on the number | 138 * @return The result of performing the opreration on the number |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 int32_t getPos() const { return pos; } | 227 int32_t getPos() const { return pos; } |
227 | 228 |
228 /** | 229 /** |
229 * Returns the character used in the textual representation of | 230 * Returns the character used in the textual representation of |
230 * substitutions of this type. Used by toString(). | 231 * substitutions of this type. Used by toString(). |
231 * @return This substitution's token character. | 232 * @return This substitution's token character. |
232 */ | 233 */ |
233 virtual UChar tokenChar() const = 0; | 234 virtual UChar tokenChar() const = 0; |
234 | 235 |
235 /** | 236 /** |
236 * Returns true if this is a null substitution. (We didn't do this | |
237 * with instanceof partially because it causes source files to | |
238 * proliferate and partially because we have to port this to C++.) | |
239 * @return true if this object is an instance of NullSubstitution | |
240 */ | |
241 virtual UBool isNullSubstitution() const; | |
242 | |
243 /** | |
244 * Returns true if this is a modulus substitution. (We didn't do this | 237 * Returns true if this is a modulus substitution. (We didn't do this |
245 * with instanceof partially because it causes source files to | 238 * with instanceof partially because it causes source files to |
246 * proliferate and partially because we have to port this to C++.) | 239 * proliferate and partially because we have to port this to C++.) |
247 * @return true if this object is an instance of ModulusSubstitution | 240 * @return true if this object is an instance of ModulusSubstitution |
248 */ | 241 */ |
249 virtual UBool isModulusSubstitution() const; | 242 virtual UBool isModulusSubstitution() const; |
250 | 243 |
251 private: | 244 private: |
252 NFSubstitution(const NFSubstitution &other); // forbid copying of this class | 245 NFSubstitution(const NFSubstitution &other); // forbid copying of this class |
253 NFSubstitution &operator=(const NFSubstitution &other); // forbid copying of
this class | 246 NFSubstitution &operator=(const NFSubstitution &other); // forbid copying of
this class |
254 | 247 |
255 public: | 248 public: |
256 static UClassID getStaticClassID(void); | 249 static UClassID getStaticClassID(void); |
257 virtual UClassID getDynamicClassID(void) const; | 250 virtual UClassID getDynamicClassID(void) const; |
258 }; | 251 }; |
259 | 252 |
260 U_NAMESPACE_END | 253 U_NAMESPACE_END |
261 | 254 |
262 /* U_HAVE_RBNF */ | 255 /* U_HAVE_RBNF */ |
263 #endif | 256 #endif |
264 | 257 |
265 // NFSUBS_H | 258 // NFSUBS_H |
266 #endif | 259 #endif |
OLD | NEW |