]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/unicode/decimfmt.h
ICU-62107.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / decimfmt.h
index d841aca74be30bab93fc7fd02199eee963f6cfb6..a331051d230ef1f6e10094f4f52e7b8807669266 100644 (file)
@@ -1,6 +1,8 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 ********************************************************************************
-*   Copyright (C) 1997-2013, International Business Machines
+*   Copyright (C) 1997-2016, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 ********************************************************************************
 *
@@ -28,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
 #endif
 #endif  /* U_HIDE_INTERNAL_API */
 
+#if U_SHOW_CPLUSPLUS_API
 U_NAMESPACE_BEGIN
 
 class DigitList;
-class ChoiceFormat;
 class CurrencyPluralInfo;
 class Hashtable;
 class UnicodeSet;
 class FieldPositionHandler;
+class DecimalFormatStaticSets;
+class FixedDecimal;
+class DecimalFormatImpl;
+class PluralRules;
+class VisibleDigitsWithExponent;
 
 // explicit template instantiation. see digitlst.h
-#if defined (_MSC_VER)
+// (When building DLLs for Windows this is required.)
+#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
 template class U_I18N_API    EnumSet<UNumberFormatAttribute,
-            UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1, 
+            UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1,
             UNUM_LIMIT_BOOLEAN_ATTRIBUTE>;
 #endif
 
 /**
+ * <p><strong>IMPORTANT:</strong> 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.
+ * <hr/>
+ *
  * 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
@@ -597,7 +610,7 @@ template class U_I18N_API    EnumSet<UNumberFormatAttribute,
  * including prefix and suffix, determines the format width.  For example, in
  * the pattern <code>"* #0 o''clock"</code>, the format width is 10.
  *
- * <li>The width is counted in 16-bit code units (UChars).
+ * <li>The width is counted in 16-bit code units (char16_ts).
  *
  * <li>Some parameters which usually do not matter have meaning when padding is
  * used, because the pattern width is significant with padding.  In the pattern
@@ -661,28 +674,6 @@ template class U_I18N_API    EnumSet<UNumberFormatAttribute,
  */
 class U_I18N_API DecimalFormat: public NumberFormat {
 public:
-    /**
-     * Rounding mode.
-     * @stable ICU 2.4
-     */
-    enum ERoundingMode {
-        kRoundCeiling,  /**< Round towards positive infinity */
-        kRoundFloor,    /**< Round towards negative infinity */
-        kRoundDown,     /**< Round towards zero */
-        kRoundUp,       /**< Round away from zero */
-        kRoundHalfEven, /**< Round towards the nearest integer, or
-                             towards the nearest even integer if equidistant */
-        kRoundHalfDown, /**< Round towards the nearest integer, or
-                             towards zero if equidistant */
-        kRoundHalfUp,   /**< Round towards the nearest integer, or
-                             away from zero if equidistant */
-        /**
-          *  Return U_FORMAT_INEXACT_ERROR if number does not format exactly. 
-          *  @stable ICU 4.8 
-          */
-        kRoundUnnecessary
-    };
-
     /**
      * Pad position.
      * @stable ICU 2.4
@@ -703,6 +694,9 @@ public:
      * on NumberFormat such as createInstance. These factories will
      * return the most appropriate sub-class of NumberFormat for a given
      * locale.
+     * <p>
+     * <strong>NOTE:</strong> New users are strongly encouraged to use
+     * {@link NumberFormatter} instead of DecimalFormat.
      * @param status    Output param set to success/failure code. If the
      *                  pattern is invalid this will be set to a failure code.
      * @stable ICU 2.0
@@ -718,6 +712,9 @@ public:
      * on NumberFormat such as createInstance. These factories will
      * return the most appropriate sub-class of NumberFormat for a given
      * locale.
+     * <p>
+     * <strong>NOTE:</strong> New users are strongly encouraged to use
+     * {@link NumberFormatter} instead of DecimalFormat.
      * @param pattern   A non-localized pattern string.
      * @param status    Output param set to success/failure code. If the
      *                  pattern is invalid this will be set to a failure code.
@@ -736,6 +733,9 @@ public:
      * createInstance or createCurrencyInstance. If you need only minor adjustments
      * to a standard format, you can modify the format returned by
      * a NumberFormat factory method.
+     * <p>
+     * <strong>NOTE:</strong> New users are strongly encouraged to use
+     * {@link NumberFormatter} instead of DecimalFormat.
      *
      * @param pattern           a non-localized pattern string
      * @param symbolsToAdopt    the set of symbols to be used.  The caller should not
@@ -784,7 +784,7 @@ public:
      * @param newvalue new value
      * @param status the error type
      * @return *this - for chaining (example: format.setAttribute(...).setAttribute(...) )
-     * @draft ICU 51
+     * @stable ICU 51
      */
     virtual DecimalFormat& setAttribute( UNumberFormatAttribute attr,
                                        int32_t newvalue,
@@ -797,12 +797,39 @@ public:
      * @param attr the attribute to set
      * @param status the error type
      * @return the attribute value. Undefined if there is an error.
-     * @draft ICU 51
+     * @stable ICU 51
      */
     virtual int32_t getAttribute( UNumberFormatAttribute attr,
                                   UErrorCode &status) const;
 
 
+    /**
+     * Set whether or not grouping will be used in this format.
+     * @param newValue    True, grouping will be used in this format.
+     * @see getGroupingUsed
+     * @stable ICU 53
+     */
+    virtual void setGroupingUsed(UBool newValue);
+
+    /**
+     * Sets whether or not numbers should be parsed as integers only.
+     * @param value    set True, this format will parse numbers as integers
+     *                 only.
+     * @see isParseIntegerOnly
+     * @stable ICU 53
+     */
+    virtual void setParseIntegerOnly(UBool value);
+
+    /**
+     * Set a particular UDisplayContext value in the formatter, such as
+     * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
+     * @param value The UDisplayContext value to set.
+     * @param status Input/output status. If at entry this indicates a failure
+     *               status, the function will do nothing; otherwise this will be
+     *               updated with any new status from the function.
+     * @stable ICU 53
+     */
+    virtual void setContext(UDisplayContext value, UErrorCode& status);
 
     /**
      * Create a DecimalFormat from the given pattern and symbols.
@@ -814,6 +841,9 @@ public:
      * createInstance or createCurrencyInstance. If you need only minor adjustments
      * to a standard format, you can modify the format returned by
      * a NumberFormat factory method.
+     * <p>
+     * <strong>NOTE:</strong> New users are strongly encouraged to use
+     * {@link NumberFormatter} instead of DecimalFormat.
      *
      * @param pattern           a non-localized pattern string
      * @param symbolsToAdopt    the set of symbols to be used.  The caller should not
@@ -837,6 +867,9 @@ public:
      * createInstance or createCurrencyInstance. If you need only minor adjustments
      * to a standard format, you can modify the format returned by
      * a NumberFormat factory method.
+     * <p>
+     * <strong>NOTE:</strong> New users are strongly encouraged to use
+     * {@link NumberFormatter} instead of DecimalFormat.
      *
      * @param pattern           a non-localized pattern string
      * @param symbols   the set of symbols to be used
@@ -936,7 +969,7 @@ public:
      *                  Can be NULL.
      * @param status    Output param filled with success/failure status.
      * @return          Reference to 'appendTo' parameter.
-     * @stable 4.4
+     * @stable ICU 4.4
      */
     virtual UnicodeString& format(double number,
                                   UnicodeString& appendTo,
@@ -985,7 +1018,7 @@ public:
      *                  Can be NULL.
      * @param status    Output param filled with success/failure status.
      * @return          Reference to 'appendTo' parameter.
-     * @stable 4.4
+     * @stable ICU 4.4
      */
     virtual UnicodeString& format(int32_t number,
                                   UnicodeString& appendTo,
@@ -1034,7 +1067,7 @@ public:
      *                  Can be NULL.
      * @param status    Output param filled with success/failure status.
      * @return          Reference to 'appendTo' parameter.
-     * @stable 4.4
+     * @stable ICU 4.4
      */
     virtual UnicodeString& format(int64_t number,
                                   UnicodeString& appendTo,
@@ -1055,16 +1088,16 @@ public:
      *                  Can be NULL.
      * @param status    Output param filled with success/failure status.
      * @return          Reference to 'appendTo' parameter.
-     * @stable 4.4
+     * @stable ICU 4.4
      */
-    virtual UnicodeString& format(const StringPiece &number,
+    virtual UnicodeString& format(StringPiece number,
                                   UnicodeString& appendTo,
                                   FieldPositionIterator* posIter,
                                   UErrorCode& status) const;
 
 
     /**
-     * Format a decimal number. 
+     * Format a decimal number.
      * The number is a DigitList wrapper onto a floating point decimal number.
      * The default implementation in NumberFormat converts the decimal number
      * to a double and formats that.
@@ -1084,12 +1117,8 @@ public:
                                   UErrorCode& status) const;
 
     /**
-     * Format a decimal number. 
-     * The number is a DigitList wrapper onto a floating point decimal number.
-     * The default implementation in NumberFormat converts the decimal number
-     * to a double and formats that.  
-     *
-     * @param number    The number, a DigitList format Decimal Floating Point.
+     * Format a decimal number.
+     * @param number    The number
      * @param appendTo  Output parameter to receive result.
      *                  Result is appended to existing contents.
      * @param pos       On input: an alignment field, if desired.
@@ -1098,84 +1127,51 @@ public:
      * @return          Reference to 'appendTo' parameter.
      * @internal
      */
-    virtual UnicodeString& format(const DigitList &number,
-                                  UnicodeString& appendTo,
-                                  FieldPosition& pos,
-                                  UErrorCode& status) const;
-
+    virtual UnicodeString& format(
+            const VisibleDigitsWithExponent &number,
+            UnicodeString& appendTo,
+            FieldPosition& pos,
+            UErrorCode& status) const;
 
     /**
-     * Format a Formattable using base-10 representation.
-     *
-     * @param obj       The value to be formatted.
-     * @param appendTo  Output parameter to receive result.
-     *                  Result is appended to existing contents.
-     * @param pos       On input: an alignment field, if desired.
-     *                  On output: the offsets of the alignment field.
-     * @param status    Error code indicating success or failure.
-     * @return          Reference to 'appendTo' parameter.
-     * @stable ICU 2.0
-     */
-    virtual UnicodeString& format(const Formattable& obj,
-                                  UnicodeString& appendTo,
-                                  FieldPosition& pos,
-                                  UErrorCode& status) const;
-
-    /**
-     * Redeclared NumberFormat method.
-     * Formats an object to produce a string.
-     *
-     * @param obj       The object to format.
+     * Format a decimal number.
+     * @param number    The number
      * @param appendTo  Output parameter to receive result.
      *                  Result is appended to existing contents.
-     * @param status    Output parameter filled in with success or failure status.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.
+     * @param status    Output param filled with success/failure status.
      * @return          Reference to 'appendTo' parameter.
-     * @stable ICU 2.0
+     * @internal
      */
-    UnicodeString& format(const Formattable& obj,
-                          UnicodeString& appendTo,
-                          UErrorCode& status) const;
+    virtual UnicodeString& format(
+            const VisibleDigitsWithExponent &number,
+            UnicodeString& appendTo,
+            FieldPositionIterator* posIter,
+            UErrorCode& status) const;
 
     /**
-     * Redeclared NumberFormat method.
-     * Format a double number.
+     * Format a decimal number.
+     * The number is a DigitList wrapper onto a floating point decimal number.
+     * The default implementation in NumberFormat converts the decimal number
+     * to a double and formats that.
      *
-     * @param number    The value to be formatted.
+     * @param number    The number, a DigitList format Decimal Floating Point.
      * @param appendTo  Output parameter to receive result.
      *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param status    Output param filled with success/failure status.
      * @return          Reference to 'appendTo' parameter.
-     * @stable ICU 2.0
+     * @internal
      */
-    UnicodeString& format(double number,
-                          UnicodeString& appendTo) const;
+    virtual UnicodeString& format(const DigitList &number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& status) const;
 
-    /**
-     * Redeclared NumberFormat method.
-     * Format a long number. These methods call the NumberFormat
-     * pure virtual format() methods with the default FieldPosition.
-     *
-     * @param number    The value to be formatted.
-     * @param appendTo  Output parameter to receive result.
-     *                  Result is appended to existing contents.
-     * @return          Reference to 'appendTo' parameter.
-     * @stable ICU 2.0
-     */
-    UnicodeString& format(int32_t number,
-                          UnicodeString& appendTo) const;
+   using NumberFormat::parse;
 
-    /**
-     * Redeclared NumberFormat method.
-     * Format an int64 number. These methods call the NumberFormat
-     * pure virtual format() methods with the default FieldPosition.
-     *
-     * @param number    The value to be formatted.
-     * @param appendTo  Output parameter to receive result.
-     *                  Result is appended to existing contents.
-     * @return          Reference to 'appendTo' parameter.
-     * @stable ICU 2.8
-     */
-    UnicodeString& format(int64_t number,
-                          UnicodeString& appendTo) const;
    /**
     * Parse the given string using this object's choices. The method
     * does string comparisons to try to find an optimal match.
@@ -1199,19 +1195,6 @@ public:
                        Formattable& result,
                        ParsePosition& parsePosition) const;
 
-    // Declare here again to get rid of function hiding problems.
-    /**
-     * Parse the given string using this object's choices.
-     *
-     * @param text           The text to be parsed.
-     * @param result         Formattable to be set to the parse result.
-     * @param status    Output parameter filled in with success or failure status.
-     * @stable ICU 2.0
-     */
-    virtual void parse(const UnicodeString& text,
-                       Formattable& result,
-                       UErrorCode& status) const;
-
     /**
      * Parses text from the given string as a currency amount.  Unlike
      * the parse() method, this method will attempt to parse a generic
@@ -1387,7 +1370,7 @@ public:
 
     /**
      * Get the rounding increment.
-     * @return A positive rounding increment, or 0.0 if a rounding
+     * @return A positive rounding increment, or 0.0 if a custom rounding
      * increment is not in effect.
      * @see #setRoundingIncrement
      * @see #getRoundingMode
@@ -1399,7 +1382,8 @@ public:
     /**
      * Set the rounding increment.  In the absence of a rounding increment,
      *    numbers will be rounded to the number of digits displayed.
-     * @param newValue A positive rounding increment.
+     * @param newValue A positive rounding increment, or 0.0 to
+     * use the default rounding increment.
      * Negative increments are equivalent to 0.0.
      * @see #getRoundingIncrement
      * @see #getRoundingMode
@@ -1419,7 +1403,7 @@ public:
     virtual ERoundingMode getRoundingMode(void) const;
 
     /**
-     * Set the rounding mode.  
+     * Set the rounding mode.
      * @param roundingMode A rounding mode
      * @see #setRoundingIncrement
      * @see #getRoundingIncrement
@@ -1532,7 +1516,7 @@ public:
      * @see #setExponentSignAlwaysShown
      * @stable ICU 2.0
      */
-    virtual UBool isScientificNotation(void);
+    virtual UBool isScientificNotation(void) const;
 
     /**
      * Set whether or not scientific notation is used. When scientific notation
@@ -1589,7 +1573,7 @@ public:
      * @see #setExponentSignAlwaysShown
      * @stable ICU 2.0
      */
-    virtual UBool isExponentSignAlwaysShown(void);
+    virtual UBool isExponentSignAlwaysShown(void) const;
 
     /**
      * Set whether the exponent sign is always shown.  This has no effect
@@ -1665,6 +1649,45 @@ public:
      */
     virtual void setSecondaryGroupingSize(int32_t newValue);
 
+#ifndef U_HIDE_INTERNAL_API
+
+    /**
+     * Returns the minimum number of grouping digits.
+     * Grouping separators are output if there are at least this many
+     * digits to the left of the first (rightmost) grouping separator,
+     * that is, there are at least (minimum grouping + grouping size) integer digits.
+     * (Subject to isGroupingUsed().)
+     *
+     * For example, if this value is 2, and the grouping size is 3, then
+     * 9999 -> "9999" and 10000 -> "10,000"
+     *
+     * This is a technology preview. This API may change behavior or may be removed.
+     *
+     * The default value for this attribute is 0.
+     * A value of 1, 0, or lower, means that the use of grouping separators
+     * only depends on the grouping size (and on isGroupingUsed()).
+     * Currently, the corresponding CLDR data is not used; this is likely to change.
+     *
+     * @see setMinimumGroupingDigits
+     * @see getGroupingSize
+     * @internal technology preview
+     */
+    int32_t getMinimumGroupingDigits() const;
+
+#endif  /* U_HIDE_INTERNAL_API */
+
+       /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following draft method since it is virtual. */
+    /**
+     * Sets the minimum grouping digits. Setting to a value less than or
+     * equal to 1 turns off minimum grouping digits.
+     *
+     * @param newValue the new value of minimum grouping digits.
+     * @see getMinimumGroupingDigits
+     * @internal technology preview
+     */
+    virtual void setMinimumGroupingDigits(int32_t newValue);
+
+
     /**
      * Allows you to get the behavior of the decimal separator with integers.
      * (The decimal separator will always appear with decimals.)
@@ -1685,6 +1708,26 @@ public:
      */
     virtual void setDecimalSeparatorAlwaysShown(UBool newValue);
 
+    /**
+     * Allows you to get the parse behavior of the pattern decimal mark.
+     *
+     * @return    TRUE if input must contain a match to decimal mark in pattern
+     * @stable ICU 54
+     */
+    UBool isDecimalPatternMatchRequired(void) const;
+
+    /**
+     * Allows you to set the behavior of the pattern decimal mark.
+     *
+     * if TRUE, the input must have a decimal mark if one was specified in the pattern. When
+     * FALSE the decimal mark may be omitted from the input.
+     *
+     * @param newValue    set TRUE if input must contain a match to decimal mark in pattern
+     * @stable ICU 54
+     */
+    virtual void setDecimalPatternMatchRequired(UBool newValue);
+
+
     /**
      * Synthesizes a pattern string that represents the current state
      * of this Format object.
@@ -1865,8 +1908,10 @@ public:
      * Sets the minimum number of significant digits that will be
      * displayed.  If <code>min</code> is less than one then it is set
      * to one.  If the maximum significant digits count is less than
-     * <code>min</code>, then it is set to <code>min</code>. This
-     * value has no effect unless areSignificantDigits() returns true.
+     * <code>min</code>, then it is set to <code>min</code>.
+     * This function also enables the use of significant digits
+     * by this formatter - areSignificantDigitsUsed() will return TRUE.
+     * @see #areSignificantDigitsUsed
      * @param min the fewest significant digits to be shown
      * @stable ICU 3.0
      */
@@ -1877,8 +1922,9 @@ public:
      * displayed.  If <code>max</code> is less than one then it is set
      * to one.  If the minimum significant digits count is greater
      * than <code>max</code>, then it is set to <code>max</code>.
-     * This value has no effect unless areSignificantDigits() returns
-     * true.
+     * This function also enables the use of significant digits
+     * by this formatter - areSignificantDigitsUsed() will return TRUE.
+     * @see #areSignificantDigitsUsed
      * @param max the most significant digits to be shown
      * @stable ICU 3.0
      */
@@ -1914,21 +1960,100 @@ public:
      * @param ec input-output error code
      * @stable ICU 3.0
      */
-    virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
+    virtual void setCurrency(const char16_t* theCurrency, UErrorCode& ec);
 
     /**
      * Sets the currency used to display currency amounts.  See
-     * setCurrency(const UChar*, UErrorCode&).
-     * @deprecated ICU 3.0. Use setCurrency(const UChar*, UErrorCode&).
+     * setCurrency(const char16_t*, UErrorCode&).
+     * @deprecated ICU 3.0. Use setCurrency(const char16_t*, UErrorCode&).
      */
-    virtual void setCurrency(const UChar* theCurrency);
+    virtual void setCurrency(const char16_t* theCurrency);
 
+    /**
+     * Sets the <tt>Currency Context</tt> object used to display currency.
+     * This takes effect immediately, if this format is a
+     * currency format.
+     * @param currencyContext new currency context object to use.
+     * @stable ICU 54
+     */
+    void setCurrencyUsage(UCurrencyUsage newUsage, UErrorCode* ec);
+
+    /**
+     * Returns the <tt>Currency Context</tt> object used to display currency
+     * @stable ICU 54
+     */
+    UCurrencyUsage getCurrencyUsage() const;
+
+
+#ifndef U_HIDE_DEPRECATED_API
     /**
      * The resource tags we use to retrieve decimal format data from
      * locale resource bundles.
      * @deprecated ICU 3.4. This string has no public purpose. Please don't use it.
      */
     static const char fgNumberPatterns[];
+#endif  // U_HIDE_DEPRECATED_API
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     *  Get a FixedDecimal corresponding to a double as it would be
+     *  formatted by this DecimalFormat.
+     *  Internal, not intended for public use.
+     *  @internal
+     */
+     FixedDecimal getFixedDecimal(double number, UErrorCode &status) const;
+
+    /**
+     *  Get a FixedDecimal corresponding to a formattable as it would be
+     *  formatted by this DecimalFormat.
+     *  Internal, not intended for public use.
+     *  @internal
+     */
+     FixedDecimal getFixedDecimal(const Formattable &number, UErrorCode &status) const;
+
+    /**
+     *  Get a FixedDecimal corresponding to a DigitList as it would be
+     *  formatted by this DecimalFormat. Note: the DigitList may be modified.
+     *  Internal, not intended for public use.
+     *  @internal
+     */
+     FixedDecimal getFixedDecimal(DigitList &number, UErrorCode &status) const;
+
+    /**
+     *  Get a VisibleDigitsWithExponent corresponding to a double
+     *  as it would be formatted by this DecimalFormat.
+     *  Internal, not intended for public use.
+     *  @internal
+     */
+     VisibleDigitsWithExponent &initVisibleDigitsWithExponent(
+             double number,
+             VisibleDigitsWithExponent &digits,
+             UErrorCode &status) const;
+
+    /**
+     *  Get a VisibleDigitsWithExponent corresponding to a formattable
+     *  as it would be formatted by this DecimalFormat.
+     *  Internal, not intended for public use.
+     *  @internal
+     */
+     VisibleDigitsWithExponent &initVisibleDigitsWithExponent(
+             const Formattable &number,
+             VisibleDigitsWithExponent &digits,
+             UErrorCode &status) const;
+
+    /**
+     *  Get a VisibleDigitsWithExponent corresponding to a DigitList
+     *  as it would be formatted by this DecimalFormat.
+     *  Note: the DigitList may be modified.
+     *  Internal, not intended for public use.
+     *  @internal
+     */
+     VisibleDigitsWithExponent &initVisibleDigitsWithExponent(
+             DigitList &number,
+             VisibleDigitsWithExponent &digits,
+             UErrorCode &status) const;
+
+#endif  /* U_HIDE_INTERNAL_API */
 
 public:
 
@@ -1962,93 +2087,27 @@ private:
 
     DecimalFormat(); // default constructor not implemented
 
-    int32_t precision() const;
-
     /**
-     *   Initialize all fields of a new DecimalFormatter.
+     *   Initialize all fields of a new DecimalFormatter to a safe default value.
      *      Common code for use by constructors.
      */
-    void init(UErrorCode& status);
+    void init();
 
     /**
      * Do real work of constructing a new DecimalFormat.
      */
-    void construct(UErrorCode&               status,
+    void construct(UErrorCode&              status,
                    UParseError&             parseErr,
                    const UnicodeString*     pattern = 0,
                    DecimalFormatSymbols*    symbolsToAdopt = 0
                    );
 
-    /**
-     * Does the real work of generating a pattern.
-     *
-     * @param result     Output param which will receive the pattern.
-     *                   Previous contents are deleted.
-     * @param localized  TRUE return localized pattern.
-     * @return           A reference to 'result'.
-     */
-    UnicodeString& toPattern(UnicodeString& result, UBool localized) const;
-
-    /**
-     * Does the real work of applying a pattern.
-     * @param pattern    The pattern to be applied.
-     * @param localized  If true, the pattern is localized; else false.
-     * @param parseError Struct to recieve information on position
-     *                   of error if an error is encountered
-     * @param status     Output param set to success/failure code on
-     *                   exit. If the pattern is invalid, this will be
-     *                   set to a failure result.
-     */
-    void applyPattern(const UnicodeString& pattern,
-                            UBool localized,
-                            UParseError& parseError,
-                            UErrorCode& status);
-
-    /*
-     * similar to applyPattern, but without re-gen affix for currency
-     */
-    void applyPatternInternally(const UnicodeString& pluralCount,
-                                const UnicodeString& pattern,
-                                UBool localized,
-                                UParseError& parseError,
-                                UErrorCode& status);
-
-    /*
-     * only apply pattern without expand affixes
-     */
-    void applyPatternWithoutExpandAffix(const UnicodeString& pattern,
-                                        UBool localized,
-                                        UParseError& parseError,
-                                        UErrorCode& status);
-
-
-    /*
-     * expand affixes (after apply patter) and re-compute fFormatWidth
-     */
-    void expandAffixAdjustWidth(const UnicodeString* pluralCount);
-
-
-    /**
-     * Do the work of formatting a number, either a double or a long.
-     *
-     * @param appendTo       Output parameter to receive result.
-     *                       Result is appended to existing contents.
-     * @param handler        Records information about field positions.
-     * @param digits         the digits to be formatted.
-     * @param isInteger      if TRUE format the digits as Integer.
-     * @return               Reference to 'appendTo' parameter.
-     */
-    UnicodeString& subformat(UnicodeString& appendTo,
-                             FieldPositionHandler& handler,
-                             DigitList&     digits,
-                             UBool          isInteger, 
-                             UErrorCode &status) const;
-
+    void handleCurrencySignInPattern(UErrorCode& status);
 
     void parse(const UnicodeString& text,
                Formattable& result,
                ParsePosition& pos,
-               UChar* currency) const;
+               char16_t* currency) const;
 
     enum {
         fgStatusInfinite,
@@ -2060,11 +2119,11 @@ private:
                    const UnicodeString* negSuffix,
                    const UnicodeString* posPrefix,
                    const UnicodeString* posSuffix,
-                   UBool currencyParsing,
+                   UBool complexCurrencyParsing,
                    int8_t type,
                    ParsePosition& parsePosition,
                    DigitList& digits, UBool* status,
-                   UChar* currency) const;
+                   char16_t* currency) const;
 
     // Mixed style parsing for currency.
     // It parses against the current currency pattern
@@ -2075,7 +2134,7 @@ private:
                            ParsePosition& parsePosition,
                            DigitList& digits,
                            UBool* status,
-                           UChar* currency) const;
+                           char16_t* currency) const;
 
     int32_t skipPadding(const UnicodeString& text, int32_t position) const;
 
@@ -2084,24 +2143,32 @@ private:
                          UBool isNegative,
                          UBool isPrefix,
                          const UnicodeString* affixPat,
-                         UBool currencyParsing,
+                         UBool complexCurrencyParsing,
                          int8_t type,
-                         UChar* currency) const;
+                         char16_t* currency) const;
 
-    static int32_t compareSimpleAffix(const UnicodeString& affix,
+    static UnicodeString& trimMarksFromAffix(const UnicodeString& affix, UnicodeString& trimmedAffix);
+
+    UBool equalWithSignCompatibility(UChar32 lhs, UChar32 rhs) const;
+
+    int32_t compareSimpleAffix(const UnicodeString& affix,
                                       const UnicodeString& input,
                                       int32_t pos,
-                                      UBool lenient);
+                                      UBool lenient) const;
 
     static int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos);
 
     static int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos);
 
