intl/icu/source/i18n/unicode/decimfmt.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

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

mercurial