ICU 51.2  51.2
decimfmt.h
Go to the documentation of this file.
1 /*
2 ********************************************************************************
3 * Copyright (C) 1997-2013, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ********************************************************************************
6 *
7 * File DECIMFMT.H
8 *
9 * Modification History:
10 *
11 * Date Name Description
12 * 02/19/97 aliu Converted from java.
13 * 03/20/97 clhuang Updated per C++ implementation.
14 * 04/03/97 aliu Rewrote parsing and formatting completely, and
15 * cleaned up and debugged. Actually works now.
16 * 04/17/97 aliu Changed DigitCount to int per code review.
17 * 07/10/97 helena Made ParsePosition a class and get rid of the function
18 * hiding problems.
19 * 09/09/97 aliu Ported over support for exponential formats.
20 * 07/20/98 stephen Changed documentation
21 * 01/30/13 emmons Added Scaling methods
22 ********************************************************************************
23 */
24 
25 #ifndef DECIMFMT_H
26 #define DECIMFMT_H
27 
28 #include "unicode/utypes.h"
34 #if !UCONFIG_NO_FORMATTING
35 
36 #include "unicode/dcfmtsym.h"
37 #include "unicode/numfmt.h"
38 #include "unicode/locid.h"
39 #include "unicode/fpositer.h"
40 #include "unicode/stringpiece.h"
41 #include "unicode/curramt.h"
42 #include "unicode/enumset.h"
43 
44 #ifndef U_HIDE_INTERNAL_API
45 
49 #if UCONFIG_FORMAT_FASTPATHS_49
50 #define UNUM_DECIMALFORMAT_INTERNAL_SIZE 16
51 #endif
52 #endif /* U_HIDE_INTERNAL_API */
53 
55 
56 class DigitList;
57 class ChoiceFormat;
58 class CurrencyPluralInfo;
59 class Hashtable;
60 class UnicodeSet;
61 class FieldPositionHandler;
62 
63 // explicit template instantiation. see digitlst.h
64 #if defined (_MSC_VER)
65 template class U_I18N_API EnumSet<UNumberFormatAttribute,
68 #endif
69 
664 public:
674  kRoundHalfEven,
676  kRoundHalfDown,
678  kRoundHalfUp,
684  kRoundUnnecessary
685  };
686 
692  kPadBeforePrefix,
693  kPadAfterPrefix,
694  kPadBeforeSuffix,
695  kPadAfterSuffix
696  };
697 
711  DecimalFormat(UErrorCode& status);
712 
727  DecimalFormat(const UnicodeString& pattern,
728  UErrorCode& status);
729 
748  DecimalFormat( const UnicodeString& pattern,
749  DecimalFormatSymbols* symbolsToAdopt,
750  UErrorCode& status);
751 
752 #ifndef U_HIDE_INTERNAL_API
753 
765  DecimalFormat( const UnicodeString& pattern,
766  DecimalFormatSymbols* symbolsToAdopt,
767  UNumberFormatStyle style,
768  UErrorCode& status);
769 
770 #if UCONFIG_HAVE_PARSEALLINPUT
771 
774  void setParseAllInput(UNumberFormatAttributeValue value);
775 #endif
776 
777 #endif /* U_HIDE_INTERNAL_API */
778 
779 
790  virtual DecimalFormat& setAttribute( UNumberFormatAttribute attr,
791  int32_t newvalue,
792  UErrorCode &status);
793 
803  virtual int32_t getAttribute( UNumberFormatAttribute attr,
804  UErrorCode &status) const;
805 
806 
807 
827  DecimalFormat( const UnicodeString& pattern,
828  DecimalFormatSymbols* symbolsToAdopt,
829  UParseError& parseError,
830  UErrorCode& status);
848  DecimalFormat( const UnicodeString& pattern,
849  const DecimalFormatSymbols& symbols,
850  UErrorCode& status);
851 
858  DecimalFormat(const DecimalFormat& source);
859 
867 
872  virtual ~DecimalFormat();
873 
881  virtual Format* clone(void) const;
882 
891  virtual UBool operator==(const Format& other) const;
892 
893 
894  using NumberFormat::format;
895 
907  virtual UnicodeString& format(double number,
908  UnicodeString& appendTo,
909  FieldPosition& pos) const;
910 
911 
924  virtual UnicodeString& format(double number,
925  UnicodeString& appendTo,
926  FieldPosition& pos,
927  UErrorCode &status) const;
928 
942  virtual UnicodeString& format(double number,
943  UnicodeString& appendTo,
944  FieldPositionIterator* posIter,
945  UErrorCode& status) const;
946 
958  virtual UnicodeString& format(int32_t number,
959  UnicodeString& appendTo,
960  FieldPosition& pos) const;
961 
973  virtual UnicodeString& format(int32_t number,
974  UnicodeString& appendTo,
975  FieldPosition& pos,
976  UErrorCode &status) const;
977 
991  virtual UnicodeString& format(int32_t number,
992  UnicodeString& appendTo,
993  FieldPositionIterator* posIter,
994  UErrorCode& status) const;
995 
1007  virtual UnicodeString& format(int64_t number,
1008  UnicodeString& appendTo,
1009  FieldPosition& pos) const;
1010 
1022  virtual UnicodeString& format(int64_t number,
1023  UnicodeString& appendTo,
1024  FieldPosition& pos,
1025  UErrorCode &status) const;
1026 
1040  virtual UnicodeString& format(int64_t number,
1041  UnicodeString& appendTo,
1042  FieldPositionIterator* posIter,
1043  UErrorCode& status) const;
1044 
1061  virtual UnicodeString& format(const StringPiece &number,
1062  UnicodeString& appendTo,
1063  FieldPositionIterator* posIter,
1064  UErrorCode& status) const;
1065 
1066 
1082  virtual UnicodeString& format(const DigitList &number,
1083  UnicodeString& appendTo,
1084  FieldPositionIterator* posIter,
1085  UErrorCode& status) const;
1086 
1102  virtual UnicodeString& format(const DigitList &number,
1103  UnicodeString& appendTo,
1104  FieldPosition& pos,
1105  UErrorCode& status) const;
1106 
1107 
1120  virtual UnicodeString& format(const Formattable& obj,
1121  UnicodeString& appendTo,
1122  FieldPosition& pos,
1123  UErrorCode& status) const;
1124 
1136  UnicodeString& format(const Formattable& obj,
1137  UnicodeString& appendTo,
1138  UErrorCode& status) const;
1139 
1150  UnicodeString& format(double number,
1151  UnicodeString& appendTo) const;
1152 
1164  UnicodeString& format(int32_t number,
1165  UnicodeString& appendTo) const;
1166 
1178  UnicodeString& format(int64_t number,
1179  UnicodeString& appendTo) const;
1199  virtual void parse(const UnicodeString& text,
1200  Formattable& result,
1201  ParsePosition& parsePosition) const;
1202 
1203  // Declare here again to get rid of function hiding problems.
1212  virtual void parse(const UnicodeString& text,
1213  Formattable& result,
1214  UErrorCode& status) const;
1215 
1235  virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
1236  ParsePosition& pos) const;
1237 
1245  virtual const DecimalFormatSymbols* getDecimalFormatSymbols(void) const;
1246 
1253  virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt);
1254 
1261  virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols);
1262 
1263 
1270  virtual const CurrencyPluralInfo* getCurrencyPluralInfo(void) const;
1271 
1278  virtual void adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt);
1279 
1286  virtual void setCurrencyPluralInfo(const CurrencyPluralInfo& info);
1287 
1288 
1297  UnicodeString& getPositivePrefix(UnicodeString& result) const;
1298 
1306  virtual void setPositivePrefix(const UnicodeString& newValue);
1307 
1316  UnicodeString& getNegativePrefix(UnicodeString& result) const;
1317 
1325  virtual void setNegativePrefix(const UnicodeString& newValue);
1326 
1335  UnicodeString& getPositiveSuffix(UnicodeString& result) const;
1336 
1344  virtual void setPositiveSuffix(const UnicodeString& newValue);
1345 
1354  UnicodeString& getNegativeSuffix(UnicodeString& result) const;
1355 
1363  virtual void setNegativeSuffix(const UnicodeString& newValue);
1364 
1375  int32_t getMultiplier(void) const;
1376 
1387  virtual void setMultiplier(int32_t newValue);
1388 
1398  virtual double getRoundingIncrement(void) const;
1399 
1410  virtual void setRoundingIncrement(double newValue);
1411 
1420  virtual ERoundingMode getRoundingMode(void) const;
1421 
1430  virtual void setRoundingMode(ERoundingMode roundingMode);
1431 
1443  virtual int32_t getFormatWidth(void) const;
1444 
1459  virtual void setFormatWidth(int32_t width);
1460 
1473  virtual UnicodeString getPadCharacterString() const;
1474 
1489  virtual void setPadCharacter(const UnicodeString &padChar);
1490 
1506  virtual EPadPosition getPadPosition(void) const;
1507 
1524  virtual void setPadPosition(EPadPosition padPos);
1525 
1536  virtual UBool isScientificNotation(void);
1537 
1553  virtual void setScientificNotation(UBool useScientific);
1554 
1565  virtual int8_t getMinimumExponentDigits(void) const;
1566 
1579  virtual void setMinimumExponentDigits(int8_t minExpDig);
1580 
1593  virtual UBool isExponentSignAlwaysShown(void);
1594 
1608  virtual void setExponentSignAlwaysShown(UBool expSignAlways);
1609 
1621  int32_t getGroupingSize(void) const;
1622 
1634  virtual void setGroupingSize(int32_t newValue);
1635 
1654  int32_t getSecondaryGroupingSize(void) const;
1655 
1667  virtual void setSecondaryGroupingSize(int32_t newValue);
1668 
1677  UBool isDecimalSeparatorAlwaysShown(void) const;
1678 
1687  virtual void setDecimalSeparatorAlwaysShown(UBool newValue);
1688 
1699  virtual UnicodeString& toPattern(UnicodeString& result) const;
1700 
1711  virtual UnicodeString& toLocalizedPattern(UnicodeString& result) const;
1712 
1742  virtual void applyPattern(const UnicodeString& pattern,
1743  UParseError& parseError,
1744  UErrorCode& status);
1753  virtual void applyPattern(const UnicodeString& pattern,
1754  UErrorCode& status);
1755 
1786  virtual void applyLocalizedPattern(const UnicodeString& pattern,
1787  UParseError& parseError,
1788  UErrorCode& status);
1789 
1799  virtual void applyLocalizedPattern(const UnicodeString& pattern,
1800  UErrorCode& status);
1801 
1802 
1812  virtual void setMaximumIntegerDigits(int32_t newValue);
1813 
1823  virtual void setMinimumIntegerDigits(int32_t newValue);
1824 
1834  virtual void setMaximumFractionDigits(int32_t newValue);
1835 
1845  virtual void setMinimumFractionDigits(int32_t newValue);
1846 
1854  int32_t getMinimumSignificantDigits() const;
1855 
1863  int32_t getMaximumSignificantDigits() const;
1864 
1874  void setMinimumSignificantDigits(int32_t min);
1875 
1886  void setMaximumSignificantDigits(int32_t max);
1887 
1894  UBool areSignificantDigitsUsed() const;
1895 
1903  void setSignificantDigitsUsed(UBool useSignificantDigits);
1904 
1905  public:
1918  virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
1919 
1925  virtual void setCurrency(const UChar* theCurrency);
1926 
1932  static const char fgNumberPatterns[];
1933 
1934 public:
1935 
1947  static UClassID U_EXPORT2 getStaticClassID(void);
1948 
1960  virtual UClassID getDynamicClassID(void) const;
1961 
1962 private:
1963 
1964  DecimalFormat(); // default constructor not implemented
1965 
1966  int32_t precision() const;
1967 
1972  void init(UErrorCode& status);
1973 
1977  void construct(UErrorCode& status,
1978  UParseError& parseErr,
1979  const UnicodeString* pattern = 0,
1980  DecimalFormatSymbols* symbolsToAdopt = 0
1981  );
1982 
1991  UnicodeString& toPattern(UnicodeString& result, UBool localized) const;
1992 
2003  void applyPattern(const UnicodeString& pattern,
2004  UBool localized,
2005  UParseError& parseError,
2006  UErrorCode& status);
2007 
2008  /*
2009  * similar to applyPattern, but without re-gen affix for currency
2010  */
2011  void applyPatternInternally(const UnicodeString& pluralCount,
2012  const UnicodeString& pattern,
2013  UBool localized,
2014  UParseError& parseError,
2015  UErrorCode& status);
2016 
2017  /*
2018  * only apply pattern without expand affixes
2019  */
2020  void applyPatternWithoutExpandAffix(const UnicodeString& pattern,
2021  UBool localized,
2022  UParseError& parseError,
2023  UErrorCode& status);
2024 
2025 
2026  /*
2027  * expand affixes (after apply patter) and re-compute fFormatWidth
2028  */
2029  void expandAffixAdjustWidth(const UnicodeString* pluralCount);
2030 
2031 
2042  UnicodeString& subformat(UnicodeString& appendTo,
2043  FieldPositionHandler& handler,
2044  DigitList& digits,
2045  UBool isInteger,
2046  UErrorCode &status) const;
2047 
2048 
2049  void parse(const UnicodeString& text,
2050  Formattable& result,
2051  ParsePosition& pos,
2052  UChar* currency) const;
2053 
2054  enum {
2055  fgStatusInfinite,
2056  fgStatusLength // Leave last in list.
2057  } StatusFlags;
2058 
2059  UBool subparse(const UnicodeString& text,
2060  const UnicodeString* negPrefix,
2061  const UnicodeString* negSuffix,
2062  const UnicodeString* posPrefix,
2063  const UnicodeString* posSuffix,
2064  UBool currencyParsing,
2065  int8_t type,
2066  ParsePosition& parsePosition,
2067  DigitList& digits, UBool* status,
2068  UChar* currency) const;
2069 
2070  // Mixed style parsing for currency.
2071  // It parses against the current currency pattern
2072  // using complex affix comparison
2073  // parses against the currency plural patterns using complex affix comparison,
2074  // and parses against the current pattern using simple affix comparison.
2075  UBool parseForCurrency(const UnicodeString& text,
2076  ParsePosition& parsePosition,
2077  DigitList& digits,
2078  UBool* status,
2079  UChar* currency) const;
2080 
2081  int32_t skipPadding(const UnicodeString& text, int32_t position) const;
2082 
2083  int32_t compareAffix(const UnicodeString& input,
2084  int32_t pos,
2085  UBool isNegative,
2086  UBool isPrefix,
2087  const UnicodeString* affixPat,
2088  UBool currencyParsing,
2089  int8_t type,
2090  UChar* currency) const;
2091 
2092  static int32_t compareSimpleAffix(const UnicodeString& affix,
2093  const UnicodeString& input,
2094  int32_t pos,
2095  UBool lenient);
2096 
2097  static int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos);
2098 
2099  static int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos);
2100 
2101  int32_t compareComplexAffix(const UnicodeString& affixPat,
2102  const UnicodeString& input,
2103  int32_t pos,
2104  int8_t type,
2105  UChar* currency) const;
2106 
2107  static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch);
2108 
2109  static int32_t match(const UnicodeString& text, int32_t pos, const UnicodeString& str);
2110 
2111  static UBool matchSymbol(const UnicodeString &text, int32_t position, int32_t length, const UnicodeString &symbol,
2112  UnicodeSet *sset, UChar32 schar);
2113 
2114  static UBool matchDecimal(UChar32 symbolChar,
2115  UBool sawDecimal, UChar32 sawDecimalChar,
2116  const UnicodeSet *sset, UChar32 schar);
2117 
2118  static UBool matchGrouping(UChar32 groupingChar,
2119  UBool sawGrouping, UChar32 sawGroupingChar,
2120  const UnicodeSet *sset,
2121  UChar32 decimalChar, const UnicodeSet *decimalSet,
2122  UChar32 schar);
2123 
2129  inline const UnicodeString &getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const;
2130 
2131  int32_t appendAffix(UnicodeString& buf,
2132  double number,
2133  FieldPositionHandler& handler,
2134  UBool isNegative,
2135  UBool isPrefix) const;
2136 
2142  void appendAffixPattern(UnicodeString& appendTo, const UnicodeString& affix,
2143  UBool localized) const;
2144 
2145  void appendAffixPattern(UnicodeString& appendTo,
2146  const UnicodeString* affixPattern,
2147  const UnicodeString& expAffix, UBool localized) const;
2148 
2149  void expandAffix(const UnicodeString& pattern,
2150  UnicodeString& affix,
2151  double number,
2152  FieldPositionHandler& handler,
2153  UBool doFormat,
2154  const UnicodeString* pluralCount) const;
2155 
2156  void expandAffixes(const UnicodeString* pluralCount);
2157 
2158  void addPadding(UnicodeString& appendTo,
2159  FieldPositionHandler& handler,
2160  int32_t prefixLen, int32_t suffixLen) const;
2161 
2162  UBool isGroupingPosition(int32_t pos) const;
2163 
2164  void setCurrencyForSymbols();
2165 
2166  // similar to setCurrency without re-compute the affixes for currency.
2167  // If currency changes, the affix pattern for currency is not changed,
2168  // but the affix will be changed. So, affixes need to be
2169  // re-computed in setCurrency(), but not in setCurrencyInternally().
2170  virtual void setCurrencyInternally(const UChar* theCurrency, UErrorCode& ec);
2171 
2172  // set up currency affix patterns for mix parsing.
2173  // The patterns saved here are the affix patterns of default currency
2174  // pattern and the unique affix patterns of the plural currency patterns.
2175  // Those patterns are used by parseForCurrency().
2176  void setupCurrencyAffixPatterns(UErrorCode& status);
2177 
2178  // set up the currency affixes used in currency plural formatting.
2179  // It sets up both fAffixesForCurrency for currency pattern if the current
2180  // pattern contains 3 currency signs,
2181  // and it sets up fPluralAffixesForCurrency for currency plural patterns.
2182  void setupCurrencyAffixes(const UnicodeString& pattern,
2183  UBool setupForCurrentPattern,
2184  UBool setupForPluralPattern,
2185  UErrorCode& status);
2186 
2187  // hashtable operations
2188  Hashtable* initHashForAffixPattern(UErrorCode& status);
2189  Hashtable* initHashForAffix(UErrorCode& status);
2190 
2191  void deleteHashForAffixPattern();
2192  void deleteHashForAffix(Hashtable*& table);
2193 
2194  void copyHashForAffixPattern(const Hashtable* source,
2195  Hashtable* target, UErrorCode& status);
2196  void copyHashForAffix(const Hashtable* source,
2197  Hashtable* target, UErrorCode& status);
2198 
2199  UnicodeString& _format(int64_t number,
2200  UnicodeString& appendTo,
2201  FieldPositionHandler& handler,
2202  UErrorCode &status) const;
2203  UnicodeString& _format(double number,
2204  UnicodeString& appendTo,
2205  FieldPositionHandler& handler,
2206  UErrorCode &status) const;
2207  UnicodeString& _format(const DigitList &number,
2208  UnicodeString& appendTo,
2209  FieldPositionHandler& handler,
2210  UErrorCode &status) const;
2211 
2212  // currency sign count
2213  enum {
2214  fgCurrencySignCountZero,
2215  fgCurrencySignCountInSymbolFormat,
2216  fgCurrencySignCountInISOFormat,
2217  fgCurrencySignCountInPluralFormat
2218  } CurrencySignCount;
2219 
2224  UnicodeString fPositivePrefix;
2225  UnicodeString fPositiveSuffix;
2226  UnicodeString fNegativePrefix;
2227  UnicodeString fNegativeSuffix;
2228  UnicodeString* fPosPrefixPattern;
2229  UnicodeString* fPosSuffixPattern;
2230  UnicodeString* fNegPrefixPattern;
2231  UnicodeString* fNegSuffixPattern;
2232 
2238  ChoiceFormat* fCurrencyChoice;
2239 
2240  DigitList * fMultiplier; // NULL for multiplier of one
2241  int32_t fScale;
2242  int32_t fGroupingSize;
2243  int32_t fGroupingSize2;
2244  UBool fDecimalSeparatorAlwaysShown;
2245  DecimalFormatSymbols* fSymbols;
2246 
2247  UBool fUseSignificantDigits;
2248  int32_t fMinSignificantDigits;
2249  int32_t fMaxSignificantDigits;
2250 
2251  UBool fUseExponentialNotation;
2252  int8_t fMinExponentDigits;
2253  UBool fExponentSignAlwaysShown;
2254 
2255  EnumSet<UNumberFormatAttribute,
2258  fBoolFlags;
2259 
2260  DigitList* fRoundingIncrement; // NULL if no rounding increment specified.
2261  ERoundingMode fRoundingMode;
2262 
2263  UChar32 fPad;
2264  int32_t fFormatWidth;
2265  EPadPosition fPadPosition;
2266 
2267  /*
2268  * Following are used for currency format
2269  */
2270  // pattern used in this formatter
2271  UnicodeString fFormatPattern;
2272  // style is only valid when decimal formatter is constructed by
2273  // DecimalFormat(pattern, decimalFormatSymbol, style)
2274  int fStyle;
2275  /*
2276  * Represents whether this is a currency format, and which
2277  * currency format style.
2278  * 0: not currency format type;
2279  * 1: currency style -- symbol name, such as "$" for US dollar.
2280  * 2: currency style -- ISO name, such as USD for US dollar.
2281  * 3: currency style -- plural long name, such as "US Dollar" for
2282  * "1.00 US Dollar", or "US Dollars" for
2283  * "3.00 US Dollars".
2284  */
2285  int fCurrencySignCount;
2286 
2287 
2288  /* For currency parsing purose,
2289  * Need to remember all prefix patterns and suffix patterns of
2290  * every currency format pattern,
2291  * including the pattern of default currecny style
2292  * and plural currency style. And the patterns are set through applyPattern.
2293  */
2294  // TODO: innerclass?
2295  /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
2296  struct AffixPatternsForCurrency : public UMemory {
2297  // negative prefix pattern
2298  UnicodeString negPrefixPatternForCurrency;
2299  // negative suffix pattern
2300  UnicodeString negSuffixPatternForCurrency;
2301  // positive prefix pattern
2302  UnicodeString posPrefixPatternForCurrency;
2303  // positive suffix pattern
2304  UnicodeString posSuffixPatternForCurrency;
2305  int8_t patternType;
2306 
2307  AffixPatternsForCurrency(const UnicodeString& negPrefix,
2308  const UnicodeString& negSuffix,
2309  const UnicodeString& posPrefix,
2310  const UnicodeString& posSuffix,
2311  int8_t type) {
2312  negPrefixPatternForCurrency = negPrefix;
2313  negSuffixPatternForCurrency = negSuffix;
2314  posPrefixPatternForCurrency = posPrefix;
2315  posSuffixPatternForCurrency = posSuffix;
2316  patternType = type;
2317  }
2318  };
2319  */
2320 
2321  /* affix for currency formatting when the currency sign in the pattern
2322  * equals to 3, such as the pattern contains 3 currency sign or
2323  * the formatter style is currency plural format style.
2324  */
2325  /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
2326  struct AffixesForCurrency : public UMemory {
2327  // negative prefix
2328  UnicodeString negPrefixForCurrency;
2329  // negative suffix
2330  UnicodeString negSuffixForCurrency;
2331  // positive prefix
2332  UnicodeString posPrefixForCurrency;
2333  // positive suffix
2334  UnicodeString posSuffixForCurrency;
2335 
2336  int32_t formatWidth;
2337 
2338  AffixesForCurrency(const UnicodeString& negPrefix,
2339  const UnicodeString& negSuffix,
2340  const UnicodeString& posPrefix,
2341  const UnicodeString& posSuffix) {
2342  negPrefixForCurrency = negPrefix;
2343  negSuffixForCurrency = negSuffix;
2344  posPrefixForCurrency = posPrefix;
2345  posSuffixForCurrency = posSuffix;
2346  }
2347  };
2348  */
2349 
2350  // Affix pattern set for currency.
2351  // It is a set of AffixPatternsForCurrency,
2352  // each element of the set saves the negative prefix pattern,
2353  // negative suffix pattern, positive prefix pattern,
2354  // and positive suffix pattern of a pattern.
2355  // It is used for currency mixed style parsing.
2356  // It is actually is a set.
2357  // The set contains the default currency pattern from the locale,
2358  // and the currency plural patterns.
2359  // Since it is a set, it does not contain duplicated items.
2360  // For example, if 2 currency plural patterns are the same, only one pattern
2361  // is included in the set. When parsing, we do not check whether the plural
2362  // count match or not.
2363  Hashtable* fAffixPatternsForCurrency;
2364 
2365  // Following 2 are affixes for currency.
2366  // It is a hash map from plural count to AffixesForCurrency.
2367  // AffixesForCurrency saves the negative prefix,
2368  // negative suffix, positive prefix, and positive suffix of a pattern.
2369  // It is used during currency formatting only when the currency sign count
2370  // is 3. In which case, the affixes are getting from here, not
2371  // from the fNegativePrefix etc.
2372  Hashtable* fAffixesForCurrency; // for current pattern
2373  Hashtable* fPluralAffixesForCurrency; // for plural pattern
2374 
2375  // Information needed for DecimalFormat to format/parse currency plural.
2376  CurrencyPluralInfo* fCurrencyPluralInfo;
2377 
2378 #if UCONFIG_HAVE_PARSEALLINPUT
2379  UNumberFormatAttributeValue fParseAllInput;
2380 #endif
2381 
2382 
2383 protected:
2384 
2385 #ifndef U_HIDE_INTERNAL_API
2386 
2390  DigitList& _round(const DigitList& number, DigitList& adjustedNum, UBool& isNegative, UErrorCode& status) const;
2391 #endif /* U_HIDE_INTERNAL_API */
2392 
2401  virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
2402 
2406  static const int32_t kDoubleIntegerDigits;
2410  static const int32_t kDoubleFractionDigits;
2411 
2422  static const int32_t kMaxScientificIntegerDigits;
2423 
2424 #if UCONFIG_FORMAT_FASTPATHS_49
2425  private:
2430  uint8_t fReserved[UNUM_DECIMALFORMAT_INTERNAL_SIZE];
2431 
2432 
2436  void handleChanged();
2437 #endif
2438 };
2439 
2440 inline UnicodeString&
2441 DecimalFormat::format(const Formattable& obj,
2442  UnicodeString& appendTo,
2443  UErrorCode& status) const {
2444  // Don't use Format:: - use immediate base class only,
2445  // in case immediate base modifies behavior later.
2446  return NumberFormat::format(obj, appendTo, status);
2447 }
2448 
2449 inline UnicodeString&
2450 DecimalFormat::format(double number,
2451  UnicodeString& appendTo) const {
2452  FieldPosition pos(0);
2453  return format(number, appendTo, pos);
2454 }
2455 
2456 inline UnicodeString&
2457 DecimalFormat::format(int32_t number,
2458  UnicodeString& appendTo) const {
2459  FieldPosition pos(0);
2460  return format((int64_t)number, appendTo, pos);
2461 }
2462 
2463 inline const UnicodeString &
2464 DecimalFormat::getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const {
2465  return fSymbols->getConstSymbol(symbol);
2466 }
2467 
2469 
2470 #endif /* #if !UCONFIG_NO_FORMATTING */
2471 
2472 #endif // _DECIMFMT
2473 //eof