+    static int32_t skipUWhiteSpaceAndMarks(const UnicodeString& text, int32_t pos);
+
+    static int32_t skipBidiMarks(const UnicodeString& text, int32_t pos);
+
     int32_t compareComplexAffix(const UnicodeString& affixPat,
                                 const UnicodeString& input,
                                 int32_t pos,
                                 int8_t type,
-                                UChar* currency) const;
+                                char16_t* currency) const;
 
     static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch);
 
@@ -2120,231 +2187,45 @@ private:
                              UChar32 decimalChar, const UnicodeSet *decimalSet,
                              UChar32 schar);
 
-    /**
-     * Get a decimal format symbol.
-     * Returns a const reference to the symbol string.
-     * @internal
-     */
-    inline const UnicodeString &getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const;
-
-    int32_t appendAffix(UnicodeString& buf,
-                        double number,
-                        FieldPositionHandler& handler,
-                        UBool isNegative,
-                        UBool isPrefix) const;
-
-    /**
-     * Append an affix to the given UnicodeString, using quotes if
-     * there are special characters.  Single quotes themselves must be
-     * escaped in either case.
-     */
-    void appendAffixPattern(UnicodeString& appendTo, const UnicodeString& affix,
-                            UBool localized) const;
-
-    void appendAffixPattern(UnicodeString& appendTo,
-                            const UnicodeString* affixPattern,
-                            const UnicodeString& expAffix, UBool localized) const;
-
-    void expandAffix(const UnicodeString& pattern,
-                     UnicodeString& affix,
-                     double number,
-                     FieldPositionHandler& handler,
-                     UBool doFormat,
-                     const UnicodeString* pluralCount) const;
-
-    void expandAffixes(const UnicodeString* pluralCount);
-
-    void addPadding(UnicodeString& appendTo,
-                    FieldPositionHandler& handler,
-                    int32_t prefixLen, int32_t suffixLen) const;
-
-    UBool isGroupingPosition(int32_t pos) const;
-
-    void setCurrencyForSymbols();
-
-    // similar to setCurrency without re-compute the affixes for currency.
-    // If currency changes, the affix pattern for currency is not changed,
-    // but the affix will be changed. So, affixes need to be
-    // re-computed in setCurrency(), but not in setCurrencyInternally().
-    virtual void setCurrencyInternally(const UChar* theCurrency, UErrorCode& ec);
-
     // set up currency affix patterns for mix parsing.
     // The patterns saved here are the affix patterns of default currency
     // pattern and the unique affix patterns of the plural currency patterns.
     // Those patterns are used by parseForCurrency().
     void setupCurrencyAffixPatterns(UErrorCode& status);
 
