]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/unicode/rbnf.h
ICU-64260.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / rbnf.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 * Copyright (C) 1997-2015, International Business Machines Corporation and others.
6 * All Rights Reserved.
7 *******************************************************************************
8 */
9
10 #ifndef RBNF_H
11 #define RBNF_H
12
13 #include "unicode/utypes.h"
14
15 /**
16 * \file
17 * \brief C++ API: Rule Based Number Format
18 */
19
20 /**
21 * \def U_HAVE_RBNF
22 * This will be 0 if RBNF support is not included in ICU
23 * and 1 if it is.
24 *
25 * @stable ICU 2.4
26 */
27 #if UCONFIG_NO_FORMATTING
28 #define U_HAVE_RBNF 0
29 #else
30 #define U_HAVE_RBNF 1
31
32 #include "unicode/dcfmtsym.h"
33 #include "unicode/fmtable.h"
34 #include "unicode/locid.h"
35 #include "unicode/numfmt.h"
36 #include "unicode/unistr.h"
37 #include "unicode/strenum.h"
38 #include "unicode/brkiter.h"
39 #include "unicode/upluralrules.h"
40
41 #if U_SHOW_CPLUSPLUS_API
42 U_NAMESPACE_BEGIN
43
44 class NFRule;
45 class NFRuleSet;
46 class LocalizationInfo;
47 class PluralFormat;
48 class RuleBasedCollator;
49
50 /**
51 * Tags for the predefined rulesets.
52 *
53 * @stable ICU 2.2
54 */
55 enum URBNFRuleSetTag {
56 URBNF_SPELLOUT,
57 URBNF_ORDINAL,
58 URBNF_DURATION,
59 URBNF_NUMBERING_SYSTEM,
60 #ifndef U_HIDE_DEPRECATED_API
61 /**
62 * One more than the highest normal URBNFRuleSetTag value.
63 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
64 */
65 URBNF_COUNT
66 #endif // U_HIDE_DEPRECATED_API
67 };
68
69 /**
70 * The RuleBasedNumberFormat class formats numbers according to a set of rules. This number formatter is
71 * typically used for spelling out numeric values in words (e.g., 25,3476 as
72 * "twenty-five thousand three hundred seventy-six" or "vingt-cinq mille trois
73 * cents soixante-seize" or
74 * "fünfundzwanzigtausenddreihundertsechsundsiebzig"), but can also be used for
75 * other complicated formatting tasks, such as formatting a number of seconds as hours,
76 * minutes and seconds (e.g., 3,730 as "1:02:10").
77 *
78 * <p>The resources contain three predefined formatters for each locale: spellout, which
79 * spells out a value in words (123 is &quot;one hundred twenty-three&quot;); ordinal, which
80 * appends an ordinal suffix to the end of a numeral (123 is &quot;123rd&quot;); and
81 * duration, which shows a duration in seconds as hours, minutes, and seconds (123 is
82 * &quot;2:03&quot;).&nbsp; The client can also define more specialized <tt>RuleBasedNumberFormat</tt>s
83 * by supplying programmer-defined rule sets.</p>
84 *
85 * <p>The behavior of a <tt>RuleBasedNumberFormat</tt> is specified by a textual description
86 * that is either passed to the constructor as a <tt>String</tt> or loaded from a resource
87 * bundle. In its simplest form, the description consists of a semicolon-delimited list of <em>rules.</em>
88 * Each rule has a string of output text and a value or range of values it is applicable to.
89 * In a typical spellout rule set, the first twenty rules are the words for the numbers from
90 * 0 to 19:</p>
91 *
92 * <pre>zero; one; two; three; four; five; six; seven; eight; nine;
93 * ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen; seventeen; eighteen; nineteen;</pre>
94 *
95 * <p>For larger numbers, we can use the preceding set of rules to format the ones place, and
96 * we only have to supply the words for the multiples of 10:</p>
97 *
98 * <pre> 20: twenty[-&gt;&gt;];
99 * 30: thirty[-&gt;&gt;];
100 * 40: forty[-&gt;&gt;];
101 * 50: fifty[-&gt;&gt;];
102 * 60: sixty[-&gt;&gt;];
103 * 70: seventy[-&gt;&gt;];
104 * 80: eighty[-&gt;&gt;];
105 * 90: ninety[-&gt;&gt;];</pre>
106 *
107 * <p>In these rules, the <em>base value</em> is spelled out explicitly and set off from the
108 * rule's output text with a colon. The rules are in a sorted list, and a rule is applicable
109 * to all numbers from its own base value to one less than the next rule's base value. The
110 * &quot;&gt;&gt;&quot; token is called a <em>substitution</em> and tells the fomatter to
111 * isolate the number's ones digit, format it using this same set of rules, and place the
112 * result at the position of the &quot;&gt;&gt;&quot; token. Text in brackets is omitted if
113 * the number being formatted is an even multiple of 10 (the hyphen is a literal hyphen; 24
114 * is &quot;twenty-four,&quot; not &quot;twenty four&quot;).</p>
115 *
116 * <p>For even larger numbers, we can actually look up several parts of the number in the
117 * list:</p>
118 *
119 * <pre>100: &lt;&lt; hundred[ &gt;&gt;];</pre>
120 *
121 * <p>The &quot;&lt;&lt;&quot; represents a new kind of substitution. The &lt;&lt; isolates
122 * the hundreds digit (and any digits to its left), formats it using this same rule set, and
123 * places the result where the &quot;&lt;&lt;&quot; was. Notice also that the meaning of
124 * &gt;&gt; has changed: it now refers to both the tens and the ones digits. The meaning of
125 * both substitutions depends on the rule's base value. The base value determines the rule's <em>divisor,</em>
126 * which is the highest power of 10 that is less than or equal to the base value (the user
127 * can change this). To fill in the substitutions, the formatter divides the number being
128 * formatted by the divisor. The integral quotient is used to fill in the &lt;&lt;
129 * substitution, and the remainder is used to fill in the &gt;&gt; substitution. The meaning
130 * of the brackets changes similarly: text in brackets is omitted if the value being
131 * formatted is an even multiple of the rule's divisor. The rules are applied recursively, so
132 * if a substitution is filled in with text that includes another substitution, that
133 * substitution is also filled in.</p>
134 *
135 * <p>This rule covers values up to 999, at which point we add another rule:</p>
136 *
137 * <pre>1000: &lt;&lt; thousand[ &gt;&gt;];</pre>
138 *
139 * <p>Again, the meanings of the brackets and substitution tokens shift because the rule's
140 * base value is a higher power of 10, changing the rule's divisor. This rule can actually be
141 * used all the way up to 999,999. This allows us to finish out the rules as follows:</p>
142 *
143 * <pre> 1,000,000: &lt;&lt; million[ &gt;&gt;];
144 * 1,000,000,000: &lt;&lt; billion[ &gt;&gt;];
145 * 1,000,000,000,000: &lt;&lt; trillion[ &gt;&gt;];
146 * 1,000,000,000,000,000: OUT OF RANGE!;</pre>
147 *
148 * <p>Commas, periods, and spaces can be used in the base values to improve legibility and
149 * are ignored by the rule parser. The last rule in the list is customarily treated as an
150 * &quot;overflow rule,&quot; applying to everything from its base value on up, and often (as
151 * in this example) being used to print out an error message or default representation.
152 * Notice also that the size of the major groupings in large numbers is controlled by the
153 * spacing of the rules: because in English we group numbers by thousand, the higher rules
154 * are separated from each other by a factor of 1,000.</p>
155 *
156 * <p>To see how these rules actually work in practice, consider the following example:
157 * Formatting 25,430 with this rule set would work like this:</p>
158 *
159 * <table border="0" width="100%">
160 * <tr>
161 * <td><strong>&lt;&lt; thousand &gt;&gt;</strong></td>
162 * <td>[the rule whose base value is 1,000 is applicable to 25,340]</td>
163 * </tr>
164 * <tr>
165 * <td><strong>twenty-&gt;&gt;</strong> thousand &gt;&gt;</td>
166 * <td>[25,340 over 1,000 is 25. The rule for 20 applies.]</td>
167 * </tr>
168 * <tr>
169 * <td>twenty-<strong>five</strong> thousand &gt;&gt;</td>
170 * <td>[25 mod 10 is 5. The rule for 5 is &quot;five.&quot;</td>
171 * </tr>
172 * <tr>
173 * <td>twenty-five thousand <strong>&lt;&lt; hundred &gt;&gt;</strong></td>
174 * <td>[25,340 mod 1,000 is 340. The rule for 100 applies.]</td>
175 * </tr>
176 * <tr>
177 * <td>twenty-five thousand <strong>three</strong> hundred &gt;&gt;</td>
178 * <td>[340 over 100 is 3. The rule for 3 is &quot;three.&quot;]</td>
179 * </tr>
180 * <tr>
181 * <td>twenty-five thousand three hundred <strong>forty</strong></td>
182 * <td>[340 mod 100 is 40. The rule for 40 applies. Since 40 divides
183 * evenly by 10, the hyphen and substitution in the brackets are omitted.]</td>
184 * </tr>
185 * </table>
186 *
187 * <p>The above syntax suffices only to format positive integers. To format negative numbers,
188 * we add a special rule:</p>
189 *
190 * <pre>-x: minus &gt;&gt;;</pre>
191 *
192 * <p>This is called a <em>negative-number rule,</em> and is identified by &quot;-x&quot;
193 * where the base value would be. This rule is used to format all negative numbers. the
194 * &gt;&gt; token here means &quot;find the number's absolute value, format it with these
195 * rules, and put the result here.&quot;</p>
196 *
197 * <p>We also add a special rule called a <em>fraction rule </em>for numbers with fractional
198 * parts:</p>
199 *
200 * <pre>x.x: &lt;&lt; point &gt;&gt;;</pre>
201 *
202 * <p>This rule is used for all positive non-integers (negative non-integers pass through the
203 * negative-number rule first and then through this rule). Here, the &lt;&lt; token refers to
204 * the number's integral part, and the &gt;&gt; to the number's fractional part. The
205 * fractional part is formatted as a series of single-digit numbers (e.g., 123.456 would be
206 * formatted as &quot;one hundred twenty-three point four five six&quot;).</p>
207 *
208 * <p>To see how this rule syntax is applied to various languages, examine the resource data.</p>
209 *
210 * <p>There is actually much more flexibility built into the rule language than the
211 * description above shows. A formatter may own multiple rule sets, which can be selected by
212 * the caller, and which can use each other to fill in their substitutions. Substitutions can
213 * also be filled in with digits, using a DecimalFormat object. There is syntax that can be
214 * used to alter a rule's divisor in various ways. And there is provision for much more
215 * flexible fraction handling. A complete description of the rule syntax follows:</p>
216 *
217 * <hr>
218 *
219 * <p>The description of a <tt>RuleBasedNumberFormat</tt>'s behavior consists of one or more <em>rule
220 * sets.</em> Each rule set consists of a name, a colon, and a list of <em>rules.</em> A rule
221 * set name must begin with a % sign. Rule sets with names that begin with a single % sign
222 * are <em>public:</em> the caller can specify that they be used to format and parse numbers.
223 * Rule sets with names that begin with %% are <em>private:</em> they exist only for the use
224 * of other rule sets. If a formatter only has one rule set, the name may be omitted.</p>
225 *
226 * <p>The user can also specify a special &quot;rule set&quot; named <tt>%%lenient-parse</tt>.
227 * The body of <tt>%%lenient-parse</tt> isn't a set of number-formatting rules, but a <tt>RuleBasedCollator</tt>
228 * description which is used to define equivalences for lenient parsing. For more information
229 * on the syntax, see <tt>RuleBasedCollator</tt>. For more information on lenient parsing,
230 * see <tt>setLenientParse()</tt>. <em>Note:</em> symbols that have syntactic meaning
231 * in collation rules, such as '&amp;', have no particular meaning when appearing outside
232 * of the <tt>lenient-parse</tt> rule set.</p>
233 *
234 * <p>The body of a rule set consists of an ordered, semicolon-delimited list of <em>rules.</em>
235 * Internally, every rule has a base value, a divisor, rule text, and zero, one, or two <em>substitutions.</em>
236 * These parameters are controlled by the description syntax, which consists of a <em>rule
237 * descriptor,</em> a colon, and a <em>rule body.</em></p>
238 *
239 * <p>A rule descriptor can take one of the following forms (text in <em>italics</em> is the
240 * name of a token):</p>
241 *
242 * <table border="0" width="100%">
243 * <tr>
244 * <td><em>bv</em>:</td>
245 * <td><em>bv</em> specifies the rule's base value. <em>bv</em> is a decimal
246 * number expressed using ASCII digits. <em>bv</em> may contain spaces, period, and commas,
247 * which are ignored. The rule's divisor is the highest power of 10 less than or equal to
248 * the base value.</td>
249 * </tr>
250 * <tr>
251 * <td><em>bv</em>/<em>rad</em>:</td>
252 * <td><em>bv</em> specifies the rule's base value. The rule's divisor is the
253 * highest power of <em>rad</em> less than or equal to the base value.</td>
254 * </tr>
255 * <tr>
256 * <td><em>bv</em>&gt;:</td>
257 * <td><em>bv</em> specifies the rule's base value. To calculate the divisor,
258 * let the radix be 10, and the exponent be the highest exponent of the radix that yields a
259 * result less than or equal to the base value. Every &gt; character after the base value
260 * decreases the exponent by 1. If the exponent is positive or 0, the divisor is the radix
261 * raised to the power of the exponent; otherwise, the divisor is 1.</td>
262 * </tr>
263 * <tr>
264 * <td><em>bv</em>/<em>rad</em>&gt;:</td>
265 * <td><em>bv</em> specifies the rule's base value. To calculate the divisor,
266 * let the radix be <em>rad</em>, and the exponent be the highest exponent of the radix that
267 * yields a result less than or equal to the base value. Every &gt; character after the radix
268 * decreases the exponent by 1. If the exponent is positive or 0, the divisor is the radix
269 * raised to the power of the exponent; otherwise, the divisor is 1.</td>
270 * </tr>
271 * <tr>
272 * <td>-x:</td>
273 * <td>The rule is a negative-number rule.</td>
274 * </tr>
275 * <tr>
276 * <td>x.x:</td>
277 * <td>The rule is an <em>improper fraction rule</em>. If the full stop in
278 * the middle of the rule name is replaced with the decimal point
279 * that is used in the language or DecimalFormatSymbols, then that rule will
280 * have precedence when formatting and parsing this rule. For example, some
281 * languages use the comma, and can thus be written as x,x instead. For example,
282 * you can use "x.x: &lt;&lt; point &gt;&gt;;x,x: &lt;&lt; comma &gt;&gt;;" to
283 * handle the decimal point that matches the language's natural spelling of
284 * the punctuation of either the full stop or comma.</td>
285 * </tr>
286 * <tr>
287 * <td>0.x:</td>
288 * <td>The rule is a <em>proper fraction rule</em>. If the full stop in
289 * the middle of the rule name is replaced with the decimal point
290 * that is used in the language or DecimalFormatSymbols, then that rule will
291 * have precedence when formatting and parsing this rule. For example, some
292 * languages use the comma, and can thus be written as 0,x instead. For example,
293 * you can use "0.x: point &gt;&gt;;0,x: comma &gt;&gt;;" to
294 * handle the decimal point that matches the language's natural spelling of
295 * the punctuation of either the full stop or comma.</td>
296 * </tr>
297 * <tr>
298 * <td>x.0:</td>
299 * <td>The rule is a <em>master rule</em>. If the full stop in
300 * the middle of the rule name is replaced with the decimal point
301 * that is used in the language or DecimalFormatSymbols, then that rule will
302 * have precedence when formatting and parsing this rule. For example, some
303 * languages use the comma, and can thus be written as x,0 instead. For example,
304 * you can use "x.0: &lt;&lt; point;x,0: &lt;&lt; comma;" to
305 * handle the decimal point that matches the language's natural spelling of
306 * the punctuation of either the full stop or comma.</td>
307 * </tr>
308 * <tr>
309 * <td>Inf:</td>
310 * <td>The rule for infinity.</td>
311 * </tr>
312 * <tr>
313 * <td>NaN:</td>
314 * <td>The rule for an IEEE 754 NaN (not a number).</td>
315 * </tr>
316 * <tr>
317 * <td><em>nothing</em></td>
318 * <td>If the rule's rule descriptor is left out, the base value is one plus the
319 * preceding rule's base value (or zero if this is the first rule in the list) in a normal
320 * rule set.&nbsp; In a fraction rule set, the base value is the same as the preceding rule's
321 * base value.</td>
322 * </tr>
323 * </table>
324 *
325 * <p>A rule set may be either a regular rule set or a <em>fraction rule set,</em> depending
326 * on whether it is used to format a number's integral part (or the whole number) or a
327 * number's fractional part. Using a rule set to format a rule's fractional part makes it a
328 * fraction rule set.</p>
329 *
330 * <p>Which rule is used to format a number is defined according to one of the following
331 * algorithms: If the rule set is a regular rule set, do the following:
332 *
333 * <ul>
334 * <li>If the rule set includes a master rule (and the number was passed in as a <tt>double</tt>),
335 * use the master rule.&nbsp; (If the number being formatted was passed in as a <tt>long</tt>,
336 * the master rule is ignored.)</li>
337 * <li>If the number is negative, use the negative-number rule.</li>
338 * <li>If the number has a fractional part and is greater than 1, use the improper fraction
339 * rule.</li>
340 * <li>If the number has a fractional part and is between 0 and 1, use the proper fraction
341 * rule.</li>
342 * <li>Binary-search the rule list for the rule with the highest base value less than or equal
343 * to the number. If that rule has two substitutions, its base value is not an even multiple
344 * of its divisor, and the number <em>is</em> an even multiple of the rule's divisor, use the
345 * rule that precedes it in the rule list. Otherwise, use the rule itself.</li>
346 * </ul>
347 *
348 * <p>If the rule set is a fraction rule set, do the following:
349 *
350 * <ul>
351 * <li>Ignore negative-number and fraction rules.</li>
352 * <li>For each rule in the list, multiply the number being formatted (which will always be
353 * between 0 and 1) by the rule's base value. Keep track of the distance between the result
354 * the nearest integer.</li>
355 * <li>Use the rule that produced the result closest to zero in the above calculation. In the
356 * event of a tie or a direct hit, use the first matching rule encountered. (The idea here is
357 * to try each rule's base value as a possible denominator of a fraction. Whichever
358 * denominator produces the fraction closest in value to the number being formatted wins.) If
359 * the rule following the matching rule has the same base value, use it if the numerator of
360 * the fraction is anything other than 1; if the numerator is 1, use the original matching
361 * rule. (This is to allow singular and plural forms of the rule text without a lot of extra
362 * hassle.)</li>
363 * </ul>
364 *
365 * <p>A rule's body consists of a string of characters terminated by a semicolon. The rule
366 * may include zero, one, or two <em>substitution tokens,</em> and a range of text in
367 * brackets. The brackets denote optional text (and may also include one or both
368 * substitutions). The exact meanings of the substitution tokens, and under what conditions
369 * optional text is omitted, depend on the syntax of the substitution token and the context.
370 * The rest of the text in a rule body is literal text that is output when the rule matches
371 * the number being formatted.</p>
372 *
373 * <p>A substitution token begins and ends with a <em>token character.</em> The token
374 * character and the context together specify a mathematical operation to be performed on the
375 * number being formatted. An optional <em>substitution descriptor </em>specifies how the
376 * value resulting from that operation is used to fill in the substitution. The position of
377 * the substitution token in the rule body specifies the location of the resultant text in
378 * the original rule text.</p>
379 *
380 * <p>The meanings of the substitution token characters are as follows:</p>
381 *
382 * <table border="0" width="100%">
383 * <tr>
384 * <td>&gt;&gt;</td>
385 * <td>in normal rule</td>
386 * <td>Divide the number by the rule's divisor and format the remainder</td>
387 * </tr>
388 * <tr>
389 * <td></td>
390 * <td>in negative-number rule</td>
391 * <td>Find the absolute value of the number and format the result</td>
392 * </tr>
393 * <tr>
394 * <td></td>
395 * <td>in fraction or master rule</td>
396 * <td>Isolate the number's fractional part and format it.</td>
397 * </tr>
398 * <tr>
399 * <td></td>
400 * <td>in rule in fraction rule set</td>
401 * <td>Not allowed.</td>
402 * </tr>
403 * <tr>
404 * <td>&gt;&gt;&gt;</td>
405 * <td>in normal rule</td>
406 * <td>Divide the number by the rule's divisor and format the remainder,
407 * but bypass the normal rule-selection process and just use the
408 * rule that precedes this one in this rule list.</td>
409 * </tr>
410 * <tr>
411 * <td></td>
412 * <td>in all other rules</td>
413 * <td>Not allowed.</td>
414 * </tr>
415 * <tr>
416 * <td>&lt;&lt;</td>
417 * <td>in normal rule</td>
418 * <td>Divide the number by the rule's divisor and format the quotient</td>
419 * </tr>
420 * <tr>
421 * <td></td>
422 * <td>in negative-number rule</td>
423 * <td>Not allowed.</td>
424 * </tr>
425 * <tr>
426 * <td></td>
427 * <td>in fraction or master rule</td>
428 * <td>Isolate the number's integral part and format it.</td>
429 * </tr>
430 * <tr>
431 * <td></td>
432 * <td>in rule in fraction rule set</td>
433 * <td>Multiply the number by the rule's base value and format the result.</td>
434 * </tr>
435 * <tr>
436 * <td>==</td>
437 * <td>in all rule sets</td>
438 * <td>Format the number unchanged</td>
439 * </tr>
440 * <tr>
441 * <td>[]</td>
442 * <td>in normal rule</td>
443 * <td>Omit the optional text if the number is an even multiple of the rule's divisor</td>
444 * </tr>
445 * <tr>
446 * <td></td>
447 * <td>in negative-number rule</td>
448 * <td>Not allowed.</td>
449 * </tr>
450 * <tr>
451 * <td></td>
452 * <td>in improper-fraction rule</td>
453 * <td>Omit the optional text if the number is between 0 and 1 (same as specifying both an
454 * x.x rule and a 0.x rule)</td>
455 * </tr>
456 * <tr>
457 * <td></td>
458 * <td>in master rule</td>
459 * <td>Omit the optional text if the number is an integer (same as specifying both an x.x
460 * rule and an x.0 rule)</td>
461 * </tr>
462 * <tr>
463 * <td></td>
464 * <td>in proper-fraction rule</td>
465 * <td>Not allowed.</td>
466 * </tr>
467 * <tr>
468 * <td></td>
469 * <td>in rule in fraction rule set</td>
470 * <td>Omit the optional text if multiplying the number by the rule's base value yields 1.</td>
471 * </tr>
472 * <tr>
473 * <td width="37">$(cardinal,<i>plural syntax</i>)$</td>
474 * <td width="23"></td>
475 * <td width="165" valign="top">in all rule sets</td>
476 * <td>This provides the ability to choose a word based on the number divided by the radix to the power of the
477 * exponent of the base value for the specified locale, which is normally equivalent to the &lt;&lt; value.
478 * This uses the cardinal plural rules from PluralFormat. All strings used in the plural format are treated
479 * as the same base value for parsing.</td>
480 * </tr>
481 * <tr>
482 * <td width="37">$(ordinal,<i>plural syntax</i>)$</td>
483 * <td width="23"></td>
484 * <td width="165" valign="top">in all rule sets</td>
485 * <td>This provides the ability to choose a word based on the number divided by the radix to the power of the
486 * exponent of the base value for the specified locale, which is normally equivalent to the &lt;&lt; value.
487 * This uses the ordinal plural rules from PluralFormat. All strings used in the plural format are treated
488 * as the same base value for parsing.</td>
489 * </tr>
490 * </table>
491 *
492 * <p>The substitution descriptor (i.e., the text between the token characters) may take one
493 * of three forms:</p>
494 *
495 * <table border="0" width="100%">
496 * <tr>
497 * <td>a rule set name</td>
498 * <td>Perform the mathematical operation on the number, and format the result using the
499 * named rule set.</td>
500 * </tr>
501 * <tr>
502 * <td>a DecimalFormat pattern</td>
503 * <td>Perform the mathematical operation on the number, and format the result using a
504 * DecimalFormat with the specified pattern.&nbsp; The pattern must begin with 0 or #.</td>
505 * </tr>
506 * <tr>
507 * <td>nothing</td>
508 * <td>Perform the mathematical operation on the number, and format the result using the rule
509 * set containing the current rule, except:
510 * <ul>
511 * <li>You can't have an empty substitution descriptor with a == substitution.</li>
512 * <li>If you omit the substitution descriptor in a &gt;&gt; substitution in a fraction rule,
513 * format the result one digit at a time using the rule set containing the current rule.</li>
514 * <li>If you omit the substitution descriptor in a &lt;&lt; substitution in a rule in a
515 * fraction rule set, format the result using the default rule set for this formatter.</li>
516 * </ul>
517 * </td>
518 * </tr>
519 * </table>
520 *
521 * <p>Whitespace is ignored between a rule set name and a rule set body, between a rule
522 * descriptor and a rule body, or between rules. If a rule body begins with an apostrophe,
523 * the apostrophe is ignored, but all text after it becomes significant (this is how you can
524 * have a rule's rule text begin with whitespace). There is no escape function: the semicolon
525 * is not allowed in rule set names or in rule text, and the colon is not allowed in rule set
526 * names. The characters beginning a substitution token are always treated as the beginning
527 * of a substitution token.</p>
528 *
529 * <p>See the resource data and the demo program for annotated examples of real rule sets
530 * using these features.</p>
531 *
532 * <p><em>User subclasses are not supported.</em> While clients may write
533 * subclasses, such code will not necessarily work and will not be
534 * guaranteed to work stably from release to release.
535 *
536 * <p><b>Localizations</b></p>
537 * <p>Constructors are available that allow the specification of localizations for the
538 * public rule sets (and also allow more control over what public rule sets are available).
539 * Localization data is represented as a textual description. The description represents
540 * an array of arrays of string. The first element is an array of the public rule set names,
541 * each of these must be one of the public rule set names that appear in the rules. Only
542 * names in this array will be treated as public rule set names by the API. Each subsequent
543 * element is an array of localizations of these names. The first element of one of these
544 * subarrays is the locale name, and the remaining elements are localizations of the
545 * public rule set names, in the same order as they were listed in the first arrray.</p>
546 * <p>In the syntax, angle brackets '<', '>' are used to delimit the arrays, and comma ',' is used
547 * to separate elements of an array. Whitespace is ignored, unless quoted.</p>
548 * <p>For example:<pre>
549 * < < %foo, %bar, %baz >,
550 * < en, Foo, Bar, Baz >,
551 * < fr, 'le Foo', 'le Bar', 'le Baz' >
552 * < zh, \\u7532, \\u4e59, \\u4e19 > >
553 * </pre></p>
554 * @author Richard Gillam
555 * @see NumberFormat
556 * @see DecimalFormat
557 * @see PluralFormat
558 * @see PluralRules
559 * @stable ICU 2.0
560 */
561 class U_I18N_API RuleBasedNumberFormat : public NumberFormat {
562 public:
563
564 //-----------------------------------------------------------------------
565 // constructors
566 //-----------------------------------------------------------------------
567
568 /**
569 * Creates a RuleBasedNumberFormat that behaves according to the description
570 * passed in. The formatter uses the default locale.
571 * @param rules A description of the formatter's desired behavior.
572 * See the class documentation for a complete explanation of the description
573 * syntax.
574 * @param perror The parse error if an error was encountered.
575 * @param status The status indicating whether the constructor succeeded.
576 * @stable ICU 3.2
577 */
578 RuleBasedNumberFormat(const UnicodeString& rules, UParseError& perror, UErrorCode& status);
579
580 /**
581 * Creates a RuleBasedNumberFormat that behaves according to the description
582 * passed in. The formatter uses the default locale.
583 * <p>
584 * The localizations data provides information about the public
585 * rule sets and their localized display names for different
586 * locales. The first element in the list is an array of the names
587 * of the public rule sets. The first element in this array is
588 * the initial default ruleset. The remaining elements in the
589 * list are arrays of localizations of the names of the public
590 * rule sets. Each of these is one longer than the initial array,
591 * with the first String being the ULocale ID, and the remaining
592 * Strings being the localizations of the rule set names, in the
593 * same order as the initial array. Arrays are NULL-terminated.
594 * @param rules A description of the formatter's desired behavior.
595 * See the class documentation for a complete explanation of the description
596 * syntax.
597 * @param localizations the localization information.
598 * names in the description. These will be copied by the constructor.
599 * @param perror The parse error if an error was encountered.
600 * @param status The status indicating whether the constructor succeeded.
601 * @stable ICU 3.2
602 */
603 RuleBasedNumberFormat(const UnicodeString& rules, const UnicodeString& localizations,
604 UParseError& perror, UErrorCode& status);
605
606 /**
607 * Creates a RuleBasedNumberFormat that behaves according to the rules
608 * passed in. The formatter uses the specified locale to determine the
609 * characters to use when formatting numerals, and to define equivalences
610 * for lenient parsing.
611 * @param rules The formatter rules.
612 * See the class documentation for a complete explanation of the rule
613 * syntax.
614 * @param locale A locale that governs which characters are used for
615 * formatting values in numerals and which characters are equivalent in
616 * lenient parsing.
617 * @param perror The parse error if an error was encountered.
618 * @param status The status indicating whether the constructor succeeded.
619 * @stable ICU 2.0
620 */
621 RuleBasedNumberFormat(const UnicodeString& rules, const Locale& locale,
622 UParseError& perror, UErrorCode& status);
623
624 /**
625 * Creates a RuleBasedNumberFormat that behaves according to the description
626 * passed in. The formatter uses the default locale.
627 * <p>
628 * The localizations data provides information about the public
629 * rule sets and their localized display names for different
630 * locales. The first element in the list is an array of the names
631 * of the public rule sets. The first element in this array is
632 * the initial default ruleset. The remaining elements in the
633 * list are arrays of localizations of the names of the public
634 * rule sets. Each of these is one longer than the initial array,
635 * with the first String being the ULocale ID, and the remaining
636 * Strings being the localizations of the rule set names, in the
637 * same order as the initial array. Arrays are NULL-terminated.
638 * @param rules A description of the formatter's desired behavior.
639 * See the class documentation for a complete explanation of the description
640 * syntax.
641 * @param localizations a list of localizations for the rule set
642 * names in the description. These will be copied by the constructor.
643 * @param locale A locale that governs which characters are used for
644 * formatting values in numerals and which characters are equivalent in
645 * lenient parsing.
646 * @param perror The parse error if an error was encountered.
647 * @param status The status indicating whether the constructor succeeded.
648 * @stable ICU 3.2
649 */
650 RuleBasedNumberFormat(const UnicodeString& rules, const UnicodeString& localizations,
651 const Locale& locale, UParseError& perror, UErrorCode& status);
652
653 /**
654 * Creates a RuleBasedNumberFormat from a predefined ruleset. The selector
655 * code choosed among three possible predefined formats: spellout, ordinal,
656 * and duration.
657 * @param tag A selector code specifying which kind of formatter to create for that
658 * locale. There are four legal values: URBNF_SPELLOUT, which creates a formatter that
659 * spells out a value in words in the desired language, URBNF_ORDINAL, which attaches
660 * an ordinal suffix from the desired language to the end of a number (e.g. "123rd"),
661 * URBNF_DURATION, which formats a duration in seconds as hours, minutes, and seconds always rounding down,
662 * and URBNF_NUMBERING_SYSTEM, which is used to invoke rules for alternate numbering
663 * systems such as the Hebrew numbering system, or for Roman Numerals, etc.
664 * @param locale The locale for the formatter.
665 * @param status The status indicating whether the constructor succeeded.
666 * @stable ICU 2.0
667 */
668 RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale& locale, UErrorCode& status);
669
670 //-----------------------------------------------------------------------
671 // boilerplate
672 //-----------------------------------------------------------------------
673
674 /**
675 * Copy constructor
676 * @param rhs the object to be copied from.
677 * @stable ICU 2.6
678 */
679 RuleBasedNumberFormat(const RuleBasedNumberFormat& rhs);
680
681 /**
682 * Assignment operator
683 * @param rhs the object to be copied from.
684 * @stable ICU 2.6
685 */
686 RuleBasedNumberFormat& operator=(const RuleBasedNumberFormat& rhs);
687
688 /**
689 * Release memory allocated for a RuleBasedNumberFormat when you are finished with it.
690 * @stable ICU 2.6
691 */
692 virtual ~RuleBasedNumberFormat();
693
694 /**
695 * Clone this object polymorphically. The caller is responsible
696 * for deleting the result when done.
697 * @return A copy of the object.
698 * @stable ICU 2.6
699 */
700 virtual Format* clone(void) const;
701
702 /**
703 * Return true if the given Format objects are semantically equal.
704 * Objects of different subclasses are considered unequal.
705 * @param other the object to be compared with.
706 * @return true if the given Format objects are semantically equal.
707 * @stable ICU 2.6
708 */
709 virtual UBool operator==(const Format& other) const;
710
711 //-----------------------------------------------------------------------
712 // public API functions
713 //-----------------------------------------------------------------------
714
715 /**
716 * return the rules that were provided to the RuleBasedNumberFormat.
717 * @return the result String that was passed in
718 * @stable ICU 2.0
719 */
720 virtual UnicodeString getRules() const;
721
722 /**
723 * Return the number of public rule set names.
724 * @return the number of public rule set names.
725 * @stable ICU 2.0
726 */
727 virtual int32_t getNumberOfRuleSetNames() const;
728
729 /**
730 * Return the name of the index'th public ruleSet. If index is not valid,
731 * the function returns null.
732 * @param index the index of the ruleset
733 * @return the name of the index'th public ruleSet.
734 * @stable ICU 2.0
735 */
736 virtual UnicodeString getRuleSetName(int32_t index) const;
737
738 /**
739 * Return the number of locales for which we have localized rule set display names.
740 * @return the number of locales for which we have localized rule set display names.
741 * @stable ICU 3.2
742 */
743 virtual int32_t getNumberOfRuleSetDisplayNameLocales(void) const;
744
745 /**
746 * Return the index'th display name locale.
747 * @param index the index of the locale
748 * @param status set to a failure code when this function fails
749 * @return the locale
750 * @see #getNumberOfRuleSetDisplayNameLocales
751 * @stable ICU 3.2
752 */
753 virtual Locale getRuleSetDisplayNameLocale(int32_t index, UErrorCode& status) const;
754
755 /**
756 * Return the rule set display names for the provided locale. These are in the same order
757 * as those returned by getRuleSetName. The locale is matched against the locales for
758 * which there is display name data, using normal fallback rules. If no locale matches,
759 * the default display names are returned. (These are the internal rule set names minus
760 * the leading '%'.)
761 * @param index the index of the rule set
762 * @param locale the locale (returned by getRuleSetDisplayNameLocales) for which the localized
763 * display name is desired
764 * @return the display name for the given index, which might be bogus if there is an error
765 * @see #getRuleSetName
766 * @stable ICU 3.2
767 */
768 virtual UnicodeString getRuleSetDisplayName(int32_t index,
769 const Locale& locale = Locale::getDefault());
770
771 /**
772 * Return the rule set display name for the provided rule set and locale.
773 * The locale is matched against the locales for which there is display name data, using
774 * normal fallback rules. If no locale matches, the default display name is returned.
775 * @return the display name for the rule set
776 * @stable ICU 3.2
777 * @see #getRuleSetDisplayName
778 */
779 virtual UnicodeString getRuleSetDisplayName(const UnicodeString& ruleSetName,
780 const Locale& locale = Locale::getDefault());
781
782
783 using NumberFormat::format;
784
785 /**
786 * Formats the specified 32-bit number using the default ruleset.
787 * @param number The number to format.
788 * @param toAppendTo the string that will hold the (appended) result
789 * @param pos the fieldposition
790 * @return A textual representation of the number.
791 * @stable ICU 2.0
792 */
793 virtual UnicodeString& format(int32_t number,
794 UnicodeString& toAppendTo,
795 FieldPosition& pos) const;
796
797 /**
798 * Formats the specified 64-bit number using the default ruleset.
799 * @param number The number to format.
800 * @param toAppendTo the string that will hold the (appended) result
801 * @param pos the fieldposition
802 * @return A textual representation of the number.
803 * @stable ICU 2.1
804 */
805 virtual UnicodeString& format(int64_t number,
806 UnicodeString& toAppendTo,
807 FieldPosition& pos) const;
808 /**
809 * Formats the specified number using the default ruleset.
810 * @param number The number to format.
811 * @param toAppendTo the string that will hold the (appended) result
812 * @param pos the fieldposition
813 * @return A textual representation of the number.
814 * @stable ICU 2.0
815 */
816 virtual UnicodeString& format(double number,
817 UnicodeString& toAppendTo,
818 FieldPosition& pos) const;
819
820 /**
821 * Formats the specified number using the named ruleset.
822 * @param number The number to format.
823 * @param ruleSetName The name of the rule set to format the number with.
824 * This must be the name of a valid public rule set for this formatter.
825 * @param toAppendTo the string that will hold the (appended) result
826 * @param pos the fieldposition
827 * @param status the status
828 * @return A textual representation of the number.
829 * @stable ICU 2.0
830 */
831 virtual UnicodeString& format(int32_t number,
832 const UnicodeString& ruleSetName,
833 UnicodeString& toAppendTo,
834 FieldPosition& pos,
835 UErrorCode& status) const;
836 /**
837 * Formats the specified 64-bit number using the named ruleset.
838 * @param number The number to format.
839 * @param ruleSetName The name of the rule set to format the number with.
840 * This must be the name of a valid public rule set for this formatter.
841 * @param toAppendTo the string that will hold the (appended) result
842 * @param pos the fieldposition
843 * @param status the status
844 * @return A textual representation of the number.
845 * @stable ICU 2.1
846 */
847 virtual UnicodeString& format(int64_t number,
848 const UnicodeString& ruleSetName,
849 UnicodeString& toAppendTo,
850 FieldPosition& pos,
851 UErrorCode& status) const;
852 /**
853 * Formats the specified number using the named ruleset.
854 * @param number The number to format.
855 * @param ruleSetName The name of the rule set to format the number with.
856 * This must be the name of a valid public rule set for this formatter.
857 * @param toAppendTo the string that will hold the (appended) result
858 * @param pos the fieldposition
859 * @param status the status
860 * @return A textual representation of the number.
861 * @stable ICU 2.0
862 */
863 virtual UnicodeString& format(double number,
864 const UnicodeString& ruleSetName,
865 UnicodeString& toAppendTo,
866 FieldPosition& pos,
867 UErrorCode& status) const;
868
869 protected:
870 /**
871 * Format a decimal number.
872 * The number is a DigitList wrapper onto a floating point decimal number.
873 * The default implementation in NumberFormat converts the decimal number
874 * to a double and formats that. Subclasses of NumberFormat that want
875 * to specifically handle big decimal numbers must override this method.
876 * class DecimalFormat does so.
877 *
878 * @param number The number, a DigitList format Decimal Floating Point.
879 * @param appendTo Output parameter to receive result.
880 * Result is appended to existing contents.
881 * @param posIter On return, can be used to iterate over positions
882 * of fields generated by this format call.
883 * @param status Output param filled with success/failure status.
884 * @return Reference to 'appendTo' parameter.
885 * @internal
886 */
887 virtual UnicodeString& format(const number::impl::DecimalQuantity &number,
888 UnicodeString& appendTo,
889 FieldPositionIterator* posIter,
890 UErrorCode& status) const;
891
892 /**
893 * Format a decimal number.
894 * The number is a DigitList wrapper onto a floating point decimal number.
895 * The default implementation in NumberFormat converts the decimal number
896 * to a double and formats that. Subclasses of NumberFormat that want
897 * to specifically handle big decimal numbers must override this method.
898 * class DecimalFormat does so.
899 *
900 * @param number The number, a DigitList format Decimal Floating Point.
901 * @param appendTo Output parameter to receive result.
902 * Result is appended to existing contents.
903 * @param pos On input: an alignment field, if desired.
904 * On output: the offsets of the alignment field.
905 * @param status Output param filled with success/failure status.
906 * @return Reference to 'appendTo' parameter.
907 * @internal
908 */
909 virtual UnicodeString& format(const number::impl::DecimalQuantity &number,
910 UnicodeString& appendTo,
911 FieldPosition& pos,
912 UErrorCode& status) const;
913 public:
914
915 using NumberFormat::parse;
916
917 /**
918 * Parses the specfied string, beginning at the specified position, according
919 * to this formatter's rules. This will match the string against all of the
920 * formatter's public rule sets and return the value corresponding to the longest
921 * parseable substring. This function's behavior is affected by the lenient
922 * parse mode.
923 * @param text The string to parse
924 * @param result the result of the parse, either a double or a long.
925 * @param parsePosition On entry, contains the position of the first character
926 * in "text" to examine. On exit, has been updated to contain the position
927 * of the first character in "text" that wasn't consumed by the parse.
928 * @see #setLenient
929 * @stable ICU 2.0
930 */
931 virtual void parse(const UnicodeString& text,
932 Formattable& result,
933 ParsePosition& parsePosition) const;
934
935 #if !UCONFIG_NO_COLLATION
936
937 /**
938 * Turns lenient parse mode on and off.
939 *
940 * When in lenient parse mode, the formatter uses a Collator for parsing the text.
941 * Only primary differences are treated as significant. This means that case
942 * differences, accent differences, alternate spellings of the same letter
943 * (e.g., ae and a-umlaut in German), ignorable characters, etc. are ignored in
944 * matching the text. In many cases, numerals will be accepted in place of words
945 * or phrases as well.
946 *
947 * For example, all of the following will correctly parse as 255 in English in
948 * lenient-parse mode:
949 * <br>"two hundred fifty-five"
950 * <br>"two hundred fifty five"
951 * <br>"TWO HUNDRED FIFTY-FIVE"
952 * <br>"twohundredfiftyfive"
953 * <br>"2 hundred fifty-5"
954 *
955 * The Collator used is determined by the locale that was
956 * passed to this object on construction. The description passed to this object
957 * on construction may supply additional collation rules that are appended to the
958 * end of the default collator for the locale, enabling additional equivalences
959 * (such as adding more ignorable characters or permitting spelled-out version of
960 * symbols; see the demo program for examples).
961 *
962 * It's important to emphasize that even strict parsing is relatively lenient: it
963 * will accept some text that it won't produce as output. In English, for example,
964 * it will correctly parse "two hundred zero" and "fifteen hundred".
965 *
966 * @param enabled If true, turns lenient-parse mode on; if false, turns it off.
967 * @see RuleBasedCollator
968 * @stable ICU 2.0
969 */
970 virtual void setLenient(UBool enabled);
971
972 /**
973 * Returns true if lenient-parse mode is turned on. Lenient parsing is off
974 * by default.
975 * @return true if lenient-parse mode is turned on.
976 * @see #setLenient
977 * @stable ICU 2.0
978 */
979 virtual inline UBool isLenient(void) const;
980
981 #endif
982
983 /**
984 * Override the default rule set to use. If ruleSetName is null, reset
985 * to the initial default rule set. If the rule set is not a public rule set name,
986 * U_ILLEGAL_ARGUMENT_ERROR is returned in status.
987 * @param ruleSetName the name of the rule set, or null to reset the initial default.
988 * @param status set to failure code when a problem occurs.
989 * @stable ICU 2.6
990 */
991 virtual void setDefaultRuleSet(const UnicodeString& ruleSetName, UErrorCode& status);
992
993 /**
994 * Return the name of the current default rule set. If the current rule set is
995 * not public, returns a bogus (and empty) UnicodeString.
996 * @return the name of the current default rule set
997 * @stable ICU 3.0
998 */
999 virtual UnicodeString getDefaultRuleSetName() const;
1000
1001 /**
1002 * Set a particular UDisplayContext value in the formatter, such as
1003 * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. Note: For getContext, see
1004 * NumberFormat.
1005 * @param value The UDisplayContext value to set.
1006 * @param status Input/output status. If at entry this indicates a failure
1007 * status, the function will do nothing; otherwise this will be
1008 * updated with any new status from the function.
1009 * @stable ICU 53
1010 */
1011 virtual void setContext(UDisplayContext value, UErrorCode& status);
1012
1013 /**
1014 * Get the rounding mode.
1015 * @return A rounding mode
1016 * @stable ICU 60
1017 */
1018 virtual ERoundingMode getRoundingMode(void) const;
1019
1020 /**
1021 * Set the rounding mode.
1022 * @param roundingMode A rounding mode
1023 * @stable ICU 60
1024 */
1025 virtual void setRoundingMode(ERoundingMode roundingMode);
1026
1027 public:
1028 /**
1029 * ICU "poor man's RTTI", returns a UClassID for this class.
1030 *
1031 * @stable ICU 2.8
1032 */
1033 static UClassID U_EXPORT2 getStaticClassID(void);
1034
1035 /**
1036 * ICU "poor man's RTTI", returns a UClassID for the actual class.
1037 *
1038 * @stable ICU 2.8
1039 */
1040 virtual UClassID getDynamicClassID(void) const;
1041
1042 /**
1043 * Sets the decimal format symbols, which is generally not changed
1044 * by the programmer or user. The formatter takes ownership of
1045 * symbolsToAdopt; the client must not delete it.
1046 *
1047 * @param symbolsToAdopt DecimalFormatSymbols to be adopted.
1048 * @stable ICU 49
1049 */
1050 virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt);
1051
1052 /**
1053 * Sets the decimal format symbols, which is generally not changed
1054 * by the programmer or user. A clone of the symbols is created and
1055 * the symbols is _not_ adopted; the client is still responsible for
1056 * deleting it.
1057 *
1058 * @param symbols DecimalFormatSymbols.
1059 * @stable ICU 49
1060 */
1061 virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols);
1062
1063 private:
1064 RuleBasedNumberFormat(); // default constructor not implemented
1065
1066 // this will ref the localizations if they are not NULL
1067 // caller must deref to get adoption
1068 RuleBasedNumberFormat(const UnicodeString& description, LocalizationInfo* localizations,
1069 const Locale& locale, UParseError& perror, UErrorCode& status);
1070
1071 void init(const UnicodeString& rules, LocalizationInfo* localizations, UParseError& perror, UErrorCode& status);
1072 void initCapitalizationContextInfo(const Locale& thelocale);
1073 void dispose();
1074 void stripWhitespace(UnicodeString& src);
1075 void initDefaultRuleSet();
1076 NFRuleSet* findRuleSet(const UnicodeString& name, UErrorCode& status) const;
1077
1078 /* friend access */
1079 friend class NFSubstitution;
1080 friend class NFRule;
1081 friend class NFRuleSet;
1082 friend class FractionalPartSubstitution;
1083
1084 inline NFRuleSet * getDefaultRuleSet() const;
1085 const RuleBasedCollator * getCollator() const;
1086 DecimalFormatSymbols * initializeDecimalFormatSymbols(UErrorCode &status);
1087 const DecimalFormatSymbols * getDecimalFormatSymbols() const;
1088 NFRule * initializeDefaultInfinityRule(UErrorCode &status);
1089 const NFRule * getDefaultInfinityRule() const;
1090 NFRule * initializeDefaultNaNRule(UErrorCode &status);
1091 const NFRule * getDefaultNaNRule() const;
1092 PluralFormat *createPluralFormat(UPluralType pluralType, const UnicodeString &pattern, UErrorCode& status) const;
1093 UnicodeString& adjustForCapitalizationContext(int32_t startPos, UnicodeString& currentResult, UErrorCode& status) const;
1094 UnicodeString& format(int64_t number, NFRuleSet *ruleSet, UnicodeString& toAppendTo, UErrorCode& status) const;
1095 void format(double number, NFRuleSet& rs, UnicodeString& toAppendTo, UErrorCode& status) const;
1096
1097 private:
1098 NFRuleSet **fRuleSets;
1099 UnicodeString* ruleSetDescriptions;
1100 int32_t numRuleSets;
1101 NFRuleSet *defaultRuleSet;
1102 Locale locale;
1103 RuleBasedCollator* collator;
1104 DecimalFormatSymbols* decimalFormatSymbols;
1105 NFRule *defaultInfinityRule;
1106 NFRule *defaultNaNRule;
1107 ERoundingMode fRoundingMode;
1108 UBool lenient;
1109 UnicodeString* lenientParseRules;
1110 LocalizationInfo* localizations;
1111 UnicodeString originalDescription;
1112 UBool capitalizationInfoSet;
1113 UBool capitalizationForUIListMenu;
1114 UBool capitalizationForStandAlone;
1115 BreakIterator* capitalizationBrkIter;
1116 };
1117
1118 // ---------------
1119
1120 #if !UCONFIG_NO_COLLATION
1121
1122 inline UBool
1123 RuleBasedNumberFormat::isLenient(void) const {
1124 return lenient;
1125 }
1126
1127 #endif
1128
1129 inline NFRuleSet*
1130 RuleBasedNumberFormat::getDefaultRuleSet() const {
1131 return defaultRuleSet;
1132 }
1133
1134 U_NAMESPACE_END
1135 #endif // U_SHOW_CPLUSPLUS_API
1136
1137 /* U_HAVE_RBNF */
1138 #endif
1139
1140 /* RBNF_H */
1141 #endif