ICU 55.1 55.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
decimfmt.h
Go to the documentation of this file.
1 /*
2 ********************************************************************************
3 * Copyright (C) 1997-2015, 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
52 U_NAMESPACE_BEGIN
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,
66 UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1,
67 UNUM_LIMIT_BOOLEAN_ATTRIBUTE>;
68 #endif
69
663 class U_I18N_API DecimalFormat: public NumberFormat {
664 public:
669 enum ERoundingMode {
670 kRoundCeiling,
671 kRoundFloor,
672 kRoundDown,
673 kRoundUp,
674 kRoundHalfEven,
676 kRoundHalfDown,
678 kRoundHalfUp,
684 kRoundUnnecessary
685 };
686
691 enum EPadPosition {
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
813 virtual void setGroupingUsed(UBool newValue);
814
822 virtual void setParseIntegerOnly(UBool value);
823
833 virtual void setContext(UDisplayContext value, UErrorCode& status);
834
854 DecimalFormat( const UnicodeString& pattern,
855 DecimalFormatSymbols* symbolsToAdopt,
856 UParseError& parseError,
857 UErrorCode& status);
875 DecimalFormat( const UnicodeString& pattern,
876 const DecimalFormatSymbols& symbols,
877 UErrorCode& status);
878
885 DecimalFormat(const DecimalFormat& source);
886
893 DecimalFormat& operator=(const DecimalFormat& rhs);
894
899 virtual ~DecimalFormat();
900
908 virtual Format* clone(void) const;
909
918 virtual UBool operator==(const Format& other) const;
919
920
921 using NumberFormat::format;
922
934 virtual UnicodeString& format(double number,
935 UnicodeString& appendTo,
936 FieldPosition& pos) const;
937
938
951 virtual UnicodeString& format(double number,
952 UnicodeString& appendTo,
953 FieldPosition& pos,
954 UErrorCode &status) const;
955
969 virtual UnicodeString& format(double number,
970 UnicodeString& appendTo,
971 FieldPositionIterator* posIter,
972 UErrorCode& status) const;
973
985 virtual UnicodeString& format(int32_t number,
986 UnicodeString& appendTo,
987 FieldPosition& pos) const;
988
1000 virtual UnicodeString& format(int32_t number,
1001 UnicodeString& appendTo,
1002 FieldPosition& pos,
1003 UErrorCode &status) const;
1004
1018 virtual UnicodeString& format(int32_t number,
1019 UnicodeString& appendTo,
1020 FieldPositionIterator* posIter,
1021 UErrorCode& status) const;
1022
1034 virtual UnicodeString& format(int64_t number,
1035 UnicodeString& appendTo,
1036 FieldPosition& pos) const;
1037
1049 virtual UnicodeString& format(int64_t number,
1050 UnicodeString& appendTo,
1051 FieldPosition& pos,
1052 UErrorCode &status) const;
1053
1067 virtual UnicodeString& format(int64_t number,
1068 UnicodeString& appendTo,
1069 FieldPositionIterator* posIter,
1070 UErrorCode& status) const;
1071
1088 virtual UnicodeString& format(const StringPiece &number,
1089 UnicodeString& appendTo,
1090 FieldPositionIterator* posIter,
1091 UErrorCode& status) const;
1092
1093
1109 virtual UnicodeString& format(const DigitList &number,
1110 UnicodeString& appendTo,
1111 FieldPositionIterator* posIter,
1112 UErrorCode& status) const;
1113
1129 virtual UnicodeString& format(const DigitList &number,
1130 UnicodeString& appendTo,
1131 FieldPosition& pos,
1132 UErrorCode& status) const;
1133
1134 using NumberFormat::parse;
1135
1155 virtual void parse(const UnicodeString& text,
1156 Formattable& result,
1157 ParsePosition& parsePosition) const;
1158
1178 virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
1179 ParsePosition& pos) const;
1180
1188 virtual const DecimalFormatSymbols* getDecimalFormatSymbols(void) const;
1189
1196 virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt);
1197
1204 virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols);
1205
1206
1213 virtual const CurrencyPluralInfo* getCurrencyPluralInfo(void) const;
1214
1221 virtual void adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt);
1222
1229 virtual void setCurrencyPluralInfo(const CurrencyPluralInfo& info);
1230
1231
1240 UnicodeString& getPositivePrefix(UnicodeString& result) const;
1241
1249 virtual void setPositivePrefix(const UnicodeString& newValue);
1250
1259 UnicodeString& getNegativePrefix(UnicodeString& result) const;
1260
1268 virtual void setNegativePrefix(const UnicodeString& newValue);
1269
1278 UnicodeString& getPositiveSuffix(UnicodeString& result) const;
1279
1287 virtual void setPositiveSuffix(const UnicodeString& newValue);
1288
1297 UnicodeString& getNegativeSuffix(UnicodeString& result) const;
1298
1306 virtual void setNegativeSuffix(const UnicodeString& newValue);
1307
1318 int32_t getMultiplier(void) const;
1319
1330 virtual void setMultiplier(int32_t newValue);
1331
1341 virtual double getRoundingIncrement(void) const;
1342
1354 virtual void setRoundingIncrement(double newValue);
1355
1364 virtual ERoundingMode getRoundingMode(void) const;
1365
1374 virtual void setRoundingMode(ERoundingMode roundingMode);
1375
1387 virtual int32_t getFormatWidth(void) const;
1388
1403 virtual void setFormatWidth(int32_t width);
1404
1417 virtual UnicodeString getPadCharacterString() const;
1418
1433 virtual void setPadCharacter(const UnicodeString &padChar);
1434
1450 virtual EPadPosition getPadPosition(void) const;
1451
1468 virtual void setPadPosition(EPadPosition padPos);
1469
1480 virtual UBool isScientificNotation(void) const;
1481
1497 virtual void setScientificNotation(UBool useScientific);
1498
1509 virtual int8_t getMinimumExponentDigits(void) const;
1510
1523 virtual void setMinimumExponentDigits(int8_t minExpDig);
1524
1537 virtual UBool isExponentSignAlwaysShown(void) const;
1538
1552 virtual void setExponentSignAlwaysShown(UBool expSignAlways);
1553
1565 int32_t getGroupingSize(void) const;
1566
1578 virtual void setGroupingSize(int32_t newValue);
1579
1598 int32_t getSecondaryGroupingSize(void) const;
1599
1611 virtual void setSecondaryGroupingSize(int32_t newValue);
1612
1621 UBool isDecimalSeparatorAlwaysShown(void) const;
1622
1631 virtual void setDecimalSeparatorAlwaysShown(UBool newValue);
1632
1633 #ifndef U_HIDE_DRAFT_API
1634
1640 UBool isDecimalPatternMatchRequired(void) const;
1641 #endif /* U_HIDE_DRAFT_API */
1642
1652 virtual void setDecimalPatternMatchRequired(UBool newValue);
1653
1654
1665 virtual UnicodeString& toPattern(UnicodeString& result) const;
1666
1677 virtual UnicodeString& toLocalizedPattern(UnicodeString& result) const;
1678
1708 virtual void applyPattern(const UnicodeString& pattern,
1709 UParseError& parseError,
1710 UErrorCode& status);
1719 virtual void applyPattern(const UnicodeString& pattern,
1720 UErrorCode& status);
1721
1752 virtual void applyLocalizedPattern(const UnicodeString& pattern,
1753 UParseError& parseError,
1754 UErrorCode& status);
1755
1765 virtual void applyLocalizedPattern(const UnicodeString& pattern,
1766 UErrorCode& status);
1767
1768
1778 virtual void setMaximumIntegerDigits(int32_t newValue);
1779
1789 virtual void setMinimumIntegerDigits(int32_t newValue);
1790
1800 virtual void setMaximumFractionDigits(int32_t newValue);
1801
1811 virtual void setMinimumFractionDigits(int32_t newValue);
1812
1820 int32_t getMinimumSignificantDigits() const;
1821
1829 int32_t getMaximumSignificantDigits() const;
1830
1842 void setMinimumSignificantDigits(int32_t min);
1843
1855 void setMaximumSignificantDigits(int32_t max);
1856
1863 UBool areSignificantDigitsUsed() const;
1864
1872 void setSignificantDigitsUsed(UBool useSignificantDigits);
1873
1874 public:
1887 virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
1888
1894 virtual void setCurrency(const UChar* theCurrency);
1895
1896 #ifndef U_HIDE_DRAFT_API
1897
1904 void setCurrencyUsage(UCurrencyUsage newUsage, UErrorCode* ec);
1905
1910 UCurrencyUsage getCurrencyUsage() const;
1911 #endif /* U_HIDE_DRAFT_API */
1912
1913
1914 #ifndef U_HIDE_DEPRECATED_API
1915
1920 static const char fgNumberPatterns[];
1921 #endif /* U_HIDE_DEPRECATED_API */
1922
1923 #ifndef U_HIDE_INTERNAL_API
1924
1930 FixedDecimal getFixedDecimal(double number, UErrorCode &status) const;
1931
1938 FixedDecimal getFixedDecimal(const Formattable &number, UErrorCode &status) const;
1939
1946 FixedDecimal getFixedDecimal(DigitList &number, UErrorCode &status) const;
1947 #endif /* U_HIDE_INTERNAL_API */
1948
1949 public:
1950
1962 static UClassID U_EXPORT2 getStaticClassID(void);
1963
1975 virtual UClassID getDynamicClassID(void) const;
1976
1977 private:
1978
1979 DecimalFormat(); // default constructor not implemented
1980
1981 int32_t precision() const;
1982
1987 void init();
1988
1992 void construct(UErrorCode& status,
1993 UParseError& parseErr,
1994 const UnicodeString* pattern = 0,
1995 DecimalFormatSymbols* symbolsToAdopt = 0
1996 );
1997
2006 UnicodeString& toPattern(UnicodeString& result, UBool localized) const;
2007
2018 void applyPattern(const UnicodeString& pattern,
2019 UBool localized,
2020 UParseError& parseError,
2021 UErrorCode& status);
2022
2023 /*
2024 * similar to applyPattern, but without re-gen affix for currency
2025 */
2026 void applyPatternInternally(const UnicodeString& pluralCount,
2027 const UnicodeString& pattern,
2028 UBool localized,
2029 UParseError& parseError,
2030 UErrorCode& status);
2031
2032 /*
2033 * only apply pattern without expand affixes
2034 */
2035 void applyPatternWithoutExpandAffix(const UnicodeString& pattern,
2036 UBool localized,
2037 UParseError& parseError,
2038 UErrorCode& status);
2039
2040
2041 /*
2042 * expand affixes (after apply patter) and re-compute fFormatWidth
2043 */
2044 void expandAffixAdjustWidth(const UnicodeString* pluralCount);
2045
2046
2057 UnicodeString& subformat(UnicodeString& appendTo,
2058 FieldPositionHandler& handler,
2059 DigitList& digits,
2060 UBool isInteger,
2061 UErrorCode &status) const;
2062
2063
2064 void parse(const UnicodeString& text,
2065 Formattable& result,
2066 ParsePosition& pos,
2067 UChar* currency) const;
2068
2069 enum {
2070 fgStatusInfinite,
2071 fgStatusLength // Leave last in list.
2072 } StatusFlags;
2073
2074 UBool subparse(const UnicodeString& text,
2075 const UnicodeString* negPrefix,
2076 const UnicodeString* negSuffix,
2077 const UnicodeString* posPrefix,
2078 const UnicodeString* posSuffix,
2079 UBool complexCurrencyParsing,
2080 int8_t type,
2081 ParsePosition& parsePosition,
2082 DigitList& digits, UBool* status,
2083 UChar* currency) const;
2084
2085 // Mixed style parsing for currency.
2086 // It parses against the current currency pattern
2087 // using complex affix comparison
2088 // parses against the currency plural patterns using complex affix comparison,
2089 // and parses against the current pattern using simple affix comparison.
2090 UBool parseForCurrency(const UnicodeString& text,
2091 ParsePosition& parsePosition,
2092 DigitList& digits,
2093 UBool* status,
2094 UChar* currency) const;
2095
2096 int32_t skipPadding(const UnicodeString& text, int32_t position) const;
2097
2098 int32_t compareAffix(const UnicodeString& input,
2099 int32_t pos,
2100 UBool isNegative,
2101 UBool isPrefix,
2102 const UnicodeString* affixPat,
2103 UBool complexCurrencyParsing,
2104 int8_t type,
2105 UChar* currency) const;
2106
2107 static UnicodeString& trimMarksFromAffix(const UnicodeString& affix, UnicodeString& trimmedAffix);
2108
2109 UBool equalWithSignCompatibility(UChar32 lhs, UChar32 rhs) const;
2110
2111 int32_t compareSimpleAffix(const UnicodeString& affix,
2112 const UnicodeString& input,
2113 int32_t pos,
2114 UBool lenient) const;
2115
2116 static int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos);
2117
2118 static int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos);
2119
2120 static int32_t skipUWhiteSpaceAndMarks(const UnicodeString& text, int32_t pos);
2121
2122 static int32_t skipBidiMarks(const UnicodeString& text, int32_t pos);
2123
2124 int32_t compareComplexAffix(const UnicodeString& affixPat,
2125 const UnicodeString& input,
2126 int32_t pos,
2127 int8_t type,
2128 UChar* currency) const;
2129
2130 static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch);
2131
2132 static int32_t match(const UnicodeString& text, int32_t pos, const UnicodeString& str);
2133
2134 static UBool matchSymbol(const UnicodeString &text, int32_t position, int32_t length, const UnicodeString &symbol,
2135 UnicodeSet *sset, UChar32 schar);
2136
2137 static UBool matchDecimal(UChar32 symbolChar,
2138 UBool sawDecimal, UChar32 sawDecimalChar,
2139 const UnicodeSet *sset, UChar32 schar);
2140
2141 static UBool matchGrouping(UChar32 groupingChar,
2142 UBool sawGrouping, UChar32 sawGroupingChar,
2143 const UnicodeSet *sset,
2144 UChar32 decimalChar, const UnicodeSet *decimalSet,
2145 UChar32 schar);
2146
2152 inline const UnicodeString &getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const;
2153
2154 int32_t appendAffix(UnicodeString& buf,
2155 double number,
2156 FieldPositionHandler& handler,
2157 UBool isNegative,
2158 UBool isPrefix) const;
2159
2165 void appendAffixPattern(UnicodeString& appendTo, const UnicodeString& affix,
2166 UBool localized) const;
2167
2168 void appendAffixPattern(UnicodeString& appendTo,
2169 const UnicodeString* affixPattern,
2170 const UnicodeString& expAffix, UBool localized) const;
2171
2172 void expandAffix(const UnicodeString& pattern,
2173 UnicodeString& affix,
2174 double number,
2175 FieldPositionHandler& handler,
2176 UBool doFormat,
2177 const UnicodeString* pluralCount) const;
2178
2179 void expandAffixes(const UnicodeString* pluralCount);
2180
2181 void addPadding(UnicodeString& appendTo,
2182 FieldPositionHandler& handler,
2183 int32_t prefixLen, int32_t suffixLen) const;
2184
2185 UBool isGroupingPosition(int32_t pos) const;
2186
2187 void setCurrencyForSymbols();
2188
2189 // similar to setCurrency without re-compute the affixes for currency.
2190 // If currency changes, the affix pattern for currency is not changed,
2191 // but the affix will be changed. So, affixes need to be
2192 // re-computed in setCurrency(), but not in setCurrencyInternally().
2193 virtual void setCurrencyInternally(const UChar* theCurrency, UErrorCode& ec);
2194
2195 // set up currency affix patterns for mix parsing.
2196 // The patterns saved here are the affix patterns of default currency
2197 // pattern and the unique affix patterns of the plural currency patterns.
2198 // Those patterns are used by parseForCurrency().
2199 void setupCurrencyAffixPatterns(UErrorCode& status);
2200
2201 // set up the currency affixes used in currency plural formatting.
2202 // It sets up both fAffixesForCurrency for currency pattern if the current
2203 // pattern contains 3 currency signs,
2204 // and it sets up fPluralAffixesForCurrency for currency plural patterns.
2205 void setupCurrencyAffixes(const UnicodeString& pattern,
2206 UBool setupForCurrentPattern,
2207 UBool setupForPluralPattern,
2208 UErrorCode& status);
2209
2210 // get the currency rounding with respect to currency usage
2211 double getCurrencyRounding(const UChar* currency,
2212 UErrorCode* ec) const;
2213
2214 // get the currency fraction with respect to currency usage
2215 int getCurrencyFractionDigits(const UChar* currency,
2216 UErrorCode* ec) const;
2217
2218 // hashtable operations
2219 Hashtable* initHashForAffixPattern(UErrorCode& status);
2220 Hashtable* initHashForAffix(UErrorCode& status);
2221
2222 void deleteHashForAffixPattern();
2223 void deleteHashForAffix(Hashtable*& table);
2224
2225 void copyHashForAffixPattern(const Hashtable* source,
2226 Hashtable* target, UErrorCode& status);
2227 void copyHashForAffix(const Hashtable* source,
2228 Hashtable* target, UErrorCode& status);
2229
2230 UnicodeString& _format(int64_t number,
2231 UnicodeString& appendTo,
2232 FieldPositionHandler& handler,
2233 UErrorCode &status) const;
2234 UnicodeString& _format(double number,
2235 UnicodeString& appendTo,
2236 FieldPositionHandler& handler,
2237 UErrorCode &status) const;
2238 UnicodeString& _format(const DigitList &number,
2239 UnicodeString& appendTo,
2240 FieldPositionHandler& handler,
2241 UErrorCode &status) const;
2242
2247 UnicodeString fPositivePrefix;
2248 UnicodeString fPositiveSuffix;
2249 UnicodeString fNegativePrefix;
2250 UnicodeString fNegativeSuffix;
2251 UnicodeString* fPosPrefixPattern;
2252 UnicodeString* fPosSuffixPattern;
2253 UnicodeString* fNegPrefixPattern;
2254 UnicodeString* fNegSuffixPattern;
2255
2261 ChoiceFormat* fCurrencyChoice;
2262
2263 DigitList * fMultiplier; // NULL for multiplier of one
2264 int32_t fScale;
2265 int32_t fGroupingSize;
2266 int32_t fGroupingSize2;
2267 UBool fDecimalSeparatorAlwaysShown;
2268 DecimalFormatSymbols* fSymbols;
2269
2270 UBool fUseSignificantDigits;
2271 int32_t fMinSignificantDigits;
2272 int32_t fMaxSignificantDigits;
2273
2274 UBool fUseExponentialNotation;
2275 int8_t fMinExponentDigits;
2276 UBool fExponentSignAlwaysShown;
2277
2278 EnumSet<UNumberFormatAttribute,
2279 UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1,
2280 UNUM_LIMIT_BOOLEAN_ATTRIBUTE>
2281 fBoolFlags;
2282
2283 DigitList* fRoundingIncrement; // NULL if no rounding increment specified.
2284 ERoundingMode fRoundingMode;
2285
2286 UChar32 fPad;
2287 int32_t fFormatWidth;
2288 EPadPosition fPadPosition;
2289
2290 /*
2291 * Following are used for currency format
2292 */
2293 // pattern used in this formatter
2294 UnicodeString fFormatPattern;
2295 // style is only valid when decimal formatter is constructed by
2296 // DecimalFormat(pattern, decimalFormatSymbol, style)
2297 int fStyle;
2298 /*
2299 * Represents whether this is a currency format, and which
2300 * currency format style.
2301 * 0: not currency format type;
2302 * 1: currency style -- symbol name, such as "$" for US dollar.
2303 * 2: currency style -- ISO name, such as USD for US dollar.
2304 * 3: currency style -- plural long name, such as "US Dollar" for
2305 * "1.00 US Dollar", or "US Dollars" for
2306 * "3.00 US Dollars".
2307 */
2308 int fCurrencySignCount;
2309
2310
2311 /* For currency parsing purose,
2312 * Need to remember all prefix patterns and suffix patterns of
2313 * every currency format pattern,
2314 * including the pattern of default currecny style
2315 * and plural currency style. And the patterns are set through applyPattern.
2316 */
2317 // TODO: innerclass?
2318 /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
2319 struct AffixPatternsForCurrency : public UMemory {
2320 // negative prefix pattern
2321 UnicodeString negPrefixPatternForCurrency;
2322 // negative suffix pattern
2323 UnicodeString negSuffixPatternForCurrency;
2324 // positive prefix pattern
2325 UnicodeString posPrefixPatternForCurrency;
2326 // positive suffix pattern
2327 UnicodeString posSuffixPatternForCurrency;
2328 int8_t patternType;
2329
2330 AffixPatternsForCurrency(const UnicodeString& negPrefix,
2331 const UnicodeString& negSuffix,
2332 const UnicodeString& posPrefix,
2333 const UnicodeString& posSuffix,
2334 int8_t type) {
2335 negPrefixPatternForCurrency = negPrefix;
2336 negSuffixPatternForCurrency = negSuffix;
2337 posPrefixPatternForCurrency = posPrefix;
2338 posSuffixPatternForCurrency = posSuffix;
2339 patternType = type;
2340 }
2341 };
2342 */
2343
2344 /* affix for currency formatting when the currency sign in the pattern
2345 * equals to 3, such as the pattern contains 3 currency sign or
2346 * the formatter style is currency plural format style.
2347 */
2348 /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
2349 struct AffixesForCurrency : public UMemory {
2350 // negative prefix
2351 UnicodeString negPrefixForCurrency;
2352 // negative suffix
2353 UnicodeString negSuffixForCurrency;
2354 // positive prefix
2355 UnicodeString posPrefixForCurrency;
2356 // positive suffix
2357 UnicodeString posSuffixForCurrency;
2358
2359 int32_t formatWidth;
2360
2361 AffixesForCurrency(const UnicodeString& negPrefix,
2362 const UnicodeString& negSuffix,
2363 const UnicodeString& posPrefix,
2364 const UnicodeString& posSuffix) {
2365 negPrefixForCurrency = negPrefix;
2366 negSuffixForCurrency = negSuffix;
2367 posPrefixForCurrency = posPrefix;
2368 posSuffixForCurrency = posSuffix;
2369 }
2370 };
2371 */
2372
2373 // Affix pattern set for currency.
2374 // It is a set of AffixPatternsForCurrency,
2375 // each element of the set saves the negative prefix pattern,
2376 // negative suffix pattern, positive prefix pattern,
2377 // and positive suffix pattern of a pattern.
2378 // It is used for currency mixed style parsing.
2379 // It is actually is a set.
2380 // The set contains the default currency pattern from the locale,
2381 // and the currency plural patterns.
2382 // Since it is a set, it does not contain duplicated items.
2383 // For example, if 2 currency plural patterns are the same, only one pattern
2384 // is included in the set. When parsing, we do not check whether the plural
2385 // count match or not.
2386 Hashtable* fAffixPatternsForCurrency;
2387
2388 // Following 2 are affixes for currency.
2389 // It is a hash map from plural count to AffixesForCurrency.
2390 // AffixesForCurrency saves the negative prefix,
2391 // negative suffix, positive prefix, and positive suffix of a pattern.
2392 // It is used during currency formatting only when the currency sign count
2393 // is 3. In which case, the affixes are getting from here, not
2394 // from the fNegativePrefix etc.
2395 Hashtable* fAffixesForCurrency; // for current pattern
2396 Hashtable* fPluralAffixesForCurrency; // for plural pattern
2397
2398 // Information needed for DecimalFormat to format/parse currency plural.
2399 CurrencyPluralInfo* fCurrencyPluralInfo;
2400
2401 #if UCONFIG_HAVE_PARSEALLINPUT
2402 UNumberFormatAttributeValue fParseAllInput;
2403 #endif
2404
2405 // Decimal Format Static Sets singleton.
2406 const DecimalFormatStaticSets *fStaticSets;
2407
2408 // Currency Usage(STANDARD vs CASH)
2409 UCurrencyUsage fCurrencyUsage;
2410
2411 protected:
2412
2413 #ifndef U_HIDE_INTERNAL_API
2414
2418 DigitList& _round(const DigitList& number, DigitList& adjustedNum, UBool& isNegative, UErrorCode& status) const;
2419 #endif /* U_HIDE_INTERNAL_API */
2420
2429 virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
2430
2434 static const int32_t kDoubleIntegerDigits;
2438 static const int32_t kDoubleFractionDigits;
2439
2450 static const int32_t kMaxScientificIntegerDigits;
2451
2452 #if UCONFIG_FORMAT_FASTPATHS_49
2453 private:
2458 uint8_t fReserved[UNUM_DECIMALFORMAT_INTERNAL_SIZE];
2459
2460
2464 void handleChanged();
2465 #endif
2466 };
2467
2468 inline const UnicodeString &
2469 DecimalFormat::getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const {
2470 return fSymbols->getConstSymbol(symbol);
2471 }
2472
2473 U_NAMESPACE_END
2474
2475 #endif /* #if !UCONFIG_NO_FORMATTING */
2476
2477 #endif // _DECIMFMT
2478 //eof