-    // set up the currency affixes used in currency plural formatting.
-    // It sets up both fAffixesForCurrency for currency pattern if the current
-    // pattern contains 3 currency signs,
-    // and it sets up fPluralAffixesForCurrency for currency plural patterns.
-    void setupCurrencyAffixes(const UnicodeString& pattern,
-                              UBool setupForCurrentPattern,
-                              UBool setupForPluralPattern,
-                              UErrorCode& status);
+    // get the currency rounding with respect to currency usage
+    double getCurrencyRounding(const char16_t* currency,
+                               UErrorCode* ec) const;
+
+    // get the currency fraction with respect to currency usage
+    int getCurrencyFractionDigits(const char16_t* currency,
+                                  UErrorCode* ec) const;
 
     // hashtable operations
     Hashtable* initHashForAffixPattern(UErrorCode& status);
-    Hashtable* initHashForAffix(UErrorCode& status);
 
     void deleteHashForAffixPattern();
-    void deleteHashForAffix(Hashtable*& table);
 
     void copyHashForAffixPattern(const Hashtable* source,
                                  Hashtable* target, UErrorCode& status);
-    void copyHashForAffix(const Hashtable* source,
-                          Hashtable* target, UErrorCode& status);
-
-    UnicodeString& _format(int64_t number,
-                           UnicodeString& appendTo,
-                           FieldPositionHandler& handler,
-                           UErrorCode &status) const;
-    UnicodeString& _format(double number,
-                           UnicodeString& appendTo,
-                           FieldPositionHandler& handler,
-                           UErrorCode &status) const;
-    UnicodeString& _format(const DigitList &number,
-                           UnicodeString& appendTo,
-                           FieldPositionHandler& handler,
-                           UErrorCode &status) const;
-
-    // currency sign count
-    enum {
-        fgCurrencySignCountZero,
-        fgCurrencySignCountInSymbolFormat,
-        fgCurrencySignCountInISOFormat,
-        fgCurrencySignCountInPluralFormat
-    } CurrencySignCount;
 
