X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/729e4ab9bc6618bc3d8a898e575df7f4019e29ca..c5116b9f5a666b9d59f443b3770acd6ef64dc6c3:/icuSources/i18n/unicode/decimfmt.h diff --git a/icuSources/i18n/unicode/decimfmt.h b/icuSources/i18n/unicode/decimfmt.h index 2d1d5bc5..6e6a7ff0 100644 --- a/icuSources/i18n/unicode/decimfmt.h +++ b/icuSources/i18n/unicode/decimfmt.h @@ -1,6 +1,8 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************** -* Copyright (C) 1997-2010, International Business Machines +* Copyright (C) 1997-2016, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************** * @@ -17,7 +19,8 @@ * 07/10/97 helena Made ParsePosition a class and get rid of the function * hiding problems. * 09/09/97 aliu Ported over support for exponential formats. -* 07/20/98 stephen Changed documentation +* 07/20/98 stephen Changed documentation +* 01/30/13 emmons Added Scaling methods ******************************************************************************** */ @@ -27,7 +30,7 @@ #include "unicode/utypes.h" /** * \file - * \brief C++ API: Formats decimal numbers. + * \brief C++ API: Compatibility APIs for decimal formatting. */ #if !UCONFIG_NO_FORMATTING @@ -37,19 +40,35 @@ #include "unicode/locid.h" #include "unicode/fpositer.h" #include "unicode/stringpiece.h" +#include "unicode/curramt.h" +#include "unicode/enumset.h" -union UHashTok; - +#if U_SHOW_CPLUSPLUS_API U_NAMESPACE_BEGIN -class DigitList; -class ChoiceFormat; class CurrencyPluralInfo; -class Hashtable; -class UnicodeSet; -class FieldPositionHandler; +class CompactDecimalFormat; + +namespace number { +class LocalizedNumberFormatter; +class FormattedNumber; +namespace impl { +class DecimalQuantity; +struct DecimalFormatFields; +} +} + +namespace numparse { +namespace impl { +class NumberParserImpl; +} +} /** + * **IMPORTANT:** New users are strongly encouraged to see if + * numberformatter.h fits their use case. Although not deprecated, this header + * is provided for backwards compatibility only. + * * DecimalFormat is a concrete subclass of NumberFormat that formats decimal * numbers. It has a variety of features designed to make it possible to parse * and format numbers in any locale, including support for Western, Arabic, or @@ -58,13 +77,13 @@ class FieldPositionHandler; * ("1.23E4"), percentages ("12%"), and currency amounts ("$123", "USD123", * "123 US dollars"). All of these flavors can be easily localized. * - *

To obtain a NumberFormat for a specific locale (including the default + * To obtain a NumberFormat for a specific locale (including the default * locale) call one of NumberFormat's factory methods such as * createInstance(). Do not call the DecimalFormat constructors directly, unless * you know what you are doing, since the NumberFormat factory methods may * return subclasses other than DecimalFormat. * - *

Example Usage + * **Example Usage** * * \code * // Normally we would have a GUI with a menu for this @@ -108,11 +127,11 @@ class FieldPositionHandler; * } * } * \endcode - *

- * Another example use createInstance(style) - *

- *

- * // Print out a number using the localized number, currency,
+ *
+ * **Another example use createInstance(style)**
+ *
+ * \code
+ * // Print out a number using the localized number, currency,
  * // percent, scientific, integer, iso currency, and plural currency
  * // format for each locale
  * Locale* locale = new Locale("en", "US");
@@ -123,11 +142,13 @@ class FieldPositionHandler;
  * for (int j=NumberFormat::kNumberStyle;
  *      j<=NumberFormat::kPluralCurrencyStyle;
  *      ++j) {
- *     NumberFormat* format = NumberFormat::createInstance(locale, j, success);
+ *     NumberFormat* form = NumberFormat::createInstance(locale, j, success);
  *     str.remove();
  *     cout << "format result " << form->format(myNumber, str) << endl;
  *     format->parse(form->format(myNumber, str), fmtable, success);
- * }
+ * delete form; + * } + * \endcode * * *

Patterns @@ -256,7 +277,7 @@ class FieldPositionHandler; * Pad escape, precedes pad character * * - *

A DecimalFormat pattern contains a postive and negative + *

A DecimalFormat pattern contains a positive and negative * subpattern, for example, "#,##0.00;(#,##0.00)". Each subpattern has a * prefix, a numeric part, and a suffix. If there is no explicit negative * subpattern, the negative subpattern is the localized minus sign prefixed to the @@ -390,7 +411,7 @@ class FieldPositionHandler; * *

  • If the number of actual fraction digits is less than the * minimum fraction digits, then trailing zeros are added. - * For example, 0.125 is formatted as "0.1250" if the mimimum fraction + * For example, 0.125 is formatted as "0.1250" if the minimum fraction * digits is set to 4. * *
  • Trailing fractional zeros are not displayed if they occur @@ -555,9 +576,9 @@ class FieldPositionHandler; * count of getMaximumSignificantDigits() - 1. For example, the * pattern "@@###E0" is equivalent to "0.0###E0". * - *
  • If signficant digits are in use, then the integer and fraction + *
  • If significant digits are in use, then the integer and fraction * digit counts, as set via the API, are ignored. If significant - * digits are not in use, then the signficant digit counts, as set via + * digits are not in use, then the significant digit counts, as set via * the API, are ignored. * * @@ -579,7 +600,7 @@ class FieldPositionHandler; * including prefix and suffix, determines the format width. For example, in * the pattern "* #0 o''clock", the format width is 10. * - *
  • The width is counted in 16-bit code units (UChars). + *
  • The width is counted in 16-bit code units (char16_ts). * *
  • Some parameters which usually do not matter have meaning when padding is * used, because the pattern width is significant with padding. In the pattern @@ -611,7 +632,7 @@ class FieldPositionHandler; * increment in the pattern itself. "#,#50" specifies a rounding increment of * 50. "#,##0.05" specifies a rounding increment of 0.05. * - *

    In the absense of an explicit rounding increment numbers are + *

    In the absence of an explicit rounding increment numbers are * rounded to their formatted width. * *