ICU 52.1  52.1
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 
48 #if UCONFIG_FORMAT_FASTPATHS_49
49 #define UNUM_DECIMALFORMAT_INTERNAL_SIZE 16
50 #endif
51 
53 
54 class DigitList;
55 class ChoiceFormat;
56 class CurrencyPluralInfo;
57 class Hashtable;
58 class UnicodeSet;
59 class FieldPositionHandler;
60 class DecimalFormatStaticSets;
61 class FixedDecimal;
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  using NumberFormat::parse;
1108 
1128  virtual void parse(const UnicodeString& text,
1129  Formattable& result,
1130  ParsePosition& parsePosition) const;
1131 
1151  virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
1152  ParsePosition& pos) const;
1153 
1161  virtual const DecimalFormatSymbols* getDecimalFormatSymbols(void) const;
1162 
1169  virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt);
1170 
1177  virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols);
1178 
1179 
1186  virtual const CurrencyPluralInfo* getCurrencyPluralInfo(void) const;
1187 
1194  virtual void adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt);
1195 
1202  virtual void setCurrencyPluralInfo(const CurrencyPluralInfo& info);
1203 
1204 
1213  UnicodeString& getPositivePrefix(UnicodeString& result) const;
1214 
1222  virtual void setPositivePrefix(const UnicodeString& newValue);
1223 
1232  UnicodeString& getNegativePrefix(UnicodeString& result) const;
1233 
1241  virtual void setNegativePrefix(const UnicodeString& newValue);
1242 
1251  UnicodeString& getPositiveSuffix(UnicodeString& result) const;
1252 
1260  virtual void setPositiveSuffix(const UnicodeString& newValue);
1261 
1270  UnicodeString& getNegativeSuffix(UnicodeString& result) const;
1271 
1279  virtual void setNegativeSuffix(const UnicodeString& newValue);
1280 
1291  int32_t getMultiplier(void) const;
1292 
1303  virtual void setMultiplier(int32_t newValue);
1304 
1314  virtual double getRoundingIncrement(void) const;
1315 
1327  virtual void setRoundingIncrement(double newValue);
1328 
1337  virtual ERoundingMode getRoundingMode(void) const;
1338 
1347  virtual void setRoundingMode(ERoundingMode roundingMode);
1348 
1360  virtual int32_t getFormatWidth(void) const;
1361 
1376  virtual void setFormatWidth(int32_t width);
1377 
1390  virtual UnicodeString getPadCharacterString() const;
1391 
1406  virtual void setPadCharacter(const UnicodeString &padChar);
1407 
1423  virtual EPadPosition getPadPosition(void) const;
1424 
1441  virtual void setPadPosition(EPadPosition padPos);
1442 
1453  virtual UBool isScientificNotation(void) const;
1454 
1470  virtual void setScientificNotation(UBool useScientific);
1471 
1482  virtual int8_t getMinimumExponentDigits(void) const;
1483 
1496  virtual void setMinimumExponentDigits(int8_t minExpDig);
1497 
1510  virtual UBool isExponentSignAlwaysShown(void) const;
1511 
1525  virtual void setExponentSignAlwaysShown(UBool expSignAlways);
1526 
1538  int32_t getGroupingSize(void) const;
1539 
1551  virtual void setGroupingSize(int32_t newValue);
1552 
1571  int32_t getSecondaryGroupingSize(void) const;
1572 
1584  virtual void setSecondaryGroupingSize(int32_t newValue);
1585 
1594  UBool isDecimalSeparatorAlwaysShown(void) const;
1595 
1604  virtual void setDecimalSeparatorAlwaysShown(UBool newValue);
1605 
1616  virtual UnicodeString& toPattern(UnicodeString& result) const;
1617 
1628  virtual UnicodeString& toLocalizedPattern(UnicodeString& result) const;
1629 
1659  virtual void applyPattern(const UnicodeString& pattern,
1660  UParseError& parseError,
1661  UErrorCode& status);
1670  virtual void applyPattern(const UnicodeString& pattern,
1671  UErrorCode& status);
1672 
1703  virtual void applyLocalizedPattern(const UnicodeString& pattern,
1704  UParseError& parseError,
1705  UErrorCode& status);
1706 
1716  virtual void applyLocalizedPattern(const UnicodeString& pattern,
1717  UErrorCode& status);
1718 
1719 
1729  virtual void setMaximumIntegerDigits(int32_t newValue);
1730 
1740  virtual void setMinimumIntegerDigits(int32_t newValue);
1741 
1751  virtual void setMaximumFractionDigits(int32_t newValue);
1752 
1762  virtual void setMinimumFractionDigits(int32_t newValue);
1763 
1771  int32_t getMinimumSignificantDigits() const;
1772 
1780  int32_t getMaximumSignificantDigits() const;
1781 
1793  void setMinimumSignificantDigits(int32_t min);
1794 
1806  void setMaximumSignificantDigits(int32_t max);
1807 
1814  UBool areSignificantDigitsUsed() const;
1815 
1823  void setSignificantDigitsUsed(UBool useSignificantDigits);
1824 
1825  public:
1838  virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
1839 
1845  virtual void setCurrency(const UChar* theCurrency);
1846 
1852  static const char fgNumberPatterns[];
1853 
1854 #ifndef U_HIDE_INTERNAL_API
1855 
1861  FixedDecimal getFixedDecimal(double number, UErrorCode &status) const;
1862 
1869  FixedDecimal getFixedDecimal(const Formattable &number, UErrorCode &status) const;
1870 
1877  FixedDecimal getFixedDecimal(DigitList &number, UErrorCode &status) const;
1878 #endif /* U_HIDE_INTERNAL_API */
1879 
1880 public:
1881 
1893  static UClassID U_EXPORT2 getStaticClassID(void);
1894 
1906  virtual UClassID getDynamicClassID(void) const;
1907 
1908 private:
1909 
1910  DecimalFormat(); // default constructor not implemented
1911 
1912  int32_t precision() const;
1913 
1918  void init();
1919 
1923  void construct(UErrorCode& status,
1924  UParseError& parseErr,
1925  const UnicodeString* pattern = 0,
1926  DecimalFormatSymbols* symbolsToAdopt = 0
1927  );
1928 
1937  UnicodeString& toPattern(UnicodeString& result, UBool localized) const;
1938 
1949  void applyPattern(const UnicodeString& pattern,
1950  UBool localized,
1951  UParseError& parseError,
1952  UErrorCode& status);
1953 
1954  /*
1955  * similar to applyPattern, but without re-gen affix for currency
1956  */
1957  void applyPatternInternally(const UnicodeString& pluralCount,
1958  const UnicodeString& pattern,
1959  UBool localized,
1960  UParseError& parseError,
1961  UErrorCode& status);
1962 
1963  /*
1964  * only apply pattern without expand affixes
1965  */
1966  void applyPatternWithoutExpandAffix(const UnicodeString& pattern,
1967  UBool localized,
1968  UParseError& parseError,
1969  UErrorCode& status);
1970 
1971 
1972  /*
1973  * expand affixes (after apply patter) and re-compute fFormatWidth
1974  */
1975  void expandAffixAdjustWidth(const UnicodeString* pluralCount);
1976 
1977 
1988  UnicodeString& subformat(UnicodeString& appendTo,
1989  FieldPositionHandler& handler,
1990  DigitList& digits,
1991  UBool isInteger,
1992  UErrorCode &status) const;
1993 
1994 
1995  void parse(const UnicodeString& text,
1996  Formattable& result,
1997  ParsePosition& pos,
1998  UChar* currency) const;
1999 
2000  enum {
2001  fgStatusInfinite,
2002  fgStatusLength // Leave last in list.
2003  } StatusFlags;
2004 
2005  UBool subparse(const UnicodeString& text,
2006  const UnicodeString* negPrefix,
2007  const UnicodeString* negSuffix,
2008  const UnicodeString* posPrefix,
2009  const UnicodeString* posSuffix,
2010  UBool complexCurrencyParsing,
2011  int8_t type,
2012  ParsePosition& parsePosition,
2013  DigitList& digits, UBool* status,
2014  UChar* currency) const;
2015 
2016  // Mixed style parsing for currency.
2017  // It parses against the current currency pattern
2018  // using complex affix comparison
2019  // parses against the currency plural patterns using complex affix comparison,
2020  // and parses against the current pattern using simple affix comparison.
2021  UBool parseForCurrency(const UnicodeString& text,
2022  ParsePosition& parsePosition,
2023  DigitList& digits,
2024  UBool* status,
2025  UChar* currency) const;
2026 
2027  int32_t skipPadding(const UnicodeString& text, int32_t position) const;
2028 
2029  int32_t compareAffix(const UnicodeString& input,
2030  int32_t pos,
2031  UBool isNegative,
2032  UBool isPrefix,
2033  const UnicodeString* affixPat,
2034  UBool complexCurrencyParsing,
2035  int8_t type,
2036  UChar* currency) const;
2037 
2038  static UnicodeString& trimMarksFromAffix(const UnicodeString& affix, UnicodeString& trimmedAffix);
2039 
2040  UBool equalWithSignCompatibility(UChar32 lhs, UChar32 rhs) const;
2041 
2042  int32_t compareSimpleAffix(const UnicodeString& affix,
2043  const UnicodeString& input,
2044  int32_t pos,
2045  UBool lenient) const;
2046 
2047  static int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos);
2048 
2049  static int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos);
2050 
2051  static int32_t skipUWhiteSpaceAndMarks(const UnicodeString& text, int32_t pos);
2052 
2053  static int32_t skipBidiMarks(const UnicodeString& text, int32_t pos);
2054 
2055  int32_t compareComplexAffix(const UnicodeString& affixPat,
2056  const UnicodeString& input,
2057  int32_t pos,
2058  int8_t type,
2059  UChar* currency) const;
2060 
2061  static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch);
2062 
2063  static int32_t match(const UnicodeString& text, int32_t pos, const UnicodeString& str);
2064 
2065  static UBool matchSymbol(const UnicodeString &text, int32_t position, int32_t length, const UnicodeString &symbol,
2066  UnicodeSet *sset, UChar32 schar);
2067 
2068  static UBool matchDecimal(UChar32 symbolChar,
2069  UBool sawDecimal, UChar32 sawDecimalChar,
2070  const UnicodeSet *sset, UChar32 schar);
2071 
2072  static UBool matchGrouping(UChar32 groupingChar,
2073  UBool sawGrouping, UChar32 sawGroupingChar,
2074  const UnicodeSet *sset,
2075  UChar32 decimalChar, const UnicodeSet *decimalSet,
2076  UChar32 schar);
2077 
2083  inline const UnicodeString &getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const;
2084 
2085  int32_t appendAffix(UnicodeString& buf,
2086  double number,
2087  FieldPositionHandler& handler,
2088  UBool isNegative,
2089  UBool isPrefix) const;
2090 
2096  void appendAffixPattern(UnicodeString& appendTo, const UnicodeString& affix,
2097  UBool localized) const;
2098 
2099  void appendAffixPattern(UnicodeString& appendTo,
2100  const UnicodeString* affixPattern,
2101  const UnicodeString& expAffix, UBool localized) const;
2102 
2103  void expandAffix(const UnicodeString& pattern,
2104  UnicodeString& affix,
2105  double number,
2106  FieldPositionHandler& handler,
2107  UBool doFormat,
2108  const UnicodeString* pluralCount) const;
2109 
2110  void expandAffixes(const UnicodeString* pluralCount);
2111 
2112  void addPadding(UnicodeString& appendTo,
2113  FieldPositionHandler& handler,
2114  int32_t prefixLen, int32_t suffixLen) const;
2115 
2116  UBool isGroupingPosition(int32_t pos) const;
2117 
2118  void setCurrencyForSymbols();
2119 
2120  // similar to setCurrency without re-compute the affixes for currency.
2121  // If currency changes, the affix pattern for currency is not changed,
2122  // but the affix will be changed. So, affixes need to be
2123  // re-computed in setCurrency(), but not in setCurrencyInternally().
2124  virtual void setCurrencyInternally(const UChar* theCurrency, UErrorCode& ec);
2125 
2126  // set up currency affix patterns for mix parsing.
2127  // The patterns saved here are the affix patterns of default currency
2128  // pattern and the unique affix patterns of the plural currency patterns.
2129  // Those patterns are used by parseForCurrency().
2130  void setupCurrencyAffixPatterns(UErrorCode& status);
2131 
2132  // set up the currency affixes used in currency plural formatting.
2133  // It sets up both fAffixesForCurrency for currency pattern if the current
2134  // pattern contains 3 currency signs,
2135  // and it sets up fPluralAffixesForCurrency for currency plural patterns.
2136  void setupCurrencyAffixes(const UnicodeString& pattern,
2137  UBool setupForCurrentPattern,
2138  UBool setupForPluralPattern,
2139  UErrorCode& status);
2140 
2141  // hashtable operations
2142  Hashtable* initHashForAffixPattern(UErrorCode& status);
2143  Hashtable* initHashForAffix(UErrorCode& status);
2144 
2145  void deleteHashForAffixPattern();
2146  void deleteHashForAffix(Hashtable*& table);
2147 
2148  void copyHashForAffixPattern(const Hashtable* source,
2149  Hashtable* target, UErrorCode& status);
2150  void copyHashForAffix(const Hashtable* source,
2151  Hashtable* target, UErrorCode& status);
2152 
2153  UnicodeString& _format(int64_t number,
2154  UnicodeString& appendTo,
2155  FieldPositionHandler& handler,
2156  UErrorCode &status) const;
2157  UnicodeString& _format(double number,
2158  UnicodeString& appendTo,
2159  FieldPositionHandler& handler,
2160  UErrorCode &status) const;
2161  UnicodeString& _format(const DigitList &number,
2162  UnicodeString& appendTo,
2163  FieldPositionHandler& handler,
2164  UErrorCode &status) const;
2165 
2166  // currency sign count
2167  enum {
2168  fgCurrencySignCountZero,
2169  fgCurrencySignCountInSymbolFormat,
2170  fgCurrencySignCountInISOFormat,
2171  fgCurrencySignCountInPluralFormat
2172  } CurrencySignCount;
2173 
2178  UnicodeString fPositivePrefix;
2179  UnicodeString fPositiveSuffix;
2180  UnicodeString fNegativePrefix;
2181  UnicodeString fNegativeSuffix;
2182  UnicodeString* fPosPrefixPattern;
2183  UnicodeString* fPosSuffixPattern;
2184  UnicodeString* fNegPrefixPattern;
2185  UnicodeString* fNegSuffixPattern;
2186 
2192  ChoiceFormat* fCurrencyChoice;
2193 
2194  DigitList * fMultiplier; // NULL for multiplier of one
2195  int32_t fScale;
2196  int32_t fGroupingSize;
2197  int32_t fGroupingSize2;
2198  UBool fDecimalSeparatorAlwaysShown;
2199  DecimalFormatSymbols* fSymbols;
2200 
2201  UBool fUseSignificantDigits;
2202  int32_t fMinSignificantDigits;
2203  int32_t fMaxSignificantDigits;
2204 
2205  UBool fUseExponentialNotation;
2206  int8_t fMinExponentDigits;
2207  UBool fExponentSignAlwaysShown;
2208 
2209  EnumSet<UNumberFormatAttribute,
2212  fBoolFlags;
2213 
2214  DigitList* fRoundingIncrement; // NULL if no rounding increment specified.
2215  ERoundingMode fRoundingMode;
2216 
2217  UChar32 fPad;
2218  int32_t fFormatWidth;
2219  EPadPosition fPadPosition;
2220 
2221  /*
2222  * Following are used for currency format
2223  */
2224  // pattern used in this formatter
2225  UnicodeString fFormatPattern;
2226  // style is only valid when decimal formatter is constructed by
2227  // DecimalFormat(pattern, decimalFormatSymbol, style)
2228  int fStyle;
2229  /*
2230  * Represents whether this is a currency format, and which
2231  * currency format style.
2232  * 0: not currency format type;
2233  * 1: currency style -- symbol name, such as "$" for US dollar.
2234  * 2: currency style -- ISO name, such as USD for US dollar.
2235  * 3: currency style -- plural long name, such as "US Dollar" for
2236  * "1.00 US Dollar", or "US Dollars" for
2237  * "3.00 US Dollars".
2238  */
2239  int fCurrencySignCount;
2240 
2241 
2242  /* For currency parsing purose,
2243  * Need to remember all prefix patterns and suffix patterns of
2244  * every currency format pattern,
2245  * including the pattern of default currecny style
2246  * and plural currency style. And the patterns are set through applyPattern.
2247  */
2248  // TODO: innerclass?
2249  /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
2250  struct AffixPatternsForCurrency : public UMemory {
2251  // negative prefix pattern
2252  UnicodeString negPrefixPatternForCurrency;
2253  // negative suffix pattern
2254  UnicodeString negSuffixPatternForCurrency;
2255  // positive prefix pattern
2256  UnicodeString posPrefixPatternForCurrency;
2257  // positive suffix pattern
2258  UnicodeString posSuffixPatternForCurrency;
2259  int8_t patternType;
2260 
2261  AffixPatternsForCurrency(const UnicodeString& negPrefix,
2262  const UnicodeString& negSuffix,
2263  const UnicodeString& posPrefix,
2264  const UnicodeString& posSuffix,
2265  int8_t type) {
2266  negPrefixPatternForCurrency = negPrefix;
2267  negSuffixPatternForCurrency = negSuffix;
2268  posPrefixPatternForCurrency = posPrefix;
2269  posSuffixPatternForCurrency = posSuffix;
2270  patternType = type;
2271  }
2272  };
2273  */
2274 
2275  /* affix for currency formatting when the currency sign in the pattern
2276  * equals to 3, such as the pattern contains 3 currency sign or
2277  * the formatter style is currency plural format style.
2278  */
2279  /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
2280  struct AffixesForCurrency : public UMemory {
2281  // negative prefix
2282  UnicodeString negPrefixForCurrency;
2283  // negative suffix
2284  UnicodeString negSuffixForCurrency;
2285  // positive prefix
2286  UnicodeString posPrefixForCurrency;
2287  // positive suffix
2288  UnicodeString posSuffixForCurrency;
2289 
2290  int32_t formatWidth;
2291 
2292  AffixesForCurrency(const UnicodeString& negPrefix,
2293  const UnicodeString& negSuffix,
2294  const UnicodeString& posPrefix,
2295  const UnicodeString& posSuffix) {
2296  negPrefixForCurrency = negPrefix;
2297  negSuffixForCurrency = negSuffix;
2298  posPrefixForCurrency = posPrefix;
2299  posSuffixForCurrency = posSuffix;
2300  }
2301  };
2302  */
2303 
2304  // Affix pattern set for currency.
2305  // It is a set of AffixPatternsForCurrency,
2306  // each element of the set saves the negative prefix pattern,
2307  // negative suffix pattern, positive prefix pattern,
2308  // and positive suffix pattern of a pattern.
2309  // It is used for currency mixed style parsing.
2310  // It is actually is a set.
2311  // The set contains the default currency pattern from the locale,
2312  // and the currency plural patterns.
2313  // Since it is a set, it does not contain duplicated items.
2314  // For example, if 2 currency plural patterns are the same, only one pattern
2315  // is included in the set. When parsing, we do not check whether the plural
2316  // count match or not.
2317  Hashtable* fAffixPatternsForCurrency;
2318 
2319  // Following 2 are affixes for currency.
2320  // It is a hash map from plural count to AffixesForCurrency.
2321  // AffixesForCurrency saves the negative prefix,
2322  // negative suffix, positive prefix, and positive suffix of a pattern.
2323  // It is used during currency formatting only when the currency sign count
2324  // is 3. In which case, the affixes are getting from here, not
2325  // from the fNegativePrefix etc.
2326  Hashtable* fAffixesForCurrency; // for current pattern
2327  Hashtable* fPluralAffixesForCurrency; // for plural pattern
2328 
2329  // Information needed for DecimalFormat to format/parse currency plural.
2330  CurrencyPluralInfo* fCurrencyPluralInfo;
2331 
2332 #if UCONFIG_HAVE_PARSEALLINPUT
2333  UNumberFormatAttributeValue fParseAllInput;
2334 #endif
2335 
2336  // Decimal Format Static Sets singleton.
2337  const DecimalFormatStaticSets *fStaticSets;
2338 
2339 
2340 protected:
2341 
2342 #ifndef U_HIDE_INTERNAL_API
2343 
2347  DigitList& _round(const DigitList& number, DigitList& adjustedNum, UBool& isNegative, UErrorCode& status) const;
2348 #endif /* U_HIDE_INTERNAL_API */
2349 
2358  virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
2359 
2363  static const int32_t kDoubleIntegerDigits;
2367  static const int32_t kDoubleFractionDigits;
2368 
2379  static const int32_t kMaxScientificIntegerDigits;
2380 
2381 #if UCONFIG_FORMAT_FASTPATHS_49
2382  private:
2387  uint8_t fReserved[UNUM_DECIMALFORMAT_INTERNAL_SIZE];
2388 
2389 
2393  void handleChanged();
2394 #endif
2395 };
2396 
2397 inline const UnicodeString &
2398 DecimalFormat::getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const {
2399  return fSymbols->getConstSymbol(symbol);
2400 }
2401 
2403 
2404 #endif /* #if !UCONFIG_NO_FORMATTING */
2405 
2406 #endif // _DECIMFMT
2407 //eof