-    /**
-     * Constants.
-     */
-
-    UnicodeString           fPositivePrefix;
-    UnicodeString           fPositiveSuffix;
-    UnicodeString           fNegativePrefix;
-    UnicodeString           fNegativeSuffix;
-    UnicodeString*          fPosPrefixPattern;
-    UnicodeString*          fPosSuffixPattern;
-    UnicodeString*          fNegPrefixPattern;
-    UnicodeString*          fNegSuffixPattern;
+    DecimalFormatImpl *fImpl;
 
     /**
-     * Formatter for ChoiceFormat-based currency names.  If this field
-     * is not null, then delegate to it to format currency symbols.
-     * @since ICU 2.6
+     * Constants.
      */
-    ChoiceFormat*           fCurrencyChoice;
 
-    DigitList *             fMultiplier;   // NULL for multiplier of one
-    int32_t                 fScale;        
-    int32_t                 fGroupingSize;
-    int32_t                 fGroupingSize2;
-    UBool                   fDecimalSeparatorAlwaysShown;
-    DecimalFormatSymbols*   fSymbols;
-
-    UBool                   fUseSignificantDigits;
-    int32_t                 fMinSignificantDigits;
-    int32_t                 fMaxSignificantDigits;
-
-    UBool                   fUseExponentialNotation;
-    int8_t                  fMinExponentDigits;
-    UBool                   fExponentSignAlwaysShown;
 
     EnumSet<UNumberFormatAttribute,
