]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/unicode/decimfmt.h
ICU-64260.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / decimfmt.h
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
b75a7d8f
A
3/*
4********************************************************************************
2ca993e8 5* Copyright (C) 1997-2016, International Business Machines
b75a7d8f
A
6* Corporation and others. All Rights Reserved.
7********************************************************************************
8*
9* File DECIMFMT.H
10*
11* Modification History:
12*
13* Date Name Description
14* 02/19/97 aliu Converted from java.
15* 03/20/97 clhuang Updated per C++ implementation.
16* 04/03/97 aliu Rewrote parsing and formatting completely, and
17* cleaned up and debugged. Actually works now.
18* 04/17/97 aliu Changed DigitCount to int per code review.
19* 07/10/97 helena Made ParsePosition a class and get rid of the function
20* hiding problems.
21* 09/09/97 aliu Ported over support for exponential formats.
51004dcb
A
22* 07/20/98 stephen Changed documentation
23* 01/30/13 emmons Added Scaling methods
b75a7d8f
A
24********************************************************************************
25*/
729e4ab9 26
b75a7d8f
A
27#ifndef DECIMFMT_H
28#define DECIMFMT_H
729e4ab9 29
b75a7d8f 30#include "unicode/utypes.h"
73c04bcf 31/**
729e4ab9 32 * \file
0f5d89e8 33 * \brief C++ API: Compatibility APIs for decimal formatting.
73c04bcf 34 */
729e4ab9 35
b75a7d8f
A
36#if !UCONFIG_NO_FORMATTING
37
38#include "unicode/dcfmtsym.h"
39#include "unicode/numfmt.h"
40#include "unicode/locid.h"
729e4ab9
A
41#include "unicode/fpositer.h"
42#include "unicode/stringpiece.h"
4388f060 43#include "unicode/curramt.h"
51004dcb
A
44#include "unicode/enumset.h"
45
f3c0d7a5 46#if U_SHOW_CPLUSPLUS_API
b75a7d8f
A
47U_NAMESPACE_BEGIN
48
729e4ab9 49class CurrencyPluralInfo;
3d1f044b
A
50class CompactDecimalFormat;
51
52namespace number {
53class LocalizedNumberFormatter;
54class FormattedNumber;
55namespace impl {
56class DecimalQuantity;
57struct DecimalFormatFields;
58}
59}
60
61namespace numparse {
62namespace impl {
63class NumberParserImpl;
64}
65}
51004dcb 66
b75a7d8f 67/**
3d1f044b 68 * **IMPORTANT:** New users are strongly encouraged to see if
0f5d89e8
A
69 * numberformatter.h fits their use case. Although not deprecated, this header
70 * is provided for backwards compatibility only.
0f5d89e8 71 *
374ca955
A
72 * DecimalFormat is a concrete subclass of NumberFormat that formats decimal
73 * numbers. It has a variety of features designed to make it possible to parse
74 * and format numbers in any locale, including support for Western, Arabic, or
75 * Indic digits. It also supports different flavors of numbers, including
76 * integers ("123"), fixed-point numbers ("123.4"), scientific notation
729e4ab9
A
77 * ("1.23E4"), percentages ("12%"), and currency amounts ("$123", "USD123",
78 * "123 US dollars"). All of these flavors can be easily localized.
374ca955 79 *
3d1f044b 80 * To obtain a NumberFormat for a specific locale (including the default
374ca955
A
81 * locale) call one of NumberFormat's factory methods such as
82 * createInstance(). Do not call the DecimalFormat constructors directly, unless
83 * you know what you are doing, since the NumberFormat factory methods may
84 * return subclasses other than DecimalFormat.
85 *
3d1f044b 86 * **Example Usage**
374ca955 87 *
b75a7d8f 88 * \code
374ca955 89 * // Normally we would have a GUI with a menu for this
b75a7d8f
A
90 * int32_t locCount;
91 * const Locale* locales = NumberFormat::getAvailableLocales(locCount);
729e4ab9 92 *
b75a7d8f
A
93 * double myNumber = -1234.56;
94 * UErrorCode success = U_ZERO_ERROR;
374ca955 95 * NumberFormat* form;
729e4ab9 96 *
374ca955
A
97 * // Print out a number with the localized number, currency and percent
98 * // format for each locale.
b75a7d8f
A
99 * UnicodeString countryName;
100 * UnicodeString displayName;
101 * UnicodeString str;
102 * UnicodeString pattern;
103 * Formattable fmtable;
104 * for (int32_t j = 0; j < 3; ++j) {
105 * cout << endl << "FORMAT " << j << endl;
106 * for (int32_t i = 0; i < locCount; ++i) {
107 * if (locales[i].getCountry(countryName).size() == 0) {
108 * // skip language-only
109 * continue;
110 * }
111 * switch (j) {
374ca955 112 * case 0:
b75a7d8f
A
113 * form = NumberFormat::createInstance(locales[i], success ); break;
114 * case 1:
115 * form = NumberFormat::createCurrencyInstance(locales[i], success ); break;
374ca955 116 * default:
b75a7d8f
A
117 * form = NumberFormat::createPercentInstance(locales[i], success ); break;
118 * }
119 * if (form) {
120 * str.remove();
121 * pattern = ((DecimalFormat*)form)->toPattern(pattern);
122 * cout << locales[i].getDisplayName(displayName) << ": " << pattern;
123 * cout << " -> " << form->format(myNumber,str) << endl;
124 * form->parse(form->format(myNumber,str), fmtable, success);
729e4ab9 125 * delete form;
b75a7d8f
A
126 * }
127 * }
128 * }
129 * \endcode
3d1f044b
A
130 *
131 * **Another example use createInstance(style)**
132 *
133 * \code
134 * // Print out a number using the localized number, currency,
729e4ab9
A
135 * // percent, scientific, integer, iso currency, and plural currency
136 * // format for each locale</strong>
137 * Locale* locale = new Locale("en", "US");
138 * double myNumber = 1234.56;
139 * UErrorCode success = U_ZERO_ERROR;
140 * UnicodeString str;
141 * Formattable fmtable;
142 * for (int j=NumberFormat::kNumberStyle;
143 * j<=NumberFormat::kPluralCurrencyStyle;
144 * ++j) {
3d1f044b 145 * NumberFormat* form = NumberFormat::createInstance(locale, j, success);
729e4ab9
A
146 * str.remove();
147 * cout << "format result " << form->format(myNumber, str) << endl;
148 * format->parse(form->format(myNumber, str), fmtable, success);
3d1f044b
A
149 * delete form;
150 * }
151 * \endcode
729e4ab9 152 *
374ca955
A
153 *
154 * <p><strong>Patterns</strong>
155 *
156 * <p>A DecimalFormat consists of a <em>pattern</em> and a set of
157 * <em>symbols</em>. The pattern may be set directly using
158 * applyPattern(), or indirectly using other API methods which
159 * manipulate aspects of the pattern, such as the minimum number of integer
160 * digits. The symbols are stored in a DecimalFormatSymbols
161 * object. When using the NumberFormat factory methods, the
162 * pattern and symbols are read from ICU's locale data.
729e4ab9 163 *
374ca955
A
164 * <p><strong>Special Pattern Characters</strong>
165 *
166 * <p>Many characters in a pattern are taken literally; they are matched during
167 * parsing and output unchanged during formatting. Special characters, on the
168 * other hand, stand for other characters, strings, or classes of characters.
169 * For example, the '#' character is replaced by a localized digit. Often the
170 * replacement character is the same as the pattern character; in the U.S. locale,
171 * the ',' grouping character is replaced by ','. However, the replacement is
172 * still happening, and if the symbols are modified, the grouping character
173 * changes. Some special characters affect the behavior of the formatter by
174 * their presence; for example, if the percent character is seen, then the
175 * value is multiplied by 100 before being displayed.
176 *
177 * <p>To insert a special character in a pattern as a literal, that is, without
178 * any special meaning, the character must be quoted. There are some exceptions to
179 * this which are noted below.
180 *
181 * <p>The characters listed here are used in non-localized patterns. Localized
182 * patterns use the corresponding characters taken from this formatter's
183 * DecimalFormatSymbols object instead, and these characters lose
184 * their special status. Two exceptions are the currency sign and quote, which
185 * are not localized.
186 *
187 * <table border=0 cellspacing=3 cellpadding=0>
188 * <tr bgcolor="#ccccff">
189 * <td align=left><strong>Symbol</strong>
190 * <td align=left><strong>Location</strong>
191 * <td align=left><strong>Localized?</strong>
192 * <td align=left><strong>Meaning</strong>
193 * <tr valign=top>
194 * <td><code>0</code>
195 * <td>Number
196 * <td>Yes
197 * <td>Digit
198 * <tr valign=top bgcolor="#eeeeff">
199 * <td><code>1-9</code>
200 * <td>Number
201 * <td>Yes
202 * <td>'1' through '9' indicate rounding.
203 * <tr valign=top>
204 * <td><code>\htmlonly&#x40;\endhtmlonly</code> <!--doxygen doesn't like @-->
205 * <td>Number
206 * <td>No
207 * <td>Significant digit
208 * <tr valign=top bgcolor="#eeeeff">
209 * <td><code>#</code>
210 * <td>Number
211 * <td>Yes
212 * <td>Digit, zero shows as absent
213 * <tr valign=top>
214 * <td><code>.</code>
215 * <td>Number
216 * <td>Yes
217 * <td>Decimal separator or monetary decimal separator
218 * <tr valign=top bgcolor="#eeeeff">
219 * <td><code>-</code>
220 * <td>Number
221 * <td>Yes
222 * <td>Minus sign
223 * <tr valign=top>
224 * <td><code>,</code>
225 * <td>Number
226 * <td>Yes
227 * <td>Grouping separator
228 * <tr valign=top bgcolor="#eeeeff">
229 * <td><code>E</code>
230 * <td>Number
231 * <td>Yes
232 * <td>Separates mantissa and exponent in scientific notation.
233 * <em>Need not be quoted in prefix or suffix.</em>
234 * <tr valign=top>
235 * <td><code>+</code>
236 * <td>Exponent
237 * <td>Yes
238 * <td>Prefix positive exponents with localized plus sign.
239 * <em>Need not be quoted in prefix or suffix.</em>
240 * <tr valign=top bgcolor="#eeeeff">
241 * <td><code>;</code>
242 * <td>Subpattern boundary
243 * <td>Yes
244 * <td>Separates positive and negative subpatterns
245 * <tr valign=top>
246 * <td><code>\%</code>
247 * <td>Prefix or suffix
248 * <td>Yes
249 * <td>Multiply by 100 and show as percentage
250 * <tr valign=top bgcolor="#eeeeff">
251 * <td><code>\\u2030</code>
252 * <td>Prefix or suffix
253 * <td>Yes
254 * <td>Multiply by 1000 and show as per mille
255 * <tr valign=top>
256 * <td><code>\htmlonly&curren;\endhtmlonly</code> (<code>\\u00A4</code>)
257 * <td>Prefix or suffix
258 * <td>No
259 * <td>Currency sign, replaced by currency symbol. If
260 * doubled, replaced by international currency symbol.
729e4ab9
A
261 * If tripled, replaced by currency plural names, for example,
262 * "US dollar" or "US dollars" for America.
374ca955
A
263 * If present in a pattern, the monetary decimal separator
264 * is used instead of the decimal separator.
265 * <tr valign=top bgcolor="#eeeeff">
266 * <td><code>'</code>
267 * <td>Prefix or suffix
268 * <td>No
269 * <td>Used to quote special characters in a prefix or suffix,
270 * for example, <code>"'#'#"</code> formats 123 to
271 * <code>"#123"</code>. To create a single quote
272 * itself, use two in a row: <code>"# o''clock"</code>.
273 * <tr valign=top>
274 * <td><code>*</code>
275 * <td>Prefix or suffix boundary
276 * <td>Yes
277 * <td>Pad escape, precedes pad character
278 * </table>
279 *
3d1f044b 280 * <p>A DecimalFormat pattern contains a positive and negative
374ca955
A
281 * subpattern, for example, "#,##0.00;(#,##0.00)". Each subpattern has a
282 * prefix, a numeric part, and a suffix. If there is no explicit negative
283 * subpattern, the negative subpattern is the localized minus sign prefixed to the
284 * positive subpattern. That is, "0.00" alone is equivalent to "0.00;-0.00". If there
285 * is an explicit negative subpattern, it serves only to specify the negative
286 * prefix and suffix; the number of digits, minimal digits, and other
287 * characteristics are ignored in the negative subpattern. That means that
288 * "#,##0.0#;(#)" has precisely the same result as "#,##0.0#;(#,##0.0#)".
289 *
290 * <p>The prefixes, suffixes, and various symbols used for infinity, digits,
291 * thousands separators, decimal separators, etc. may be set to arbitrary
292 * values, and they will appear properly during formatting. However, care must
293 * be taken that the symbols and strings do not conflict, or parsing will be
294 * unreliable. For example, either the positive and negative prefixes or the
295 * suffixes must be distinct for parse() to be able
296 * to distinguish positive from negative values. Another example is that the
297 * decimal separator and thousands separator should be distinct characters, or
298 * parsing will be impossible.
299 *
300 * <p>The <em>grouping separator</em> is a character that separates clusters of
301 * integer digits to make large numbers more legible. It commonly used for
302 * thousands, but in some locales it separates ten-thousands. The <em>grouping
303 * size</em> is the number of digits between the grouping separators, such as 3
304 * for "100,000,000" or 4 for "1 0000 0000". There are actually two different
305 * grouping sizes: One used for the least significant integer digits, the
306 * <em>primary grouping size</em>, and one used for all others, the
307 * <em>secondary grouping size</em>. In most locales these are the same, but
308 * sometimes they are different. For example, if the primary grouping interval
309 * is 3, and the secondary is 2, then this corresponds to the pattern
310 * "#,##,##0", and the number 123456789 is formatted as "12,34,56,789". If a
311 * pattern contains multiple grouping separators, the interval between the last
312 * one and the end of the integer defines the primary grouping size, and the
313 * interval between the last two defines the secondary grouping size. All others
314 * are ignored, so "#,##,###,####" == "###,###,####" == "##,#,###,####".
315 *
316 * <p>Illegal patterns, such as "#.#.#" or "#.###,###", will cause
317 * DecimalFormat to set a failing UErrorCode.
318 *
319 * <p><strong>Pattern BNF</strong>
320 *
b75a7d8f 321 * <pre>
374ca955
A
322 * pattern := subpattern (';' subpattern)?
323 * subpattern := prefix? number exponent? suffix?
324 * number := (integer ('.' fraction)?) | sigDigits
325 * prefix := '\\u0000'..'\\uFFFD' - specialCharacters
326 * suffix := '\\u0000'..'\\uFFFD' - specialCharacters
327 * integer := '#'* '0'* '0'
328 * fraction := '0'* '#'*
329 * sigDigits := '#'* '@' '@'* '#'*
330 * exponent := 'E' '+'? '0'* '0'
331 * padSpec := '*' padChar
332 * padChar := '\\u0000'..'\\uFFFD' - quote
333 * &nbsp;
334 * Notation:
335 * X* 0 or more instances of X
336 * X? 0 or 1 instances of X
337 * X|Y either X or Y
338 * C..D any character from C up to D, inclusive
339 * S-T characters in S, except those in T
b75a7d8f 340 * </pre>
374ca955
A
341 * The first subpattern is for positive numbers. The second (optional)
342 * subpattern is for negative numbers.
729e4ab9 343 *
374ca955
A
344 * <p>Not indicated in the BNF syntax above:
345 *
346 * <ul><li>The grouping separator ',' can occur inside the integer and
347 * sigDigits elements, between any two pattern characters of that
348 * element, as long as the integer or sigDigits element is not
349 * followed by the exponent element.
350 *
351 * <li>Two grouping intervals are recognized: That between the
352 * decimal point and the first grouping symbol, and that
353 * between the first and second grouping symbols. These
354 * intervals are identical in most locales, but in some
355 * locales they differ. For example, the pattern
356 * &quot;#,##,###&quot; formats the number 123456789 as
357 * &quot;12,34,56,789&quot;.</li>
729e4ab9 358 *
374ca955
A
359 * <li>The pad specifier <code>padSpec</code> may appear before the prefix,
360 * after the prefix, before the suffix, after the suffix, or not at all.
361 *
362 * <li>In place of '0', the digits '1' through '9' may be used to
363 * indicate a rounding increment.
364 * </ul>
365 *
366 * <p><strong>Parsing</strong>
367 *
368 * <p>DecimalFormat parses all Unicode characters that represent
369 * decimal digits, as defined by u_charDigitValue(). In addition,
370 * DecimalFormat also recognizes as digits the ten consecutive
371 * characters starting with the localized zero digit defined in the
372 * DecimalFormatSymbols object. During formatting, the
373 * DecimalFormatSymbols-based digits are output.
374 *
375 * <p>During parsing, grouping separators are ignored.
376 *
729e4ab9
A
377 * <p>For currency parsing, the formatter is able to parse every currency
378 * style formats no matter which style the formatter is constructed with.
379 * For example, a formatter instance gotten from
380 * NumberFormat.getInstance(ULocale, NumberFormat.CURRENCYSTYLE) can parse
381 * formats such as "USD1.00" and "3.00 US dollars".
382 *
374ca955
A
383 * <p>If parse(UnicodeString&,Formattable&,ParsePosition&)
384 * fails to parse a string, it leaves the parse position unchanged.
385 * The convenience method parse(UnicodeString&,Formattable&,UErrorCode&)
386 * indicates parse failure by setting a failing
387 * UErrorCode.
388 *
389 * <p><strong>Formatting</strong>
390 *
391 * <p>Formatting is guided by several parameters, all of which can be
392 * specified either using a pattern or using the API. The following
393 * description applies to formats that do not use <a href="#sci">scientific
394 * notation</a> or <a href="#sigdig">significant digits</a>.
395 *
396 * <ul><li>If the number of actual integer digits exceeds the
397 * <em>maximum integer digits</em>, then only the least significant
398 * digits are shown. For example, 1997 is formatted as "97" if the
399 * maximum integer digits is set to 2.
400 *
401 * <li>If the number of actual integer digits is less than the
402 * <em>minimum integer digits</em>, then leading zeros are added. For
403 * example, 1997 is formatted as "01997" if the minimum integer digits
404 * is set to 5.
405 *
406 * <li>If the number of actual fraction digits exceeds the <em>maximum
729e4ab9 407 * fraction digits</em>, then rounding is performed to the
374ca955
A
408 * maximum fraction digits. For example, 0.125 is formatted as "0.12"
409 * if the maximum fraction digits is 2. This behavior can be changed
729e4ab9 410 * by specifying a rounding increment and/or a rounding mode.
374ca955
A
411 *
412 * <li>If the number of actual fraction digits is less than the
413 * <em>minimum fraction digits</em>, then trailing zeros are added.
3d1f044b 414 * For example, 0.125 is formatted as "0.1250" if the minimum fraction
374ca955
A
415 * digits is set to 4.
416 *
417 * <li>Trailing fractional zeros are not displayed if they occur
418 * <em>j</em> positions after the decimal, where <em>j</em> is less
419 * than the maximum fraction digits. For example, 0.10004 is
420 * formatted as "0.1" if the maximum fraction digits is four or less.
421 * </ul>
422 *
423 * <p><strong>Special Values</strong>
424 *
425 * <p><code>NaN</code> is represented as a single character, typically
426 * <code>\\uFFFD</code>. This character is determined by the
427 * DecimalFormatSymbols object. This is the only value for which
428 * the prefixes and suffixes are not used.
429 *
430 * <p>Infinity is represented as a single character, typically
431 * <code>\\u221E</code>, with the positive or negative prefixes and suffixes
432 * applied. The infinity character is determined by the
433 * DecimalFormatSymbols object.
434 *
435 * <a name="sci"><strong>Scientific Notation</strong></a>
436 *
437 * <p>Numbers in scientific notation are expressed as the product of a mantissa
438 * and a power of ten, for example, 1234 can be expressed as 1.234 x 10<sup>3</sup>. The
439 * mantissa is typically in the half-open interval [1.0, 10.0) or sometimes [0.0, 1.0),
440 * but it need not be. DecimalFormat supports arbitrary mantissas.
441 * DecimalFormat can be instructed to use scientific
442 * notation through the API or through the pattern. In a pattern, the exponent
443 * character immediately followed by one or more digit characters indicates
444 * scientific notation. Example: "0.###E0" formats the number 1234 as
445 * "1.234E3".
446 *
447 * <ul>
448 * <li>The number of digit characters after the exponent character gives the
449 * minimum exponent digit count. There is no maximum. Negative exponents are
450 * formatted using the localized minus sign, <em>not</em> the prefix and suffix
451 * from the pattern. This allows patterns such as "0.###E0 m/s". To prefix
452 * positive exponents with a localized plus sign, specify '+' between the
453 * exponent and the digits: "0.###E+0" will produce formats "1E+1", "1E+0",
454 * "1E-1", etc. (In localized patterns, use the localized plus sign rather than
455 * '+'.)
456 *
457 * <li>The minimum number of integer digits is achieved by adjusting the
458 * exponent. Example: 0.00123 formatted with "00.###E0" yields "12.3E-4". This
459 * only happens if there is no maximum number of integer digits. If there is a
460 * maximum, then the minimum number of integer digits is fixed at one.
461 *
462 * <li>The maximum number of integer digits, if present, specifies the exponent
463 * grouping. The most common use of this is to generate <em>engineering
464 * notation</em>, in which the exponent is a multiple of three, e.g.,
465 * "##0.###E0". The number 12345 is formatted using "##0.####E0" as "12.345E3".
466 *
467 * <li>When using scientific notation, the formatter controls the
468 * digit counts using significant digits logic. The maximum number of
469 * significant digits limits the total number of integer and fraction
470 * digits that will be shown in the mantissa; it does not affect
471 * parsing. For example, 12345 formatted with "##0.##E0" is "12.3E3".
472 * See the section on significant digits for more details.
473 *
474 * <li>The number of significant digits shown is determined as
475 * follows: If areSignificantDigitsUsed() returns false, then the
476 * minimum number of significant digits shown is one, and the maximum
477 * number of significant digits shown is the sum of the <em>minimum
478 * integer</em> and <em>maximum fraction</em> digits, and is
479 * unaffected by the maximum integer digits. If this sum is zero,
480 * then all significant digits are shown. If
481 * areSignificantDigitsUsed() returns true, then the significant digit
482 * counts are specified by getMinimumSignificantDigits() and
483 * getMaximumSignificantDigits(). In this case, the number of
484 * integer digits is fixed at one, and there is no exponent grouping.
485 *
486 * <li>Exponential patterns may not contain grouping separators.
487 * </ul>
488 *
489 * <a name="sigdig"><strong>Significant Digits</strong></a>
490 *
491 * <code>DecimalFormat</code> has two ways of controlling how many
492 * digits are shows: (a) significant digits counts, or (b) integer and
493 * fraction digit counts. Integer and fraction digit counts are
494 * described above. When a formatter is using significant digits
495 * counts, the number of integer and fraction digits is not specified
496 * directly, and the formatter settings for these counts are ignored.
497 * Instead, the formatter uses however many integer and fraction
498 * digits are required to display the specified number of significant
499 * digits. Examples:
500 *
501 * <table border=0 cellspacing=3 cellpadding=0>
502 * <tr bgcolor="#ccccff">
503 * <td align=left>Pattern
504 * <td align=left>Minimum significant digits
505 * <td align=left>Maximum significant digits
506 * <td align=left>Number
507 * <td align=left>Output of format()
508 * <tr valign=top>
509 * <td><code>\@\@\@</code>
510 * <td>3
511 * <td>3
512 * <td>12345
513 * <td><code>12300</code>
514 * <tr valign=top bgcolor="#eeeeff">
515 * <td><code>\@\@\@</code>
516 * <td>3
517 * <td>3
518 * <td>0.12345
519 * <td><code>0.123</code>
520 * <tr valign=top>
521 * <td><code>\@\@##</code>
522 * <td>2
523 * <td>4
524 * <td>3.14159
525 * <td><code>3.142</code>
526 * <tr valign=top bgcolor="#eeeeff">
527 * <td><code>\@\@##</code>
528 * <td>2
529 * <td>4
530 * <td>1.23004
531 * <td><code>1.23</code>
532 * </table>
533 *
534 * <ul>
535 * <li>Significant digit counts may be expressed using patterns that
536 * specify a minimum and maximum number of significant digits. These
537 * are indicated by the <code>'@'</code> and <code>'#'</code>
538 * characters. The minimum number of significant digits is the number
539 * of <code>'@'</code> characters. The maximum number of significant
540 * digits is the number of <code>'@'</code> characters plus the number
541 * of <code>'#'</code> characters following on the right. For
542 * example, the pattern <code>"@@@"</code> indicates exactly 3
543 * significant digits. The pattern <code>"@##"</code> indicates from
544 * 1 to 3 significant digits. Trailing zero digits to the right of
545 * the decimal separator are suppressed after the minimum number of
546 * significant digits have been shown. For example, the pattern
547 * <code>"@##"</code> formats the number 0.1203 as
548 * <code>"0.12"</code>.
549 *
550 * <li>If a pattern uses significant digits, it may not contain a
551 * decimal separator, nor the <code>'0'</code> pattern character.
552 * Patterns such as <code>"@00"</code> or <code>"@.###"</code> are
553 * disallowed.
554 *
555 * <li>Any number of <code>'#'</code> characters may be prepended to
556 * the left of the leftmost <code>'@'</code> character. These have no
557 * effect on the minimum and maximum significant digits counts, but
558 * may be used to position grouping separators. For example,
559 * <code>"#,#@#"</code> indicates a minimum of one significant digits,
560 * a maximum of two significant digits, and a grouping size of three.
561 *
562 * <li>In order to enable significant digits formatting, use a pattern
563 * containing the <code>'@'</code> pattern character. Alternatively,
564 * call setSignificantDigitsUsed(TRUE).
565 *
566 * <li>In order to disable significant digits formatting, use a
567 * pattern that does not contain the <code>'@'</code> pattern
568 * character. Alternatively, call setSignificantDigitsUsed(FALSE).
569 *
570 * <li>The number of significant digits has no effect on parsing.
571 *
572 * <li>Significant digits may be used together with exponential notation. Such
573 * patterns are equivalent to a normal exponential pattern with a minimum and
574 * maximum integer digit count of one, a minimum fraction digit count of
575 * <code>getMinimumSignificantDigits() - 1</code>, and a maximum fraction digit
576 * count of <code>getMaximumSignificantDigits() - 1</code>. For example, the
577 * pattern <code>"@@###E0"</code> is equivalent to <code>"0.0###E0"</code>.
578 *
3d1f044b 579 * <li>If significant digits are in use, then the integer and fraction
374ca955 580 * digit counts, as set via the API, are ignored. If significant
3d1f044b 581 * digits are not in use, then the significant digit counts, as set via
374ca955
A
582 * the API, are ignored.
583 *
584 * </ul>
585 *
586 * <p><strong>Padding</strong>
587 *
588 * <p>DecimalFormat supports padding the result of
589 * format() to a specific width. Padding may be specified either
590 * through the API or through the pattern syntax. In a pattern the pad escape
591 * character, followed by a single pad character, causes padding to be parsed
592 * and formatted. The pad escape character is '*' in unlocalized patterns, and
593 * can be localized using DecimalFormatSymbols::setSymbol() with a
594 * DecimalFormatSymbols::kPadEscapeSymbol
595 * selector. For example, <code>"$*x#,##0.00"</code> formats 123 to
596 * <code>"$xx123.00"</code>, and 1234 to <code>"$1,234.00"</code>.
597 *
598 * <ul>
599 * <li>When padding is in effect, the width of the positive subpattern,
600 * including prefix and suffix, determines the format width. For example, in
601 * the pattern <code>"* #0 o''clock"</code>, the format width is 10.
602 *
f3c0d7a5 603 * <li>The width is counted in 16-bit code units (char16_ts).
374ca955
A
604 *
605 * <li>Some parameters which usually do not matter have meaning when padding is
606 * used, because the pattern width is significant with padding. In the pattern
607 * "* ##,##,#,##0.##", the format width is 14. The initial characters "##,##,"
608 * do not affect the grouping size or maximum integer digits, but they do affect
609 * the format width.
610 *
611 * <li>Padding may be inserted at one of four locations: before the prefix,
612 * after the prefix, before the suffix, or after the suffix. If padding is
613 * specified in any other location, applyPattern()
614 * sets a failing UErrorCode. If there is no prefix,
615 * before the prefix and after the prefix are equivalent, likewise for the
616 * suffix.
617 *
618 * <li>When specified in a pattern, the 32-bit code point immediately
619 * following the pad escape is the pad character. This may be any character,
620 * including a special pattern character. That is, the pad escape
621 * <em>escapes</em> the following character. If there is no character after
622 * the pad escape, then the pattern is illegal.
623 *
624 * </ul>
625 *
626 * <p><strong>Rounding</strong>
627 *
628 * <p>DecimalFormat supports rounding to a specific increment. For
629 * example, 1230 rounded to the nearest 50 is 1250. 1.234 rounded to the
630 * nearest 0.65 is 1.3. The rounding increment may be specified through the API
631 * or in a pattern. To specify a rounding increment in a pattern, include the
632 * increment in the pattern itself. "#,#50" specifies a rounding increment of
633 * 50. "#,##0.05" specifies a rounding increment of 0.05.
634 *
3d1f044b 635 * <p>In the absence of an explicit rounding increment numbers are
729e4ab9
A
636 * rounded to their formatted width.
637 *
374ca955
A
638 * <ul>
639 * <li>Rounding only affects the string produced by formatting. It does
640 * not affect parsing or change any numerical values.
641 *
642 * <li>A <em>rounding mode</em> determines how values are rounded; see
729e4ab9
A
643 * DecimalFormat::ERoundingMode. The default rounding mode is
644 * DecimalFormat::kRoundHalfEven. The rounding mode can only be set
645 * through the API; it can not be set with a pattern.
374ca955
A
646 *
647 * <li>Some locales use rounding in their currency formats to reflect the
648 * smallest currency denomination.
649 *
650 * <li>In a pattern, digits '1' through '9' specify rounding, but otherwise
651 * behave identically to digit '0'.
652 * </ul>
653 *
654 * <p><strong>Synchronization</strong>
655 *
656 * <p>DecimalFormat objects are not synchronized. Multiple
657 * threads should not access one formatter concurrently.
658 *
659 * <p><strong>Subclassing</strong>
660 *
661 * <p><em>User subclasses are not supported.</em> While clients may write
662 * subclasses, such code will not necessarily work and will not be
663 * guaranteed to work stably from release to release.
b75a7d8f 664 */
3d1f044b
A
665class U_I18N_API DecimalFormat : public NumberFormat {
666 public:
374ca955
A
667 /**
668 * Pad position.
669 * @stable ICU 2.4
670 */
b75a7d8f 671 enum EPadPosition {
3d1f044b 672 kPadBeforePrefix, kPadAfterPrefix, kPadBeforeSuffix, kPadAfterSuffix
b75a7d8f
A
673 };
674
675 /**
676 * Create a DecimalFormat using the default pattern and symbols
677 * for the default locale. This is a convenient way to obtain a
678 * DecimalFormat when internationalization is not the main concern.
679 * <P>
680 * To obtain standard formats for a given locale, use the factory methods
681 * on NumberFormat such as createInstance. These factories will
682 * return the most appropriate sub-class of NumberFormat for a given
683 * locale.
0f5d89e8
A
684 * <p>
685 * <strong>NOTE:</strong> New users are strongly encouraged to use
3d1f044b 686 * #icu::number::NumberFormatter instead of DecimalFormat.
b75a7d8f
A
687 * @param status Output param set to success/failure code. If the
688 * pattern is invalid this will be set to a failure code.
689 * @stable ICU 2.0
690 */
691 DecimalFormat(UErrorCode& status);
692
693 /**
694 * Create a DecimalFormat from the given pattern and the symbols
695 * for the default locale. This is a convenient way to obtain a
696 * DecimalFormat when internationalization is not the main concern.
697 * <P>
698 * To obtain standard formats for a given locale, use the factory methods
699 * on NumberFormat such as createInstance. These factories will
700 * return the most appropriate sub-class of NumberFormat for a given
701 * locale.
0f5d89e8
A
702 * <p>
703 * <strong>NOTE:</strong> New users are strongly encouraged to use
3d1f044b 704 * #icu::number::NumberFormatter instead of DecimalFormat.
b75a7d8f
A
705 * @param pattern A non-localized pattern string.
706 * @param status Output param set to success/failure code. If the
707 * pattern is invalid this will be set to a failure code.
708 * @stable ICU 2.0
709 */
3d1f044b 710 DecimalFormat(const UnicodeString& pattern, UErrorCode& status);
b75a7d8f
A
711
712 /**
713 * Create a DecimalFormat from the given pattern and symbols.
714 * Use this constructor when you need to completely customize the
715 * behavior of the format.
716 * <P>
717 * To obtain standard formats for a given
718 * locale, use the factory methods on NumberFormat such as
719 * createInstance or createCurrencyInstance. If you need only minor adjustments
720 * to a standard format, you can modify the format returned by
721 * a NumberFormat factory method.
0f5d89e8
A
722 * <p>
723 * <strong>NOTE:</strong> New users are strongly encouraged to use
3d1f044b 724 * #icu::number::NumberFormatter instead of DecimalFormat.
b75a7d8f
A
725 *
726 * @param pattern a non-localized pattern string
727 * @param symbolsToAdopt the set of symbols to be used. The caller should not
728 * delete this object after making this call.
729 * @param status Output param set to success/failure code. If the
730 * pattern is invalid this will be set to a failure code.
731 * @stable ICU 2.0
732 */
3d1f044b 733 DecimalFormat(const UnicodeString& pattern, DecimalFormatSymbols* symbolsToAdopt, UErrorCode& status);
b75a7d8f 734
4388f060 735#ifndef U_HIDE_INTERNAL_API
3d1f044b 736
729e4ab9
A
737 /**
738 * This API is for ICU use only.
739 * Create a DecimalFormat from the given pattern, symbols, and style.
740 *
741 * @param pattern a non-localized pattern string
742 * @param symbolsToAdopt the set of symbols to be used. The caller should not
743 * delete this object after making this call.
4388f060 744 * @param style style of decimal format
729e4ab9
A
745 * @param status Output param set to success/failure code. If the
746 * pattern is invalid this will be set to a failure code.
51004dcb 747 * @internal
729e4ab9 748 */
3d1f044b
A
749 DecimalFormat(const UnicodeString& pattern, DecimalFormatSymbols* symbolsToAdopt,
750 UNumberFormatStyle style, UErrorCode& status);
51004dcb
A
751
752#if UCONFIG_HAVE_PARSEALLINPUT
3d1f044b 753
51004dcb
A
754 /**
755 * @internal
756 */
757 void setParseAllInput(UNumberFormatAttributeValue value);
3d1f044b 758
51004dcb
A
759#endif
760
4388f060 761#endif /* U_HIDE_INTERNAL_API */
729e4ab9 762
3d1f044b
A
763 private:
764
765 /**
766 * Internal constructor for DecimalFormat; sets up internal fields. All public constructors should
767 * call this constructor.
768 */
769 DecimalFormat(const DecimalFormatSymbols* symbolsToAdopt, UErrorCode& status);
770
771 public:
51004dcb
A
772
773 /**
774 * Set an integer attribute on this DecimalFormat.
775 * May return U_UNSUPPORTED_ERROR if this instance does not support
776 * the specified attribute.
777 * @param attr the attribute to set
3d1f044b 778 * @param newValue new value
51004dcb
A
779 * @param status the error type
780 * @return *this - for chaining (example: format.setAttribute(...).setAttribute(...) )
57a6839d 781 * @stable ICU 51
51004dcb 782 */
3d1f044b 783 virtual DecimalFormat& setAttribute(UNumberFormatAttribute attr, int32_t newValue, UErrorCode& status);
51004dcb
A
784
785 /**
786 * Get an integer
787 * May return U_UNSUPPORTED_ERROR if this instance does not support
788 * the specified attribute.
789 * @param attr the attribute to set
790 * @param status the error type
791 * @return the attribute value. Undefined if there is an error.
57a6839d 792 * @stable ICU 51
51004dcb 793 */
3d1f044b 794 virtual int32_t getAttribute(UNumberFormatAttribute attr, UErrorCode& status) const;
51004dcb 795
2ca993e8 796
57a6839d
A
797 /**
798 * Set whether or not grouping will be used in this format.
799 * @param newValue True, grouping will be used in this format.
800 * @see getGroupingUsed
b331163b 801 * @stable ICU 53
57a6839d 802 */
3d1f044b 803 void setGroupingUsed(UBool newValue) U_OVERRIDE;
57a6839d
A
804
805 /**
806 * Sets whether or not numbers should be parsed as integers only.
807 * @param value set True, this format will parse numbers as integers
808 * only.
809 * @see isParseIntegerOnly
b331163b 810 * @stable ICU 53
57a6839d 811 */
3d1f044b 812 void setParseIntegerOnly(UBool value) U_OVERRIDE;
51004dcb 813
57a6839d 814 /**
3d1f044b
A
815 * Sets whether lenient parsing should be enabled (it is off by default).
816 *
817 * @param enable \c TRUE if lenient parsing should be used,
818 * \c FALSE otherwise.
819 * @stable ICU 4.8
57a6839d 820 */
3d1f044b 821 void setLenient(UBool enable) U_OVERRIDE;
51004dcb 822
b75a7d8f
A
823 /**
824 * Create a DecimalFormat from the given pattern and symbols.
825 * Use this constructor when you need to completely customize the
826 * behavior of the format.
827 * <P>
828 * To obtain standard formats for a given
829 * locale, use the factory methods on NumberFormat such as
830 * createInstance or createCurrencyInstance. If you need only minor adjustments
831 * to a standard format, you can modify the format returned by
832 * a NumberFormat factory method.
0f5d89e8
A
833 * <p>
834 * <strong>NOTE:</strong> New users are strongly encouraged to use
3d1f044b 835 * #icu::number::NumberFormatter instead of DecimalFormat.
b75a7d8f
A
836 *
837 * @param pattern a non-localized pattern string
838 * @param symbolsToAdopt the set of symbols to be used. The caller should not
839 * delete this object after making this call.
3d1f044b 840 * @param parseError Output param to receive errors occurred during parsing
b75a7d8f
A
841 * @param status Output param set to success/failure code. If the
842 * pattern is invalid this will be set to a failure code.
843 * @stable ICU 2.0
844 */
3d1f044b
A
845 DecimalFormat(const UnicodeString& pattern, DecimalFormatSymbols* symbolsToAdopt,
846 UParseError& parseError, UErrorCode& status);
847
b75a7d8f
A
848 /**
849 * Create a DecimalFormat from the given pattern and symbols.
850 * Use this constructor when you need to completely customize the
851 * behavior of the format.
852 * <P>
853 * To obtain standard formats for a given
854 * locale, use the factory methods on NumberFormat such as
855 * createInstance or createCurrencyInstance. If you need only minor adjustments
856 * to a standard format, you can modify the format returned by
857 * a NumberFormat factory method.
0f5d89e8
A
858 * <p>
859 * <strong>NOTE:</strong> New users are strongly encouraged to use
3d1f044b 860 * #icu::number::NumberFormatter instead of DecimalFormat.
b75a7d8f
A
861 *
862 * @param pattern a non-localized pattern string
863 * @param symbols the set of symbols to be used
864 * @param status Output param set to success/failure code. If the
865 * pattern is invalid this will be set to a failure code.
866 * @stable ICU 2.0
867 */
3d1f044b 868 DecimalFormat(const UnicodeString& pattern, const DecimalFormatSymbols& symbols, UErrorCode& status);
b75a7d8f
A
869
870 /**
871 * Copy constructor.
729e4ab9 872 *
b75a7d8f
A
873 * @param source the DecimalFormat object to be copied from.
874 * @stable ICU 2.0
875 */
876 DecimalFormat(const DecimalFormat& source);
877
878 /**
879 * Assignment operator.
880 *
881 * @param rhs the DecimalFormat object to be copied.
882 * @stable ICU 2.0
883 */
884 DecimalFormat& operator=(const DecimalFormat& rhs);
885
886 /**
887 * Destructor.
888 * @stable ICU 2.0
889 */
3d1f044b 890 ~DecimalFormat() U_OVERRIDE;
b75a7d8f
A
891
892 /**
893 * Clone this Format object polymorphically. The caller owns the
894 * result and should delete it when done.
895 *
896 * @return a polymorphic copy of this DecimalFormat.
897 * @stable ICU 2.0
898 */
3d1f044b 899 Format* clone(void) const U_OVERRIDE;
b75a7d8f
A
900
901 /**
902 * Return true if the given Format objects are semantically equal.
903 * Objects of different subclasses are considered unequal.
904 *
905 * @param other the object to be compared with.
906 * @return true if the given Format objects are semantically equal.
907 * @stable ICU 2.0
908 */
3d1f044b 909 UBool operator==(const Format& other) const U_OVERRIDE;
b75a7d8f 910
729e4ab9
A
911
912 using NumberFormat::format;
913
b75a7d8f
A
914 /**
915 * Format a double or long number using base-10 representation.
916 *
917 * @param number The value to be formatted.
918 * @param appendTo Output parameter to receive result.
919 * Result is appended to existing contents.
920 * @param pos On input: an alignment field, if desired.
921 * On output: the offsets of the alignment field.
922 * @return Reference to 'appendTo' parameter.
923 * @stable ICU 2.0
729e4ab9 924 */
3d1f044b 925 UnicodeString& format(double number, UnicodeString& appendTo, FieldPosition& pos) const U_OVERRIDE;
51004dcb 926
3d1f044b 927#ifndef U_HIDE_INTERNAL_API
51004dcb
A
928 /**
929 * Format a double or long number using base-10 representation.
930 *
931 * @param number The value to be formatted.
932 * @param appendTo Output parameter to receive result.
933 * Result is appended to existing contents.
934 * @param pos On input: an alignment field, if desired.
935 * On output: the offsets of the alignment field.
936 * @param status
937 * @return Reference to 'appendTo' parameter.
938 * @internal
939 */
3d1f044b
A
940 UnicodeString& format(double number, UnicodeString& appendTo, FieldPosition& pos,
941 UErrorCode& status) const U_OVERRIDE;
942#endif /* U_HIDE_INTERNAL_API */
51004dcb 943
729e4ab9
A
944 /**
945 * Format a double or long number using base-10 representation.
946 *
947 * @param number The value to be formatted.
948 * @param appendTo Output parameter to receive result.
949 * Result is appended to existing contents.
950 * @param posIter On return, can be used to iterate over positions
951 * of fields generated by this format call.
952 * Can be NULL.
953 * @param status Output param filled with success/failure status.
954 * @return Reference to 'appendTo' parameter.
f3c0d7a5 955 * @stable ICU 4.4
729e4ab9 956 */
3d1f044b
A
957 UnicodeString& format(double number, UnicodeString& appendTo, FieldPositionIterator* posIter,
958 UErrorCode& status) const U_OVERRIDE;
729e4ab9 959
b75a7d8f
A
960 /**
961 * Format a long number using base-10 representation.
962 *
963 * @param number The value to be formatted.
964 * @param appendTo Output parameter to receive result.
965 * Result is appended to existing contents.
966 * @param pos On input: an alignment field, if desired.
967 * On output: the offsets of the alignment field.
968 * @return Reference to 'appendTo' parameter.
969 * @stable ICU 2.0
970 */
3d1f044b 971 UnicodeString& format(int32_t number, UnicodeString& appendTo, FieldPosition& pos) const U_OVERRIDE;
729e4ab9 972
3d1f044b 973#ifndef U_HIDE_INTERNAL_API
51004dcb
A
974 /**
975 * Format a long number using base-10 representation.
976 *
977 * @param number The value to be formatted.
978 * @param appendTo Output parameter to receive result.
979 * Result is appended to existing contents.
980 * @param pos On input: an alignment field, if desired.
981 * On output: the offsets of the alignment field.
3d1f044b 982 * @param status Output param filled with success/failure status.
51004dcb
A
983 * @return Reference to 'appendTo' parameter.
984 * @internal
985 */
3d1f044b
A
986 UnicodeString& format(int32_t number, UnicodeString& appendTo, FieldPosition& pos,
987 UErrorCode& status) const U_OVERRIDE;
988#endif /* U_HIDE_INTERNAL_API */
51004dcb 989
729e4ab9
A
990 /**
991 * Format a long number using base-10 representation.
992 *
993 * @param number The value to be formatted.
994 * @param appendTo Output parameter to receive result.
995 * Result is appended to existing contents.
996 * @param posIter On return, can be used to iterate over positions
997 * of fields generated by this format call.
998 * Can be NULL.
999 * @param status Output param filled with success/failure status.
1000 * @return Reference to 'appendTo' parameter.
f3c0d7a5 1001 * @stable ICU 4.4
729e4ab9 1002 */
3d1f044b
A
1003 UnicodeString& format(int32_t number, UnicodeString& appendTo, FieldPositionIterator* posIter,
1004 UErrorCode& status) const U_OVERRIDE;
729e4ab9 1005
374ca955
A
1006 /**
1007 * Format an int64 number using base-10 representation.
1008 *
1009 * @param number The value to be formatted.
1010 * @param appendTo Output parameter to receive result.
1011 * Result is appended to existing contents.
1012 * @param pos On input: an alignment field, if desired.
1013 * On output: the offsets of the alignment field.
1014 * @return Reference to 'appendTo' parameter.
73c04bcf 1015 * @stable ICU 2.8
374ca955 1016 */
3d1f044b 1017 UnicodeString& format(int64_t number, UnicodeString& appendTo, FieldPosition& pos) const U_OVERRIDE;
374ca955 1018
3d1f044b 1019#ifndef U_HIDE_INTERNAL_API
51004dcb
A
1020 /**
1021 * Format an int64 number using base-10 representation.
1022 *
1023 * @param number The value to be formatted.
1024 * @param appendTo Output parameter to receive result.
1025 * Result is appended to existing contents.
1026 * @param pos On input: an alignment field, if desired.
1027 * On output: the offsets of the alignment field.
3d1f044b 1028 * @param status Output param filled with success/failure status.
51004dcb
A
1029 * @return Reference to 'appendTo' parameter.
1030 * @internal
1031 */
3d1f044b
A
1032 UnicodeString& format(int64_t number, UnicodeString& appendTo, FieldPosition& pos,
1033 UErrorCode& status) const U_OVERRIDE;
1034#endif /* U_HIDE_INTERNAL_API */
51004dcb 1035
729e4ab9
A
1036 /**
1037 * Format an int64 number using base-10 representation.
1038 *
1039 * @param number The value to be formatted.
1040 * @param appendTo Output parameter to receive result.
1041 * Result is appended to existing contents.
1042 * @param posIter On return, can be used to iterate over positions
1043 * of fields generated by this format call.
1044 * Can be NULL.
1045 * @param status Output param filled with success/failure status.
1046 * @return Reference to 'appendTo' parameter.
f3c0d7a5 1047 * @stable ICU 4.4
729e4ab9 1048 */
3d1f044b
A
1049 UnicodeString& format(int64_t number, UnicodeString& appendTo, FieldPositionIterator* posIter,
1050 UErrorCode& status) const U_OVERRIDE;
729e4ab9
A
1051
1052 /**
1053 * Format a decimal number.
1054 * The syntax of the unformatted number is a "numeric string"
1055 * as defined in the Decimal Arithmetic Specification, available at
1056 * http://speleotrove.com/decimal
1057 *
1058 * @param number The unformatted number, as a string.
1059 * @param appendTo Output parameter to receive result.
1060 * Result is appended to existing contents.
1061 * @param posIter On return, can be used to iterate over positions
1062 * of fields generated by this format call.
1063 * Can be NULL.
1064 * @param status Output param filled with success/failure status.
1065 * @return Reference to 'appendTo' parameter.
f3c0d7a5 1066 * @stable ICU 4.4
729e4ab9 1067 */
3d1f044b
A
1068 UnicodeString& format(StringPiece number, UnicodeString& appendTo, FieldPositionIterator* posIter,
1069 UErrorCode& status) const U_OVERRIDE;
729e4ab9 1070
3d1f044b 1071#ifndef U_HIDE_INTERNAL_API
729e4ab9
A
1072
1073 /**
57a6839d 1074 * Format a decimal number.
3d1f044b 1075 * The number is a DecimalQuantity wrapper onto a floating point decimal number.
729e4ab9
A
1076 * The default implementation in NumberFormat converts the decimal number
1077 * to a double and formats that.
1078 *
3d1f044b 1079 * @param number The number, a DecimalQuantity format Decimal Floating Point.
729e4ab9
A
1080 * @param appendTo Output parameter to receive result.
1081 * Result is appended to existing contents.
1082 * @param posIter On return, can be used to iterate over positions
1083 * of fields generated by this format call.
1084 * @param status Output param filled with success/failure status.
1085 * @return Reference to 'appendTo' parameter.
1086 * @internal
1087 */
3d1f044b
A
1088 UnicodeString& format(const number::impl::DecimalQuantity& number, UnicodeString& appendTo,
1089 FieldPositionIterator* posIter, UErrorCode& status) const U_OVERRIDE;
729e4ab9 1090
2ca993e8
A
1091 /**
1092 * Format a decimal number.
3d1f044b
A
1093 * The number is a DecimalQuantity wrapper onto a floating point decimal number.
1094 * The default implementation in NumberFormat converts the decimal number
1095 * to a double and formats that.
1096 *
1097 * @param number The number, a DecimalQuantity format Decimal Floating Point.
2ca993e8
A
1098 * @param appendTo Output parameter to receive result.
1099 * Result is appended to existing contents.
1100 * @param pos On input: an alignment field, if desired.
1101 * On output: the offsets of the alignment field.
1102 * @param status Output param filled with success/failure status.
1103 * @return Reference to 'appendTo' parameter.
1104 * @internal
1105 */
3d1f044b
A
1106 UnicodeString& format(const number::impl::DecimalQuantity& number, UnicodeString& appendTo,
1107 FieldPosition& pos, UErrorCode& status) const U_OVERRIDE;
2ca993e8 1108
3d1f044b
A
1109#endif // U_HIDE_INTERNAL_API
1110
1111 using NumberFormat::parse;
2ca993e8 1112
729e4ab9 1113 /**
3d1f044b
A
1114 * Parse the given string using this object's choices. The method
1115 * does string comparisons to try to find an optimal match.
1116 * If no object can be parsed, index is unchanged, and NULL is
1117 * returned. The result is returned as the most parsimonious
1118 * type of Formattable that will accommodate all of the
1119 * necessary precision. For example, if the result is exactly 12,
1120 * it will be returned as a long. However, if it is 1.5, it will
1121 * be returned as a double.
729e4ab9 1122 *
3d1f044b
A
1123 * @param text The text to be parsed.
1124 * @param result Formattable to be set to the parse result.
1125 * If parse fails, return contents are undefined.
1126 * @param parsePosition The position to start parsing at on input.
1127 * On output, moved to after the last successfully
1128 * parse character. On parse failure, does not change.
1129 * @see Formattable
1130 * @stable ICU 2.0
729e4ab9 1131 */
3d1f044b
A
1132 void parse(const UnicodeString& text, Formattable& result,
1133 ParsePosition& parsePosition) const U_OVERRIDE;
b75a7d8f 1134
374ca955
A
1135 /**
1136 * Parses text from the given string as a currency amount. Unlike
1137 * the parse() method, this method will attempt to parse a generic
1138 * currency name, searching for a match of this object's locale's
1139 * currency display names, or for a 3-letter ISO currency code.
1140 * This method will fail if this format is not a currency format,
1141 * that is, if it does not contain the currency pattern symbol
1142 * (U+00A4) in its prefix or suffix.
1143 *
1144 * @param text the string to parse
4388f060
A
1145 * @param pos input-output position; on input, the position within text
1146 * to match; must have 0 <= pos.getIndex() < text.length();
1147 * on output, the position after the last matched character.
1148 * If the parse fails, the position in unchanged upon output.
1149 * @return if parse succeeds, a pointer to a newly-created CurrencyAmount
1150 * object (owned by the caller) containing information about
1151 * the parsed currency; if parse fails, this is NULL.
51004dcb 1152 * @stable ICU 49
374ca955 1153 */
3d1f044b 1154 CurrencyAmount* parseCurrency(const UnicodeString& text, ParsePosition& pos) const U_OVERRIDE;
374ca955 1155
b75a7d8f
A
1156 /**
1157 * Returns the decimal format symbols, which is generally not changed
1158 * by the programmer or user.
1159 * @return desired DecimalFormatSymbols
1160 * @see DecimalFormatSymbols
1161 * @stable ICU 2.0
1162 */
1163 virtual const DecimalFormatSymbols* getDecimalFormatSymbols(void) const;
1164
1165 /**
1166 * Sets the decimal format symbols, which is generally not changed
1167 * by the programmer or user.
1168 * @param symbolsToAdopt DecimalFormatSymbols to be adopted.
1169 * @stable ICU 2.0
1170 */
1171 virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt);
1172
1173 /**
1174 * Sets the decimal format symbols, which is generally not changed
1175 * by the programmer or user.
1176 * @param symbols DecimalFormatSymbols.
1177 * @stable ICU 2.0
1178 */
1179 virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols);
1180
1181
729e4ab9
A
1182 /**
1183 * Returns the currency plural format information,
1184 * which is generally not changed by the programmer or user.
1185 * @return desired CurrencyPluralInfo
1186 * @stable ICU 4.2
1187 */
1188 virtual const CurrencyPluralInfo* getCurrencyPluralInfo(void) const;
1189
1190 /**
1191 * Sets the currency plural format information,
1192 * which is generally not changed by the programmer or user.
1193 * @param toAdopt CurrencyPluralInfo to be adopted.
1194 * @stable ICU 4.2
1195 */
1196 virtual void adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt);
1197
1198 /**
1199 * Sets the currency plural format information,
1200 * which is generally not changed by the programmer or user.
1201 * @param info Currency Plural Info.
1202 * @stable ICU 4.2
1203 */
1204 virtual void setCurrencyPluralInfo(const CurrencyPluralInfo& info);
1205
1206
b75a7d8f
A
1207 /**
1208 * Get the positive prefix.
1209 *
1210 * @param result Output param which will receive the positive prefix.
1211 * @return A reference to 'result'.
1212 * Examples: +123, $123, sFr123
1213 * @stable ICU 2.0
1214 */
1215 UnicodeString& getPositivePrefix(UnicodeString& result) const;
1216
1217 /**
1218 * Set the positive prefix.
1219 *
1220 * @param newValue the new value of the the positive prefix to be set.
1221 * Examples: +123, $123, sFr123
1222 * @stable ICU 2.0
1223 */
1224 virtual void setPositivePrefix(const UnicodeString& newValue);
1225
1226 /**
1227 * Get the negative prefix.
1228 *
1229 * @param result Output param which will receive the negative prefix.
1230 * @return A reference to 'result'.
1231 * Examples: -123, ($123) (with negative suffix), sFr-123
1232 * @stable ICU 2.0
1233 */
1234 UnicodeString& getNegativePrefix(UnicodeString& result) const;
1235
1236 /**
1237 * Set the negative prefix.
1238 *
1239 * @param newValue the new value of the the negative prefix to be set.
1240 * Examples: -123, ($123) (with negative suffix), sFr-123
1241 * @stable ICU 2.0
1242 */
1243 virtual void setNegativePrefix(const UnicodeString& newValue);
1244
1245 /**
1246 * Get the positive suffix.
1247 *
1248 * @param result Output param which will receive the positive suffix.
1249 * @return A reference to 'result'.
1250 * Example: 123%
1251 * @stable ICU 2.0
1252 */
1253 UnicodeString& getPositiveSuffix(UnicodeString& result) const;
1254
1255 /**
1256 * Set the positive suffix.
1257 *
1258 * @param newValue the new value of the positive suffix to be set.
1259 * Example: 123%
1260 * @stable ICU 2.0
1261 */
1262 virtual void setPositiveSuffix(const UnicodeString& newValue);
1263
1264 /**
1265 * Get the negative suffix.
1266 *
1267 * @param result Output param which will receive the negative suffix.
1268 * @return A reference to 'result'.
1269 * Examples: -123%, ($123) (with positive suffixes)
1270 * @stable ICU 2.0
1271 */
1272 UnicodeString& getNegativeSuffix(UnicodeString& result) const;
1273
1274 /**
1275 * Set the negative suffix.
1276 *
1277 * @param newValue the new value of the negative suffix to be set.
1278 * Examples: 123%
1279 * @stable ICU 2.0
1280 */
1281 virtual void setNegativeSuffix(const UnicodeString& newValue);
1282
3d1f044b
A
1283#ifndef U_HIDE_DRAFT_API
1284 /**
1285 * Whether to show the plus sign on positive (non-negative) numbers; for example, "+12"
1286 *
1287 * For more control over sign display, use NumberFormatter.
1288 *
1289 * @return Whether the sign is shown on positive numbers and zero.
1290 * @draft ICU 64
1291 */
1292 UBool isSignAlwaysShown() const;
1293
1294 /**
1295 * Set whether to show the plus sign on positive (non-negative) numbers; for example, "+12".
1296 *
1297 * For more control over sign display, use NumberFormatter.
1298 *
1299 * @param value true to always show a sign; false to hide the sign on positive numbers and zero.
1300 * @draft ICU 64
1301 */
1302 void setSignAlwaysShown(UBool value);
1303#endif /* U_HIDE_DRAFT_API */
1304
b75a7d8f
A
1305 /**
1306 * Get the multiplier for use in percent, permill, etc.
1307 * For a percentage, set the suffixes to have "%" and the multiplier to be 100.
1308 * (For Arabic, use arabic percent symbol).
374ca955 1309 * For a permill, set the suffixes to have "\\u2031" and the multiplier to be 1000.
b75a7d8f 1310 *
3d1f044b
A
1311 * The number may also be multiplied by a power of ten; see getMultiplierScale().
1312 *
b75a7d8f
A
1313 * @return the multiplier for use in percent, permill, etc.
1314 * Examples: with 100, 1.23 -> "123", and "123" -> 1.23
1315 * @stable ICU 2.0
1316 */
1317 int32_t getMultiplier(void) const;
1318
1319 /**
1320 * Set the multiplier for use in percent, permill, etc.
1321 * For a percentage, set the suffixes to have "%" and the multiplier to be 100.
1322 * (For Arabic, use arabic percent symbol).
374ca955 1323 * For a permill, set the suffixes to have "\\u2031" and the multiplier to be 1000.
b75a7d8f 1324 *
3d1f044b
A
1325 * This method only supports integer multipliers. To multiply by a non-integer, pair this
1326 * method with setMultiplierScale().
1327 *
b75a7d8f
A
1328 * @param newValue the new value of the multiplier for use in percent, permill, etc.
1329 * Examples: with 100, 1.23 -> "123", and "123" -> 1.23
1330 * @stable ICU 2.0
1331 */
1332 virtual void setMultiplier(int32_t newValue);
1333
3d1f044b
A
1334#ifndef U_HIDE_DRAFT_API
1335 /**
1336 * Gets the power of ten by which number should be multiplied before formatting, which
1337 * can be combined with setMultiplier() to multiply by any arbitrary decimal value.
1338 *
1339 * A multiplier scale of 2 corresponds to multiplication by 100, and a multiplier scale
1340 * of -2 corresponds to multiplication by 0.01.
1341 *
1342 * This method is analogous to UNUM_SCALE in getAttribute.
1343 *
1344 * @return the current value of the power-of-ten multiplier.
1345 * @draft ICU 62
1346 */
1347 int32_t getMultiplierScale(void) const;
1348
1349 /**
1350 * Sets a power of ten by which number should be multiplied before formatting, which
1351 * can be combined with setMultiplier() to multiply by any arbitrary decimal value.
1352 *
1353 * A multiplier scale of 2 corresponds to multiplication by 100, and a multiplier scale
1354 * of -2 corresponds to multiplication by 0.01.
1355 *
1356 * For example, to multiply numbers by 0.5 before formatting, you can do:
1357 *
1358 * <pre>
1359 * df.setMultiplier(5);
1360 * df.setMultiplierScale(-1);
1361 * </pre>
1362 *
1363 * This method is analogous to UNUM_SCALE in setAttribute.
1364 *
1365 * @param newValue the new value of the power-of-ten multiplier.
1366 * @draft ICU 62
1367 */
1368 void setMultiplierScale(int32_t newValue);
1369#endif /* U_HIDE_DRAFT_API */
1370
b75a7d8f
A
1371 /**
1372 * Get the rounding increment.
57a6839d 1373 * @return A positive rounding increment, or 0.0 if a custom rounding
729e4ab9 1374 * increment is not in effect.
b75a7d8f
A
1375 * @see #setRoundingIncrement
1376 * @see #getRoundingMode
1377 * @see #setRoundingMode
1378 * @stable ICU 2.0
1379 */
374ca955 1380 virtual double getRoundingIncrement(void) const;
b75a7d8f
A
1381
1382 /**
729e4ab9
A
1383 * Set the rounding increment. In the absence of a rounding increment,
1384 * numbers will be rounded to the number of digits displayed.
57a6839d
A
1385 * @param newValue A positive rounding increment, or 0.0 to
1386 * use the default rounding increment.
b75a7d8f
A
1387 * Negative increments are equivalent to 0.0.
1388 * @see #getRoundingIncrement
1389 * @see #getRoundingMode
1390 * @see #setRoundingMode
1391 * @stable ICU 2.0
1392 */
1393 virtual void setRoundingIncrement(double newValue);
1394
1395 /**
1396 * Get the rounding mode.
1397 * @return A rounding mode
1398 * @see #setRoundingIncrement
1399 * @see #getRoundingIncrement
1400 * @see #setRoundingMode
1401 * @stable ICU 2.0
1402 */
3d1f044b 1403 virtual ERoundingMode getRoundingMode(void) const U_OVERRIDE;
b75a7d8f
A
1404
1405 /**
57a6839d 1406 * Set the rounding mode.
b75a7d8f
A
1407 * @param roundingMode A rounding mode
1408 * @see #setRoundingIncrement
1409 * @see #getRoundingIncrement
1410 * @see #getRoundingMode
1411 * @stable ICU 2.0
1412 */
3d1f044b 1413 virtual void setRoundingMode(ERoundingMode roundingMode) U_OVERRIDE;
b75a7d8f
A
1414
1415 /**
374ca955
A
1416 * Get the width to which the output of format() is padded.
1417 * The width is counted in 16-bit code units.
b75a7d8f
A
1418 * @return the format width, or zero if no padding is in effect
1419 * @see #setFormatWidth
73c04bcf 1420 * @see #getPadCharacterString
b75a7d8f
A
1421 * @see #setPadCharacter
1422 * @see #getPadPosition
1423 * @see #setPadPosition
1424 * @stable ICU 2.0
1425 */
374ca955 1426 virtual int32_t getFormatWidth(void) const;
b75a7d8f
A
1427
1428 /**
374ca955
A
1429 * Set the width to which the output of format() is padded.
1430 * The width is counted in 16-bit code units.
b75a7d8f
A
1431 * This method also controls whether padding is enabled.
1432 * @param width the width to which to pad the result of
374ca955 1433 * format(), or zero to disable padding. A negative
b75a7d8f
A
1434 * width is equivalent to 0.
1435 * @see #getFormatWidth
73c04bcf 1436 * @see #getPadCharacterString
b75a7d8f
A
1437 * @see #setPadCharacter
1438 * @see #getPadPosition
1439 * @see #setPadPosition
1440 * @stable ICU 2.0
1441 */
1442 virtual void setFormatWidth(int32_t width);
1443
1444 /**
374ca955
A
1445 * Get the pad character used to pad to the format width. The
1446 * default is ' '.
1447 * @return a string containing the pad character. This will always
1448 * have a length of one 32-bit code point.
b75a7d8f
A
1449 * @see #setFormatWidth
1450 * @see #getFormatWidth
1451 * @see #setPadCharacter
1452 * @see #getPadPosition
1453 * @see #setPadPosition
1454 * @stable ICU 2.0
1455 */
374ca955 1456 virtual UnicodeString getPadCharacterString() const;
b75a7d8f
A
1457
1458 /**
374ca955
A
1459 * Set the character used to pad to the format width. If padding
1460 * is not enabled, then this will take effect if padding is later
1461 * enabled.
3d1f044b
A
1462 * @param padChar a string containing the pad character. If the string
1463 * has length 0, then the pad character is set to ' '. Otherwise
374ca955 1464 * padChar.char32At(0) will be used as the pad character.
b75a7d8f
A
1465 * @see #setFormatWidth
1466 * @see #getFormatWidth
73c04bcf 1467 * @see #getPadCharacterString
b75a7d8f
A
1468 * @see #getPadPosition
1469 * @see #setPadPosition
1470 * @stable ICU 2.0
1471 */
3d1f044b 1472 virtual void setPadCharacter(const UnicodeString& padChar);
b75a7d8f
A
1473
1474 /**
1475 * Get the position at which padding will take place. This is the location
374ca955 1476 * at which padding will be inserted if the result of format()
b75a7d8f 1477 * is shorter than the format width.
374ca955
A
1478 * @return the pad position, one of kPadBeforePrefix,
1479 * kPadAfterPrefix, kPadBeforeSuffix, or
1480 * kPadAfterSuffix.
b75a7d8f
A
1481 * @see #setFormatWidth
1482 * @see #getFormatWidth
1483 * @see #setPadCharacter
73c04bcf 1484 * @see #getPadCharacterString
b75a7d8f 1485 * @see #setPadPosition
46f4442e 1486 * @see #EPadPosition
b75a7d8f
A
1487 * @stable ICU 2.0
1488 */
374ca955 1489 virtual EPadPosition getPadPosition(void) const;
b75a7d8f
A
1490
1491 /**
b75a7d8f 1492 * Set the position at which padding will take place. This is the location
374ca955 1493 * at which padding will be inserted if the result of format()
b75a7d8f
A
1494 * is shorter than the format width. This has no effect unless padding is
1495 * enabled.
374ca955
A
1496 * @param padPos the pad position, one of kPadBeforePrefix,
1497 * kPadAfterPrefix, kPadBeforeSuffix, or
1498 * kPadAfterSuffix.
b75a7d8f
A
1499 * @see #setFormatWidth
1500 * @see #getFormatWidth
1501 * @see #setPadCharacter
73c04bcf 1502 * @see #getPadCharacterString
b75a7d8f 1503 * @see #getPadPosition
46f4442e 1504 * @see #EPadPosition
b75a7d8f
A
1505 * @stable ICU 2.0
1506 */
1507 virtual void setPadPosition(EPadPosition padPos);
1508
1509 /**
1510 * Return whether or not scientific notation is used.
1511 * @return TRUE if this object formats and parses scientific notation
1512 * @see #setScientificNotation
1513 * @see #getMinimumExponentDigits
1514 * @see #setMinimumExponentDigits
1515 * @see #isExponentSignAlwaysShown
1516 * @see #setExponentSignAlwaysShown
1517 * @stable ICU 2.0
1518 */
57a6839d 1519 virtual UBool isScientificNotation(void) const;
b75a7d8f
A
1520
1521 /**
374ca955
A
1522 * Set whether or not scientific notation is used. When scientific notation
1523 * is used, the effective maximum number of integer digits is <= 8. If the
1524 * maximum number of integer digits is set to more than 8, the effective
1525 * maximum will be 1. This allows this call to generate a 'default' scientific
1526 * number format without additional changes.
b75a7d8f
A
1527 * @param useScientific TRUE if this object formats and parses scientific
1528 * notation
1529 * @see #isScientificNotation
1530 * @see #getMinimumExponentDigits
1531 * @see #setMinimumExponentDigits
1532 * @see #isExponentSignAlwaysShown
1533 * @see #setExponentSignAlwaysShown
1534 * @stable ICU 2.0
1535 */
1536 virtual void setScientificNotation(UBool useScientific);
1537
1538 /**
1539 * Return the minimum exponent digits that will be shown.
1540 * @return the minimum exponent digits that will be shown
1541 * @see #setScientificNotation
1542 * @see #isScientificNotation
1543 * @see #setMinimumExponentDigits
1544 * @see #isExponentSignAlwaysShown
1545 * @see #setExponentSignAlwaysShown
1546 * @stable ICU 2.0
1547 */
374ca955 1548 virtual int8_t getMinimumExponentDigits(void) const;
b75a7d8f
A
1549
1550 /**
1551 * Set the minimum exponent digits that will be shown. This has no
1552 * effect unless scientific notation is in use.
1553 * @param minExpDig a value >= 1 indicating the fewest exponent digits
1554 * that will be shown. Values less than 1 will be treated as 1.
1555 * @see #setScientificNotation
1556 * @see #isScientificNotation
1557 * @see #getMinimumExponentDigits
1558 * @see #isExponentSignAlwaysShown
1559 * @see #setExponentSignAlwaysShown
1560 * @stable ICU 2.0
1561 */
1562 virtual void setMinimumExponentDigits(int8_t minExpDig);
1563
1564 /**
1565 * Return whether the exponent sign is always shown.
1566 * @return TRUE if the exponent is always prefixed with either the
1567 * localized minus sign or the localized plus sign, false if only negative
1568 * exponents are prefixed with the localized minus sign.
1569 * @see #setScientificNotation
1570 * @see #isScientificNotation
1571 * @see #setMinimumExponentDigits
1572 * @see #getMinimumExponentDigits
1573 * @see #setExponentSignAlwaysShown
1574 * @stable ICU 2.0
1575 */
57a6839d 1576 virtual UBool isExponentSignAlwaysShown(void) const;
b75a7d8f
A
1577
1578 /**
1579 * Set whether the exponent sign is always shown. This has no effect
1580 * unless scientific notation is in use.
1581 * @param expSignAlways TRUE if the exponent is always prefixed with either
1582 * the localized minus sign or the localized plus sign, false if only
1583 * negative exponents are prefixed with the localized minus sign.
1584 * @see #setScientificNotation
1585 * @see #isScientificNotation
1586 * @see #setMinimumExponentDigits
1587 * @see #getMinimumExponentDigits
1588 * @see #isExponentSignAlwaysShown
1589 * @stable ICU 2.0
1590 */
1591 virtual void setExponentSignAlwaysShown(UBool expSignAlways);
1592
1593 /**
1594 * Return the grouping size. Grouping size is the number of digits between
1595 * grouping separators in the integer portion of a number. For example,
1596 * in the number "123,456.78", the grouping size is 3.
1597 *
1598 * @return the grouping size.
1599 * @see setGroupingSize
1600 * @see NumberFormat::isGroupingUsed
1601 * @see DecimalFormatSymbols::getGroupingSeparator
1602 * @stable ICU 2.0
1603 */
1604 int32_t getGroupingSize(void) const;
1605
1606 /**
1607 * Set the grouping size. Grouping size is the number of digits between
1608 * grouping separators in the integer portion of a number. For example,
1609 * in the number "123,456.78", the grouping size is 3.
1610 *
1611 * @param newValue the new value of the grouping size.
1612 * @see getGroupingSize
1613 * @see NumberFormat::setGroupingUsed
1614 * @see DecimalFormatSymbols::setGroupingSeparator
1615 * @stable ICU 2.0
1616 */
1617 virtual void setGroupingSize(int32_t newValue);
1618
1619 /**
1620 * Return the secondary grouping size. In some locales one
1621 * grouping interval is used for the least significant integer
1622 * digits (the primary grouping size), and another is used for all
1623 * others (the secondary grouping size). A formatter supporting a
1624 * secondary grouping size will return a positive integer unequal
1625 * to the primary grouping size returned by
374ca955 1626 * getGroupingSize(). For example, if the primary
b75a7d8f
A
1627 * grouping size is 4, and the secondary grouping size is 2, then
1628 * the number 123456789 formats as "1,23,45,6789", and the pattern
1629 * appears as "#,##,###0".
1630 * @return the secondary grouping size, or a value less than
1631 * one if there is none
1632 * @see setSecondaryGroupingSize
1633 * @see NumberFormat::isGroupingUsed
1634 * @see DecimalFormatSymbols::getGroupingSeparator
374ca955 1635 * @stable ICU 2.4
b75a7d8f
A
1636 */
1637 int32_t getSecondaryGroupingSize(void) const;
1638
1639 /**
1640 * Set the secondary grouping size. If set to a value less than 1,
1641 * then secondary grouping is turned off, and the primary grouping
1642 * size is used for all intervals, not just the least significant.
1643 *
1644 * @param newValue the new value of the secondary grouping size.
1645 * @see getSecondaryGroupingSize
1646 * @see NumberFormat#setGroupingUsed
1647 * @see DecimalFormatSymbols::setGroupingSeparator
374ca955 1648 * @stable ICU 2.4
b75a7d8f
A
1649 */
1650 virtual void setSecondaryGroupingSize(int32_t newValue);
1651
3d1f044b 1652#ifndef U_HIDE_DRAFT_API
2ca993e8
A
1653 /**
1654 * Returns the minimum number of grouping digits.
1655 * Grouping separators are output if there are at least this many
1656 * digits to the left of the first (rightmost) grouping separator,
1657 * that is, there are at least (minimum grouping + grouping size) integer digits.
1658 * (Subject to isGroupingUsed().)
1659 *
1660 * For example, if this value is 2, and the grouping size is 3, then
1661 * 9999 -> "9999" and 10000 -> "10,000"
1662 *
2ca993e8
A
1663 * The default value for this attribute is 0.
1664 * A value of 1, 0, or lower, means that the use of grouping separators
1665 * only depends on the grouping size (and on isGroupingUsed()).
3d1f044b
A
1666 *
1667 * NOTE: The CLDR data is used in NumberFormatter but not in DecimalFormat.
1668 * This is for backwards compatibility reasons.
1669 *
1670 * For more control over grouping strategies, use NumberFormatter.
2ca993e8
A
1671 *
1672 * @see setMinimumGroupingDigits
1673 * @see getGroupingSize
3d1f044b 1674 * @draft ICU 64
2ca993e8
A
1675 */
1676 int32_t getMinimumGroupingDigits() const;
1677
2ca993e8
A
1678 /**
1679 * Sets the minimum grouping digits. Setting to a value less than or
1680 * equal to 1 turns off minimum grouping digits.
1681 *
3d1f044b
A
1682 * For more control over grouping strategies, use NumberFormatter.
1683 *
2ca993e8
A
1684 * @param newValue the new value of minimum grouping digits.
1685 * @see getMinimumGroupingDigits
3d1f044b 1686 * @draft ICU 64
2ca993e8 1687 */
3d1f044b
A
1688 void setMinimumGroupingDigits(int32_t newValue);
1689#endif /* U_HIDE_DRAFT_API */
2ca993e8
A
1690
1691
b75a7d8f
A
1692 /**
1693 * Allows you to get the behavior of the decimal separator with integers.
1694 * (The decimal separator will always appear with decimals.)
1695 *
1696 * @return TRUE if the decimal separator always appear with decimals.
1697 * Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345
1698 * @stable ICU 2.0
1699 */
1700 UBool isDecimalSeparatorAlwaysShown(void) const;
1701
1702 /**
1703 * Allows you to set the behavior of the decimal separator with integers.
1704 * (The decimal separator will always appear with decimals.)
1705 *
1706 * @param newValue set TRUE if the decimal separator will always appear with decimals.
1707 * Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345
1708 * @stable ICU 2.0
1709 */
1710 virtual void setDecimalSeparatorAlwaysShown(UBool newValue);
1711
b331163b
A
1712 /**
1713 * Allows you to get the parse behavior of the pattern decimal mark.
1714 *
1715 * @return TRUE if input must contain a match to decimal mark in pattern
2ca993e8 1716 * @stable ICU 54
b331163b
A
1717 */
1718 UBool isDecimalPatternMatchRequired(void) const;
b331163b
A
1719
1720 /**
3d1f044b 1721 * Allows you to set the parse behavior of the pattern decimal mark.
2ca993e8 1722 *
b331163b
A
1723 * if TRUE, the input must have a decimal mark if one was specified in the pattern. When
1724 * FALSE the decimal mark may be omitted from the input.
1725 *
1726 * @param newValue set TRUE if input must contain a match to decimal mark in pattern
2ca993e8 1727 * @stable ICU 54
b331163b
A
1728 */
1729 virtual void setDecimalPatternMatchRequired(UBool newValue);
1730
3d1f044b
A
1731#ifndef U_HIDE_DRAFT_API
1732 /**
1733 * Returns whether to ignore exponents when parsing.
1734 *
1735 * @return Whether to ignore exponents when parsing.
1736 * @see #setParseNoExponent
1737 * @draft ICU 64
1738 */
1739 UBool isParseNoExponent() const;
1740
1741 /**
1742 * Specifies whether to stop parsing when an exponent separator is encountered. For
1743 * example, parses "123E4" to 123 (with parse position 3) instead of 1230000 (with parse position
1744 * 5).
1745 *
1746 * @param value true to prevent exponents from being parsed; false to allow them to be parsed.
1747 * @draft ICU 64
1748 */
1749 void setParseNoExponent(UBool value);
1750
1751 /**
1752 * Returns whether parsing is sensitive to case (lowercase/uppercase).
1753 *
1754 * @return Whether parsing is case-sensitive.
1755 * @see #setParseCaseSensitive
1756 * @draft ICU 64
1757 */
1758 UBool isParseCaseSensitive() const;
1759
1760 /**
1761 * Whether to pay attention to case when parsing; default is to ignore case (perform
1762 * case-folding). For example, "A" == "a" in case-insensitive but not case-sensitive mode.
1763 *
1764 * Currency symbols are never case-folded. For example, "us$1.00" will not parse in case-insensitive
1765 * mode, even though "US$1.00" parses.
1766 *
1767 * @param value true to enable case-sensitive parsing (the default); false to force
1768 * case-sensitive parsing behavior.
1769 * @draft ICU 64
1770 */
1771 void setParseCaseSensitive(UBool value);
1772
1773 /**
1774 * Returns whether truncation of high-order integer digits should result in an error.
1775 * By default, setMaximumIntegerDigits truncates high-order digits silently.
1776 *
1777 * @return Whether an error code is set if high-order digits are truncated.
1778 * @see setFormatFailIfMoreThanMaxDigits
1779 * @draft ICU 64
1780 */
1781 UBool isFormatFailIfMoreThanMaxDigits() const;
1782
1783 /**
1784 * Sets whether truncation of high-order integer digits should result in an error.
1785 * By default, setMaximumIntegerDigits truncates high-order digits silently.
1786 *
1787 * @param value Whether to set an error code if high-order digits are truncated.
1788 * @draft ICU 64
1789 */
1790 void setFormatFailIfMoreThanMaxDigits(UBool value);
1791#endif /* U_HIDE_DRAFT_API */
1792
b331163b 1793
b75a7d8f
A
1794 /**
1795 * Synthesizes a pattern string that represents the current state
1796 * of this Format object.
1797 *
1798 * @param result Output param which will receive the pattern.
1799 * Previous contents are deleted.
1800 * @return A reference to 'result'.
1801 * @see applyPattern
1802 * @stable ICU 2.0
1803 */
1804 virtual UnicodeString& toPattern(UnicodeString& result) const;
1805
1806 /**
1807 * Synthesizes a localized pattern string that represents the current
1808 * state of this Format object.
1809 *
1810 * @param result Output param which will receive the localized pattern.
1811 * Previous contents are deleted.
1812 * @return A reference to 'result'.
1813 * @see applyPattern
1814 * @stable ICU 2.0
1815 */
1816 virtual UnicodeString& toLocalizedPattern(UnicodeString& result) const;
729e4ab9 1817
b75a7d8f
A
1818 /**
1819 * Apply the given pattern to this Format object. A pattern is a
1820 * short-hand specification for the various formatting properties.
1821 * These properties can also be changed individually through the
1822 * various setter methods.
1823 * <P>
1824 * There is no limit to integer digits are set
1825 * by this routine, since that is the typical end-user desire;
1826 * use setMaximumInteger if you want to set a real value.
1827 * For negative numbers, use a second pattern, separated by a semicolon
1828 * <pre>
1829 * . Example "#,#00.0#" -> 1,234.56
1830 * </pre>
1831 * This means a minimum of 2 integer digits, 1 fraction digit, and
1832 * a maximum of 2 fraction digits.
1833 * <pre>
1834 * . Example: "#,#00.0#;(#,#00.0#)" for negatives in parantheses.
1835 * </pre>
1836 * In negative patterns, the minimum and maximum counts are ignored;
1837 * these are presumed to be set in the positive pattern.
1838 *
1839 * @param pattern The pattern to be applied.
729e4ab9 1840 * @param parseError Struct to recieve information on position
b75a7d8f
A
1841 * of error if an error is encountered
1842 * @param status Output param set to success/failure code on
1843 * exit. If the pattern is invalid, this will be
1844 * set to a failure result.
1845 * @stable ICU 2.0
1846 */
3d1f044b
A
1847 virtual void applyPattern(const UnicodeString& pattern, UParseError& parseError, UErrorCode& status);
1848
b75a7d8f
A
1849 /**
1850 * Sets the pattern.
1851 * @param pattern The pattern to be applied.
1852 * @param status Output param set to success/failure code on
1853 * exit. If the pattern is invalid, this will be
1854 * set to a failure result.
1855 * @stable ICU 2.0
729e4ab9 1856 */
3d1f044b 1857 virtual void applyPattern(const UnicodeString& pattern, UErrorCode& status);
b75a7d8f
A
1858
1859 /**
1860 * Apply the given pattern to this Format object. The pattern
1861 * is assumed to be in a localized notation. A pattern is a
1862 * short-hand specification for the various formatting properties.
1863 * These properties can also be changed individually through the
1864 * various setter methods.
1865 * <P>
1866 * There is no limit to integer digits are set
1867 * by this routine, since that is the typical end-user desire;
1868 * use setMaximumInteger if you want to set a real value.
1869 * For negative numbers, use a second pattern, separated by a semicolon
1870 * <pre>
1871 * . Example "#,#00.0#" -> 1,234.56
1872 * </pre>
1873 * This means a minimum of 2 integer digits, 1 fraction digit, and
1874 * a maximum of 2 fraction digits.
1875 *
1876 * Example: "#,#00.0#;(#,#00.0#)" for negatives in parantheses.
1877 *
1878 * In negative patterns, the minimum and maximum counts are ignored;
1879 * these are presumed to be set in the positive pattern.
1880 *
1881 * @param pattern The localized pattern to be applied.
729e4ab9 1882 * @param parseError Struct to recieve information on position
b75a7d8f
A
1883 * of error if an error is encountered
1884 * @param status Output param set to success/failure code on
1885 * exit. If the pattern is invalid, this will be
1886 * set to a failure result.
1887 * @stable ICU 2.0
1888 */
3d1f044b 1889 virtual void applyLocalizedPattern(const UnicodeString& pattern, UParseError& parseError,
b75a7d8f
A
1890 UErrorCode& status);
1891
1892 /**
1893 * Apply the given pattern to this Format object.
1894 *
1895 * @param pattern The localized pattern to be applied.
1896 * @param status Output param set to success/failure code on
1897 * exit. If the pattern is invalid, this will be
1898 * set to a failure result.
1899 * @stable ICU 2.0
1900 */
3d1f044b 1901 virtual void applyLocalizedPattern(const UnicodeString& pattern, UErrorCode& status);
b75a7d8f
A
1902
1903
1904 /**
1905 * Sets the maximum number of digits allowed in the integer portion of a
1906 * number. This override limits the integer digit count to 309.
1907 *
729e4ab9 1908 * @param newValue the new value of the maximum number of digits
b75a7d8f
A
1909 * allowed in the integer portion of a number.
1910 * @see NumberFormat#setMaximumIntegerDigits
1911 * @stable ICU 2.0
1912 */
3d1f044b 1913 void setMaximumIntegerDigits(int32_t newValue) U_OVERRIDE;
b75a7d8f
A
1914
1915 /**
1916 * Sets the minimum number of digits allowed in the integer portion of a
1917 * number. This override limits the integer digit count to 309.
729e4ab9
A
1918 *
1919 * @param newValue the new value of the minimum number of digits
b75a7d8f
A
1920 * allowed in the integer portion of a number.
1921 * @see NumberFormat#setMinimumIntegerDigits
1922 * @stable ICU 2.0
1923 */
3d1f044b 1924 void setMinimumIntegerDigits(int32_t newValue) U_OVERRIDE;
b75a7d8f
A
1925
1926 /**
1927 * Sets the maximum number of digits allowed in the fraction portion of a
1928 * number. This override limits the fraction digit count to 340.
1929 *
729e4ab9 1930 * @param newValue the new value of the maximum number of digits
b75a7d8f
A
1931 * allowed in the fraction portion of a number.
1932 * @see NumberFormat#setMaximumFractionDigits
1933 * @stable ICU 2.0
1934 */
3d1f044b 1935 void setMaximumFractionDigits(int32_t newValue) U_OVERRIDE;
b75a7d8f
A
1936
1937 /**
1938 * Sets the minimum number of digits allowed in the fraction portion of a
1939 * number. This override limits the fraction digit count to 340.
1940 *
729e4ab9 1941 * @param newValue the new value of the minimum number of digits
b75a7d8f
A
1942 * allowed in the fraction portion of a number.
1943 * @see NumberFormat#setMinimumFractionDigits
1944 * @stable ICU 2.0
1945 */
3d1f044b 1946 void setMinimumFractionDigits(int32_t newValue) U_OVERRIDE;
b75a7d8f 1947
374ca955
A
1948 /**
1949 * Returns the minimum number of significant digits that will be
1950 * displayed. This value has no effect unless areSignificantDigitsUsed()
1951 * returns true.
1952 * @return the fewest significant digits that will be shown
73c04bcf 1953 * @stable ICU 3.0
374ca955
A
1954 */
1955 int32_t getMinimumSignificantDigits() const;
1956
1957 /**
1958 * Returns the maximum number of significant digits that will be
1959 * displayed. This value has no effect unless areSignificantDigitsUsed()
1960 * returns true.
1961 * @return the most significant digits that will be shown
73c04bcf 1962 * @stable ICU 3.0
374ca955
A
1963 */
1964 int32_t getMaximumSignificantDigits() const;
1965
1966 /**
1967 * Sets the minimum number of significant digits that will be
1968 * displayed. If <code>min</code> is less than one then it is set
1969 * to one. If the maximum significant digits count is less than
57a6839d
A
1970 * <code>min</code>, then it is set to <code>min</code>.
1971 * This function also enables the use of significant digits
1972 * by this formatter - areSignificantDigitsUsed() will return TRUE.
1973 * @see #areSignificantDigitsUsed
729e4ab9 1974 * @param min the fewest significant digits to be shown
73c04bcf 1975 * @stable ICU 3.0
374ca955
A
1976 */
1977 void setMinimumSignificantDigits(int32_t min);
1978
1979 /**
1980 * Sets the maximum number of significant digits that will be
1981 * displayed. If <code>max</code> is less than one then it is set
1982 * to one. If the minimum significant digits count is greater
1983 * than <code>max</code>, then it is set to <code>max</code>.
57a6839d
A
1984 * This function also enables the use of significant digits
1985 * by this formatter - areSignificantDigitsUsed() will return TRUE.
1986 * @see #areSignificantDigitsUsed
729e4ab9 1987 * @param max the most significant digits to be shown
73c04bcf 1988 * @stable ICU 3.0
374ca955
A
1989 */
1990 void setMaximumSignificantDigits(int32_t max);
1991
1992 /**
1993 * Returns true if significant digits are in use, or false if
1994 * integer and fraction digit counts are in use.
1995 * @return true if significant digits are in use
73c04bcf 1996 * @stable ICU 3.0
374ca955
A
1997 */
1998 UBool areSignificantDigitsUsed() const;
1999
2000 /**
2001 * Sets whether significant digits are in use, or integer and
2002 * fraction digit counts are in use.
2003 * @param useSignificantDigits true to use significant digits, or
2004 * false to use integer and fraction digit counts
73c04bcf 2005 * @stable ICU 3.0
374ca955
A
2006 */
2007 void setSignificantDigitsUsed(UBool useSignificantDigits);
2008
c5116b9f
A
2009 /**
2010 * Group-set several settings used for numbers in date formats.
2011 * Avoids calls to touch for each separate setting.
2012 * Equivalent to:
2013 * setGroupingUsed(FALSE);
2014 * setDecimalSeparatorAlwaysShown(FALSE);
2015 * setParseIntegerOnly(TRUE);
2016 * setMinimumFractionDigits(0);
2017 * @internal
2018 */
2019 void setDateSettings(void) U_OVERRIDE;
2020
b75a7d8f
A
2021 /**
2022 * Sets the currency used to display currency
2023 * amounts. This takes effect immediately, if this format is a
2024 * currency format. If this format is not a currency format, then
2025 * the currency is used if and when this object becomes a
2026 * currency format through the application of a new pattern.
2027 * @param theCurrency a 3-letter ISO code indicating new currency
374ca955
A
2028 * to use. It need not be null-terminated. May be the empty
2029 * string or NULL to indicate no currency.
2030 * @param ec input-output error code
73c04bcf 2031 * @stable ICU 3.0
374ca955 2032 */
3d1f044b 2033 void setCurrency(const char16_t* theCurrency, UErrorCode& ec) U_OVERRIDE;
374ca955
A
2034
2035 /**
2036 * Sets the currency used to display currency amounts. See
f3c0d7a5
A
2037 * setCurrency(const char16_t*, UErrorCode&).
2038 * @deprecated ICU 3.0. Use setCurrency(const char16_t*, UErrorCode&).
b75a7d8f 2039 */
f3c0d7a5 2040 virtual void setCurrency(const char16_t* theCurrency);
b75a7d8f 2041
b331163b 2042 /**
3d1f044b 2043 * Sets the `Currency Usage` object used to display currency.
b331163b 2044 * This takes effect immediately, if this format is a
2ca993e8 2045 * currency format.
3d1f044b
A
2046 * @param newUsage new currency usage object to use.
2047 * @param ec input-output error code
2ca993e8 2048 * @stable ICU 54
b331163b
A
2049 */
2050 void setCurrencyUsage(UCurrencyUsage newUsage, UErrorCode* ec);
2051
2052 /**
3d1f044b 2053 * Returns the `Currency Usage` object used to display currency
2ca993e8 2054 * @stable ICU 54
b331163b
A
2055 */
2056 UCurrencyUsage getCurrencyUsage() const;
b331163b 2057
57a6839d 2058#ifndef U_HIDE_INTERNAL_API
57a6839d
A
2059
2060 /**
3d1f044b 2061 * Format a number and save it into the given DecimalQuantity.
57a6839d
A
2062 * Internal, not intended for public use.
2063 * @internal
2064 */
3d1f044b
A
2065 void formatToDecimalQuantity(double number, number::impl::DecimalQuantity& output,
2066 UErrorCode& status) const;
57a6839d
A
2067
2068 /**
3d1f044b
A
2069 * Get a DecimalQuantity corresponding to a formattable as it would be
2070 * formatted by this DecimalFormat.
57a6839d
A
2071 * Internal, not intended for public use.
2072 * @internal
2073 */
3d1f044b
A
2074 void formatToDecimalQuantity(const Formattable& number, number::impl::DecimalQuantity& output,
2075 UErrorCode& status) const;
2ca993e8 2076
3d1f044b 2077#endif /* U_HIDE_INTERNAL_API */
2ca993e8 2078
3d1f044b
A
2079#ifndef U_HIDE_DRAFT_API
2080 /**
2081 * Converts this DecimalFormat to a (Localized)NumberFormatter. Starting
2082 * in ICU 60, NumberFormatter is the recommended way to format numbers.
2083 * You can use the returned LocalizedNumberFormatter to format numbers and
2084 * get a FormattedNumber, which contains a string as well as additional
2085 * annotations about the formatted value.
2086 *
2087 * If a memory allocation failure occurs, the return value of this method
2088 * might be null. If you are concerned about correct recovery from
2089 * out-of-memory situations, use this pattern:
2090 *
2091 * <pre>
2092 * FormattedNumber result;
2093 * if (auto* ptr = df->toNumberFormatter(status)) {
2094 * result = ptr->formatDouble(123, status);
2095 * }
2096 * </pre>
2097 *
2098 * If you are not concerned about out-of-memory situations, or if your
2099 * environment throws exceptions when memory allocation failure occurs,
2100 * you can chain the methods, like this:
2101 *
2102 * <pre>
2103 * FormattedNumber result = df
2104 * ->toNumberFormatter(status)
2105 * ->formatDouble(123, status);
2106 * </pre>
2107 *
2108 * NOTE: The returned LocalizedNumberFormatter is owned by this DecimalFormat.
2109 * If a non-const method is called on the DecimalFormat, or if the DecimalFormat
2110 * is deleted, the object becomes invalid. If you plan to keep the return value
2111 * beyond the lifetime of the DecimalFormat, copy it to a local variable:
2112 *
2113 * <pre>
2114 * LocalizedNumberFormatter lnf;
2115 * if (auto* ptr = df->toNumberFormatter(status)) {
2116 * lnf = *ptr;
2117 * }
2118 * </pre>
2119 *
2120 * @param status Set on failure, like U_MEMORY_ALLOCATION_ERROR.
2121 * @return A pointer to an internal object, or nullptr on failure.
2122 * Do not delete the return value!
2123 * @draft ICU 64
2ca993e8 2124 */
3d1f044b
A
2125 const number::LocalizedNumberFormatter* toNumberFormatter(UErrorCode& status) const;
2126#endif /* U_HIDE_DRAFT_API */
2ca993e8 2127
3d1f044b 2128#ifndef U_HIDE_DEPRECATED_API
2ca993e8 2129 /**
3d1f044b
A
2130 * Deprecated: Like {@link #toNumberFormatter(UErrorCode&) const},
2131 * but does not take an error code.
2132 *
2133 * The new signature should be used in case an error occurs while returning the
2134 * LocalizedNumberFormatter.
2135 *
2136 * This old signature will be removed in ICU 65.
2137 *
2138 * @return A reference to an internal object.
2139 * @deprecated ICU 64
2ca993e8 2140 */
3d1f044b
A
2141 const number::LocalizedNumberFormatter& toNumberFormatter() const;
2142#endif /* U_HIDE_DEPRECATED_API */
b75a7d8f
A
2143
2144 /**
2145 * Return the class ID for this class. This is useful only for
2146 * comparing to a return value from getDynamicClassID(). For example:
2147 * <pre>
2148 * . Base* polymorphic_pointer = createPolymorphicObject();
2149 * . if (polymorphic_pointer->getDynamicClassID() ==
2150 * . Derived::getStaticClassID()) ...
2151 * </pre>
2152 * @return The class ID for all objects of this class.
2153 * @stable ICU 2.0
2154 */
374ca955 2155 static UClassID U_EXPORT2 getStaticClassID(void);
b75a7d8f
A
2156
2157 /**
2158 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override.
2159 * This method is to implement a simple version of RTTI, since not all
2160 * C++ compilers support genuine RTTI. Polymorphic operator==() and
2161 * clone() methods call this method.
2162 *
2163 * @return The class ID for this object. All objects of a
2164 * given class have the same class ID. Objects of
2165 * other classes have different class IDs.
2166 * @stable ICU 2.0
2167 */
3d1f044b 2168 UClassID getDynamicClassID(void) const U_OVERRIDE;
b75a7d8f 2169
3d1f044b 2170#ifndef U_HIDE_INTERNAL_API
374ca955 2171
b75a7d8f 2172 /**
3d1f044b
A
2173 * Set whether DecimalFormatSymbols copy in toNumberFormatter
2174 * is deep (clone) or shallow (pointer copy). Apple <rdar://problem/49955427>
2175 * @internal
b75a7d8f 2176 */
3d1f044b 2177 void setDFSShallowCopy(UBool shallow);
57a6839d 2178
3d1f044b 2179#endif /* U_HIDE_INTERNAL_API */
729e4ab9 2180
3d1f044b 2181private:
729e4ab9 2182
3d1f044b
A
2183 /** Rebuilds the formatter object from the property bag. */
2184 void touch(UErrorCode& status);
b75a7d8f 2185
3d1f044b
A
2186 /** Rebuilds the formatter object, ignoring any error code. */
2187 void touchNoError();
b75a7d8f
A
2188
2189 /**
3d1f044b
A
2190 * Updates the property bag with settings from the given pattern.
2191 *
2192 * @param pattern The pattern string to parse.
2193 * @param ignoreRounding Whether to leave out rounding information (minFrac, maxFrac, and rounding
2194 * increment) when parsing the pattern. This may be desirable if a custom rounding mode, such
2195 * as CurrencyUsage, is to be used instead. One of {@link
2196 * PatternStringParser#IGNORE_ROUNDING_ALWAYS}, {@link PatternStringParser#IGNORE_ROUNDING_IF_CURRENCY},
2197 * or {@link PatternStringParser#IGNORE_ROUNDING_NEVER}.
2198 * @see PatternAndPropertyUtils#parseToExistingProperties
b75a7d8f 2199 */
3d1f044b
A
2200 void setPropertiesFromPattern(const UnicodeString& pattern, int32_t ignoreRounding,
2201 UErrorCode& status);
b75a7d8f 2202
3d1f044b 2203 const numparse::impl::NumberParserImpl* getParser(UErrorCode& status) const;
b75a7d8f 2204
3d1f044b 2205 const numparse::impl::NumberParserImpl* getCurrencyParser(UErrorCode& status) const;
51004dcb 2206
3d1f044b
A
2207 static void fieldPositionHelper(const number::FormattedNumber& formatted, FieldPosition& fieldPosition,
2208 int32_t offset, UErrorCode& status);
b75a7d8f 2209
3d1f044b
A
2210 static void fieldPositionIteratorHelper(const number::FormattedNumber& formatted,
2211 FieldPositionIterator* fpi, int32_t offset, UErrorCode& status);
729e4ab9 2212
3d1f044b 2213 void setupFastFormat();
729e4ab9 2214
3d1f044b 2215 bool fastFormatDouble(double input, UnicodeString& output) const;
729e4ab9 2216
3d1f044b 2217 bool fastFormatInt64(int64_t input, UnicodeString& output) const;
729e4ab9 2218
3d1f044b 2219 void doFastFormatInt32(int32_t input, bool isNegative, UnicodeString& output) const;
51004dcb 2220
3d1f044b
A
2221 //=====================================================================================//
2222 // INSTANCE FIELDS //
2223 //=====================================================================================//
51004dcb 2224
374ca955 2225
3d1f044b
A
2226 // One instance field for the implementation, keep all fields inside of an implementation
2227 // class defined in number_mapper.h
2228 number::impl::DecimalFormatFields* fields = nullptr;
51004dcb 2229
3d1f044b
A
2230 // Allow child class CompactDecimalFormat to access fProperties:
2231 friend class CompactDecimalFormat;
2232
2233 // Allow MeasureFormat to use fieldPositionHelper:
2234 friend class MeasureFormat;
51004dcb 2235
374ca955 2236};
b75a7d8f 2237
b75a7d8f 2238U_NAMESPACE_END
f3c0d7a5 2239#endif // U_SHOW_CPLUSPLUS_API
b75a7d8f
A
2240
2241#endif /* #if !UCONFIG_NO_FORMATTING */
2242
2243#endif // _DECIMFMT
2244//eof