-            UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1, 
-            UNUM_LIMIT_BOOLEAN_ATTRIBUTE>  
+            UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1,
+            UNUM_LIMIT_BOOLEAN_ATTRIBUTE>
                             fBoolFlags;
 
-    DigitList*              fRoundingIncrement;  // NULL if no rounding increment specified.
-    ERoundingMode           fRoundingMode;
-
-    UChar32                 fPad;
-    int32_t                 fFormatWidth;
-    EPadPosition            fPadPosition;
 
-    /*
-     * Following are used for currency format
-     */
-    // pattern used in this formatter
-    UnicodeString fFormatPattern;
     // style is only valid when decimal formatter is constructed by
     // DecimalFormat(pattern, decimalFormatSymbol, style)
     int fStyle;
-    /*
-     * Represents whether this is a currency format, and which
-     * currency format style.
-     * 0: not currency format type;
-     * 1: currency style -- symbol name, such as "$" for US dollar.
-     * 2: currency style -- ISO name, such as USD for US dollar.
-     * 3: currency style -- plural long name, such as "US Dollar" for
-     *                      "1.00 US Dollar", or "US Dollars" for
-     *                      "3.00 US Dollars".
-     */
-    int fCurrencySignCount;
-
-
-    /* For currency parsing purose,
-     * Need to remember all prefix patterns and suffix patterns of
-     * every currency format pattern,
-     * including the pattern of default currecny style
-     * and plural currency style. And the patterns are set through applyPattern.
-     */
-    // TODO: innerclass?
-    /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
-    struct AffixPatternsForCurrency : public UMemory {
-        // negative prefix pattern
-        UnicodeString negPrefixPatternForCurrency;
-        // negative suffix pattern
-        UnicodeString negSuffixPatternForCurrency;
-        // positive prefix pattern
-        UnicodeString posPrefixPatternForCurrency;
-        // positive suffix pattern
-        UnicodeString posSuffixPatternForCurrency;
-        int8_t patternType;
-
-        AffixPatternsForCurrency(const UnicodeString& negPrefix,
-                                 const UnicodeString& negSuffix,
-                                 const UnicodeString& posPrefix,
-                                 const UnicodeString& posSuffix,
-                                 int8_t type) {
-            negPrefixPatternForCurrency = negPrefix;
-            negSuffixPatternForCurrency = negSuffix;
-            posPrefixPatternForCurrency = posPrefix;
-            posSuffixPatternForCurrency = posSuffix;
-            patternType = type;
-        }
-    };
-    */
 
-    /* affix for currency formatting when the currency sign in the pattern
-     * equals to 3, such as the pattern contains 3 currency sign or
-     * the formatter style is currency plural format style.
-     */
-    /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
-    struct AffixesForCurrency : public UMemory {
-        // negative prefix
-        UnicodeString negPrefixForCurrency;
-        // negative suffix
-        UnicodeString negSuffixForCurrency;
-        // positive prefix
-        UnicodeString posPrefixForCurrency;
-        // positive suffix
-        UnicodeString posSuffixForCurrency;
-
-        int32_t formatWidth;
-
-        AffixesForCurrency(const UnicodeString& negPrefix,
-                           const UnicodeString& negSuffix,
-                           const UnicodeString& posPrefix,
-                           const UnicodeString& posSuffix) {
-            negPrefixForCurrency = negPrefix;
-            negSuffixForCurrency = negSuffix;
-            posPrefixForCurrency = posPrefix;
-            posSuffixForCurrency = posSuffix;
-        }
-    };
-    */
 
     // Affix pattern set for currency.
     // It is a set of AffixPatternsForCurrency,
@@ -2361,16 +2242,6 @@ private:
     // count match or not.
     Hashtable* fAffixPatternsForCurrency;
 
-    // Following 2 are affixes for currency.
-    // It is a hash map from plural count to AffixesForCurrency.
-    // AffixesForCurrency saves the negative prefix,
-    // negative suffix, positive prefix, and positive suffix of a pattern.
-    // It is used during currency formatting only when the currency sign count
-    // is 3. In which case, the affixes are getting from here, not
-    // from the fNegativePrefix etc.
-    Hashtable* fAffixesForCurrency;  // for current pattern
-    Hashtable* fPluralAffixesForCurrency;  // for plural pattern
-
     // Information needed for DecimalFormat to format/parse currency plural.
     CurrencyPluralInfo* fCurrencyPluralInfo;
 
@@ -2378,6 +2249,8 @@ private:
     UNumberFormatAttributeValue fParseAllInput;
 #endif
 
+    // Decimal Format Static Sets singleton.
+    const DecimalFormatStaticSets *fStaticSets;
 
 protected:
 
@@ -2397,7 +2270,7 @@ protected:
      * have a capacity of at least 4
      * @internal
      */
-    virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
+    virtual void getEffectiveCurrency(char16_t* result, UErrorCode& ec) const;
 
   /** number of integer digits
    * @stable ICU 2.4
@@ -2420,51 +2293,10 @@ protected:
      */
     static const int32_t  kMaxScientificIntegerDigits;
 
-#if UCONFIG_FORMAT_FASTPATHS_49
- private:
-    /**
-     * Internal state. 
-     * @internal
-     */
-    uint8_t fReserved[UNUM_DECIMALFORMAT_INTERNAL_SIZE];
-
-
-    /**
-     * Called whenever any state changes. Recomputes whether fastpath is OK to use.
-     */
-    void handleChanged();
-#endif
 };
 
-inline UnicodeString&
-DecimalFormat::format(const Formattable& obj,
-                      UnicodeString& appendTo,
-                      UErrorCode& status) const {
-    // Don't use Format:: - use immediate base class only,
-    // in case immediate base modifies behavior later.
-    return NumberFormat::format(obj, appendTo, status);
-}
-
-inline UnicodeString&
-DecimalFormat::format(double number,
-                      UnicodeString& appendTo) const {
-    FieldPosition pos(0);
-    return format(number, appendTo, pos);
-}
-
-inline UnicodeString&
-DecimalFormat::format(int32_t number,
-                      UnicodeString& appendTo) const {
-    FieldPosition pos(0);
-    return format((int64_t)number, appendTo, pos);
-}
-
-inline const UnicodeString &
-DecimalFormat::getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const {
-    return fSymbols->getConstSymbol(symbol);
-}
-
 U_NAMESPACE_END
+#endif // U_SHOW_CPLUSPLUS_API
 
 #endif /* #if !UCONFIG_NO_FORMATTING */