ICU 49.1.2  49.1.2
decimfmt.h
Go to the documentation of this file.
00001 /*
00002 ********************************************************************************
00003 *   Copyright (C) 1997-2012, International Business Machines
00004 *   Corporation and others.  All Rights Reserved.
00005 ********************************************************************************
00006 *
00007 * File DECIMFMT.H
00008 *
00009 * Modification History:
00010 *
00011 *   Date        Name        Description
00012 *   02/19/97    aliu        Converted from java.
00013 *   03/20/97    clhuang     Updated per C++ implementation.
00014 *   04/03/97    aliu        Rewrote parsing and formatting completely, and
00015 *                           cleaned up and debugged.  Actually works now.
00016 *   04/17/97    aliu        Changed DigitCount to int per code review.
00017 *   07/10/97    helena      Made ParsePosition a class and get rid of the function
00018 *                           hiding problems.
00019 *   09/09/97    aliu        Ported over support for exponential formats.
00020 *    07/20/98    stephen        Changed documentation
00021 ********************************************************************************
00022 */
00023 
00024 #ifndef DECIMFMT_H
00025 #define DECIMFMT_H
00026 
00027 #include "unicode/utypes.h"
00033 #if !UCONFIG_NO_FORMATTING
00034 
00035 #include "unicode/dcfmtsym.h"
00036 #include "unicode/numfmt.h"
00037 #include "unicode/locid.h"
00038 #include "unicode/fpositer.h"
00039 #include "unicode/stringpiece.h"
00040 #include "unicode/curramt.h"
00041 
00046 #if UCONFIG_FORMAT_FASTPATHS_49
00047 #define UNUM_DECIMALFORMAT_INTERNAL_SIZE 16
00048 #endif
00049 
00050 U_NAMESPACE_BEGIN
00051 
00052 class DigitList;
00053 class ChoiceFormat;
00054 class CurrencyPluralInfo;
00055 class Hashtable;
00056 class UnicodeSet;
00057 class FieldPositionHandler;
00058 
00652 class U_I18N_API DecimalFormat: public NumberFormat {
00653 public:
00658     enum ERoundingMode {
00659         kRoundCeiling,  
00660         kRoundFloor,    
00661         kRoundDown,     
00662         kRoundUp,       
00663         kRoundHalfEven, 
00665         kRoundHalfDown, 
00667         kRoundHalfUp,   
00673         kRoundUnnecessary
00674     };
00675 
00680     enum EPadPosition {
00681         kPadBeforePrefix,
00682         kPadAfterPrefix,
00683         kPadBeforeSuffix,
00684         kPadAfterSuffix
00685     };
00686 
00700     DecimalFormat(UErrorCode& status);
00701 
00716     DecimalFormat(const UnicodeString& pattern,
00717                   UErrorCode& status);
00718 
00737     DecimalFormat(  const UnicodeString& pattern,
00738                     DecimalFormatSymbols* symbolsToAdopt,
00739                     UErrorCode& status);
00740 
00741 #ifndef U_HIDE_INTERNAL_API
00742 
00754     DecimalFormat(  const UnicodeString& pattern,
00755                     DecimalFormatSymbols* symbolsToAdopt,
00756                     UNumberFormatStyle style,
00757                     UErrorCode& status);
00758 
00759 
00760 #if UCONFIG_HAVE_PARSEALLINPUT
00761 
00764     void setParseAllInput(UNumberFormatAttributeValue value);
00765 #endif
00766 
00767 #endif  /* U_HIDE_INTERNAL_API */
00768 
00788     DecimalFormat(  const UnicodeString& pattern,
00789                     DecimalFormatSymbols* symbolsToAdopt,
00790                     UParseError& parseError,
00791                     UErrorCode& status);
00809     DecimalFormat(  const UnicodeString& pattern,
00810                     const DecimalFormatSymbols& symbols,
00811                     UErrorCode& status);
00812 
00819     DecimalFormat(const DecimalFormat& source);
00820 
00827     DecimalFormat& operator=(const DecimalFormat& rhs);
00828 
00833     virtual ~DecimalFormat();
00834 
00842     virtual Format* clone(void) const;
00843 
00852     virtual UBool operator==(const Format& other) const;
00853 
00854 
00855     using NumberFormat::format;
00856 
00868     virtual UnicodeString& format(double number,
00869                                   UnicodeString& appendTo,
00870                                   FieldPosition& pos) const;
00871 
00885     virtual UnicodeString& format(double number,
00886                                   UnicodeString& appendTo,
00887                                   FieldPositionIterator* posIter,
00888                                   UErrorCode& status) const;
00889 
00901     virtual UnicodeString& format(int32_t number,
00902                                   UnicodeString& appendTo,
00903                                   FieldPosition& pos) const;
00904 
00918     virtual UnicodeString& format(int32_t number,
00919                                   UnicodeString& appendTo,
00920                                   FieldPositionIterator* posIter,
00921                                   UErrorCode& status) const;
00922 
00934     virtual UnicodeString& format(int64_t number,
00935                                   UnicodeString& appendTo,
00936                                   FieldPosition& pos) const;
00937 
00951     virtual UnicodeString& format(int64_t number,
00952                                   UnicodeString& appendTo,
00953                                   FieldPositionIterator* posIter,
00954                                   UErrorCode& status) const;
00955 
00972     virtual UnicodeString& format(const StringPiece &number,
00973                                   UnicodeString& appendTo,
00974                                   FieldPositionIterator* posIter,
00975                                   UErrorCode& status) const;
00976 
00977 
00993     virtual UnicodeString& format(const DigitList &number,
00994                                   UnicodeString& appendTo,
00995                                   FieldPositionIterator* posIter,
00996                                   UErrorCode& status) const;
00997 
01013     virtual UnicodeString& format(const DigitList &number,
01014                                   UnicodeString& appendTo,
01015                                   FieldPosition& pos,
01016                                   UErrorCode& status) const;
01017 
01018 
01031     virtual UnicodeString& format(const Formattable& obj,
01032                                   UnicodeString& appendTo,
01033                                   FieldPosition& pos,
01034                                   UErrorCode& status) const;
01035 
01047     UnicodeString& format(const Formattable& obj,
01048                           UnicodeString& appendTo,
01049                           UErrorCode& status) const;
01050 
01061     UnicodeString& format(double number,
01062                           UnicodeString& appendTo) const;
01063 
01075     UnicodeString& format(int32_t number,
01076                           UnicodeString& appendTo) const;
01077 
01089     UnicodeString& format(int64_t number,
01090                           UnicodeString& appendTo) const;
01110     virtual void parse(const UnicodeString& text,
01111                        Formattable& result,
01112                        ParsePosition& parsePosition) const;
01113 
01114     // Declare here again to get rid of function hiding problems.
01123     virtual void parse(const UnicodeString& text,
01124                        Formattable& result,
01125                        UErrorCode& status) const;
01126 
01127 /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */
01147     virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
01148                                           ParsePosition& pos) const;
01149 
01157     virtual const DecimalFormatSymbols* getDecimalFormatSymbols(void) const;
01158 
01165     virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt);
01166 
01173     virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols);
01174 
01175 
01182     virtual const CurrencyPluralInfo* getCurrencyPluralInfo(void) const;
01183 
01190     virtual void adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt);
01191 
01198     virtual void setCurrencyPluralInfo(const CurrencyPluralInfo& info);
01199 
01200 
01209     UnicodeString& getPositivePrefix(UnicodeString& result) const;
01210 
01218     virtual void setPositivePrefix(const UnicodeString& newValue);
01219 
01228     UnicodeString& getNegativePrefix(UnicodeString& result) const;
01229 
01237     virtual void setNegativePrefix(const UnicodeString& newValue);
01238 
01247     UnicodeString& getPositiveSuffix(UnicodeString& result) const;
01248 
01256     virtual void setPositiveSuffix(const UnicodeString& newValue);
01257 
01266     UnicodeString& getNegativeSuffix(UnicodeString& result) const;
01267 
01275     virtual void setNegativeSuffix(const UnicodeString& newValue);
01276 
01287     int32_t getMultiplier(void) const;
01288 
01299     virtual void setMultiplier(int32_t newValue);
01300 
01310     virtual double getRoundingIncrement(void) const;
01311 
01322     virtual void setRoundingIncrement(double newValue);
01323 
01332     virtual ERoundingMode getRoundingMode(void) const;
01333 
01342     virtual void setRoundingMode(ERoundingMode roundingMode);
01343 
01355     virtual int32_t getFormatWidth(void) const;
01356 
01371     virtual void setFormatWidth(int32_t width);
01372 
01385     virtual UnicodeString getPadCharacterString() const;
01386 
01401     virtual void setPadCharacter(const UnicodeString &padChar);
01402 
01418     virtual EPadPosition getPadPosition(void) const;
01419 
01436     virtual void setPadPosition(EPadPosition padPos);
01437 
01448     virtual UBool isScientificNotation(void);
01449 
01465     virtual void setScientificNotation(UBool useScientific);
01466 
01477     virtual int8_t getMinimumExponentDigits(void) const;
01478 
01491     virtual void setMinimumExponentDigits(int8_t minExpDig);
01492 
01505     virtual UBool isExponentSignAlwaysShown(void);
01506 
01520     virtual void setExponentSignAlwaysShown(UBool expSignAlways);
01521 
01533     int32_t getGroupingSize(void) const;
01534 
01546     virtual void setGroupingSize(int32_t newValue);
01547 
01566     int32_t getSecondaryGroupingSize(void) const;
01567 
01579     virtual void setSecondaryGroupingSize(int32_t newValue);
01580 
01589     UBool isDecimalSeparatorAlwaysShown(void) const;
01590 
01599     virtual void setDecimalSeparatorAlwaysShown(UBool newValue);
01600 
01611     virtual UnicodeString& toPattern(UnicodeString& result) const;
01612 
01623     virtual UnicodeString& toLocalizedPattern(UnicodeString& result) const;
01624 
01654     virtual void applyPattern(const UnicodeString& pattern,
01655                              UParseError& parseError,
01656                              UErrorCode& status);
01665     virtual void applyPattern(const UnicodeString& pattern,
01666                              UErrorCode& status);
01667 
01698     virtual void applyLocalizedPattern(const UnicodeString& pattern,
01699                                        UParseError& parseError,
01700                                        UErrorCode& status);
01701 
01711     virtual void applyLocalizedPattern(const UnicodeString& pattern,
01712                                        UErrorCode& status);
01713 
01714 
01724     virtual void setMaximumIntegerDigits(int32_t newValue);
01725 
01735     virtual void setMinimumIntegerDigits(int32_t newValue);
01736 
01746     virtual void setMaximumFractionDigits(int32_t newValue);
01747 
01757     virtual void setMinimumFractionDigits(int32_t newValue);
01758 
01766     int32_t getMinimumSignificantDigits() const;
01767 
01775     int32_t getMaximumSignificantDigits() const;
01776 
01786     void setMinimumSignificantDigits(int32_t min);
01787 
01798     void setMaximumSignificantDigits(int32_t max);
01799 
01806     UBool areSignificantDigitsUsed() const;
01807 
01815     void setSignificantDigitsUsed(UBool useSignificantDigits);
01816 
01817  public:
01830     virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
01831 
01837     virtual void setCurrency(const UChar* theCurrency);
01838 
01844     static const char fgNumberPatterns[];
01845 
01846 public:
01847 
01859     static UClassID U_EXPORT2 getStaticClassID(void);
01860 
01872     virtual UClassID getDynamicClassID(void) const;
01873 
01874 private:
01875 
01876     DecimalFormat(); // default constructor not implemented
01877 
01878     int32_t precision() const;
01879 
01884     void init(UErrorCode& status);
01885 
01889     void construct(UErrorCode&               status,
01890                    UParseError&             parseErr,
01891                    const UnicodeString*     pattern = 0,
01892                    DecimalFormatSymbols*    symbolsToAdopt = 0
01893                    );
01894 
01903     UnicodeString& toPattern(UnicodeString& result, UBool localized) const;
01904 
01915     void applyPattern(const UnicodeString& pattern,
01916                             UBool localized,
01917                             UParseError& parseError,
01918                             UErrorCode& status);
01919 
01920     /*
01921      * similar to applyPattern, but without re-gen affix for currency
01922      */
01923     void applyPatternInternally(const UnicodeString& pluralCount,
01924                                 const UnicodeString& pattern,
01925                                 UBool localized,
01926                                 UParseError& parseError,
01927                                 UErrorCode& status);
01928 
01929     /*
01930      * only apply pattern without expand affixes
01931      */
01932     void applyPatternWithoutExpandAffix(const UnicodeString& pattern,
01933                                         UBool localized,
01934                                         UParseError& parseError,
01935                                         UErrorCode& status);
01936 
01937 
01938     /*
01939      * expand affixes (after apply patter) and re-compute fFormatWidth
01940      */
01941     void expandAffixAdjustWidth(const UnicodeString* pluralCount);
01942 
01943 
01954     UnicodeString& subformat(UnicodeString& appendTo,
01955                              FieldPositionHandler& handler,
01956                              DigitList&     digits,
01957                              UBool          isInteger) const;
01958 
01959 
01960     void parse(const UnicodeString& text,
01961                Formattable& result,
01962                ParsePosition& pos,
01963                UChar* currency) const;
01964 
01965     enum {
01966         fgStatusInfinite,
01967         fgStatusLength      // Leave last in list.
01968     } StatusFlags;
01969 
01970     UBool subparse(const UnicodeString& text,
01971                    const UnicodeString* negPrefix,
01972                    const UnicodeString* negSuffix,
01973                    const UnicodeString* posPrefix,
01974                    const UnicodeString* posSuffix,
01975                    UBool currencyParsing,
01976                    int8_t type,
01977                    ParsePosition& parsePosition,
01978                    DigitList& digits, UBool* status,
01979                    UChar* currency) const;
01980 
01981     // Mixed style parsing for currency.
01982     // It parses against the current currency pattern
01983     // using complex affix comparison
01984     // parses against the currency plural patterns using complex affix comparison,
01985     // and parses against the current pattern using simple affix comparison.
01986     UBool parseForCurrency(const UnicodeString& text,
01987                            ParsePosition& parsePosition,
01988                            DigitList& digits,
01989                            UBool* status,
01990                            UChar* currency) const;
01991 
01992     int32_t skipPadding(const UnicodeString& text, int32_t position) const;
01993 
01994     int32_t compareAffix(const UnicodeString& input,
01995                          int32_t pos,
01996                          UBool isNegative,
01997                          UBool isPrefix,
01998                          const UnicodeString* affixPat,
01999                          UBool currencyParsing,
02000                          int8_t type,
02001                          UChar* currency) const;
02002 
02003     static int32_t compareSimpleAffix(const UnicodeString& affix,
02004                                       const UnicodeString& input,
02005                                       int32_t pos,
02006                                       UBool lenient);
02007 
02008     static int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos);
02009 
02010     static int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos);
02011 
02012     int32_t compareComplexAffix(const UnicodeString& affixPat,
02013                                 const UnicodeString& input,
02014                                 int32_t pos,
02015                                 int8_t type,
02016                                 UChar* currency) const;
02017 
02018     static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch);
02019 
02020     static int32_t match(const UnicodeString& text, int32_t pos, const UnicodeString& str);
02021 
02022     static UBool matchSymbol(const UnicodeString &text, int32_t position, int32_t length, const UnicodeString &symbol,
02023                              UnicodeSet *sset, UChar32 schar);
02024 
02025     static UBool matchDecimal(UChar32 symbolChar,
02026                             UBool sawDecimal,  UChar32 sawDecimalChar,
02027                              const UnicodeSet *sset, UChar32 schar);
02028 
02029     static UBool matchGrouping(UChar32 groupingChar,
02030                             UBool sawGrouping, UChar32 sawGroupingChar,
02031                              const UnicodeSet *sset,
02032                              UChar32 decimalChar, const UnicodeSet *decimalSet,
02033                              UChar32 schar);
02034 
02040     inline const UnicodeString &getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const;
02041 
02042     int32_t appendAffix(UnicodeString& buf,
02043                         double number,
02044                         FieldPositionHandler& handler,
02045                         UBool isNegative,
02046                         UBool isPrefix) const;
02047 
02053     void appendAffixPattern(UnicodeString& appendTo, const UnicodeString& affix,
02054                             UBool localized) const;
02055 
02056     void appendAffixPattern(UnicodeString& appendTo,
02057                             const UnicodeString* affixPattern,
02058                             const UnicodeString& expAffix, UBool localized) const;
02059 
02060     void expandAffix(const UnicodeString& pattern,
02061                      UnicodeString& affix,
02062                      double number,
02063                      FieldPositionHandler& handler,
02064                      UBool doFormat,
02065                      const UnicodeString* pluralCount) const;
02066 
02067     void expandAffixes(const UnicodeString* pluralCount);
02068 
02069     void addPadding(UnicodeString& appendTo,
02070                     FieldPositionHandler& handler,
02071                     int32_t prefixLen, int32_t suffixLen) const;
02072 
02073     UBool isGroupingPosition(int32_t pos) const;
02074 
02075     void setCurrencyForSymbols();
02076 
02077     // similar to setCurrency without re-compute the affixes for currency.
02078     // If currency changes, the affix pattern for currency is not changed,
02079     // but the affix will be changed. So, affixes need to be
02080     // re-computed in setCurrency(), but not in setCurrencyInternally().
02081     virtual void setCurrencyInternally(const UChar* theCurrency, UErrorCode& ec);
02082 
02083     // set up currency affix patterns for mix parsing.
02084     // The patterns saved here are the affix patterns of default currency
02085     // pattern and the unique affix patterns of the plural currency patterns.
02086     // Those patterns are used by parseForCurrency().
02087     void setupCurrencyAffixPatterns(UErrorCode& status);
02088 
02089     // set up the currency affixes used in currency plural formatting.
02090     // It sets up both fAffixesForCurrency for currency pattern if the current
02091     // pattern contains 3 currency signs,
02092     // and it sets up fPluralAffixesForCurrency for currency plural patterns.
02093     void setupCurrencyAffixes(const UnicodeString& pattern,
02094                               UBool setupForCurrentPattern,
02095                               UBool setupForPluralPattern,
02096                               UErrorCode& status);
02097 
02098     // hashtable operations
02099     Hashtable* initHashForAffixPattern(UErrorCode& status);
02100     Hashtable* initHashForAffix(UErrorCode& status);
02101 
02102     void deleteHashForAffixPattern();
02103     void deleteHashForAffix(Hashtable*& table);
02104 
02105     void copyHashForAffixPattern(const Hashtable* source,
02106                                  Hashtable* target, UErrorCode& status);
02107     void copyHashForAffix(const Hashtable* source,
02108                           Hashtable* target, UErrorCode& status);
02109 
02110     UnicodeString& _format(int64_t number,
02111                            UnicodeString& appendTo,
02112                            FieldPositionHandler& handler) const;
02113     UnicodeString& _format(double number,
02114                            UnicodeString& appendTo,
02115                            FieldPositionHandler& handler) const;
02116     UnicodeString& _format(const DigitList &number,
02117                            UnicodeString& appendTo,
02118                            FieldPositionHandler& handler,
02119                            UErrorCode &status) const;
02120 
02121     // currency sign count
02122     enum {
02123         fgCurrencySignCountZero,
02124         fgCurrencySignCountInSymbolFormat,
02125         fgCurrencySignCountInISOFormat,
02126         fgCurrencySignCountInPluralFormat
02127     } CurrencySignCount;
02128 
02133     UnicodeString           fPositivePrefix;
02134     UnicodeString           fPositiveSuffix;
02135     UnicodeString           fNegativePrefix;
02136     UnicodeString           fNegativeSuffix;
02137     UnicodeString*          fPosPrefixPattern;
02138     UnicodeString*          fPosSuffixPattern;
02139     UnicodeString*          fNegPrefixPattern;
02140     UnicodeString*          fNegSuffixPattern;
02141 
02147     ChoiceFormat*           fCurrencyChoice;
02148 
02149     DigitList *             fMultiplier;   // NULL for multiplier of one
02150     int32_t                 fGroupingSize;
02151     int32_t                 fGroupingSize2;
02152     UBool                   fDecimalSeparatorAlwaysShown;
02153     DecimalFormatSymbols*   fSymbols;
02154 
02155     UBool                   fUseSignificantDigits;
02156     int32_t                 fMinSignificantDigits;
02157     int32_t                 fMaxSignificantDigits;
02158 
02159     UBool                   fUseExponentialNotation;
02160     int8_t                  fMinExponentDigits;
02161     UBool                   fExponentSignAlwaysShown;
02162 
02163     DigitList*              fRoundingIncrement;  // NULL if no rounding increment specified.
02164     ERoundingMode           fRoundingMode;
02165 
02166     UChar32                 fPad;
02167     int32_t                 fFormatWidth;
02168     EPadPosition            fPadPosition;
02169 
02170     /*
02171      * Following are used for currency format
02172      */
02173     // pattern used in this formatter
02174     UnicodeString fFormatPattern;
02175     // style is only valid when decimal formatter is constructed by
02176     // DecimalFormat(pattern, decimalFormatSymbol, style)
02177     int fStyle;
02178     /*
02179      * Represents whether this is a currency format, and which
02180      * currency format style.
02181      * 0: not currency format type;
02182      * 1: currency style -- symbol name, such as "$" for US dollar.
02183      * 2: currency style -- ISO name, such as USD for US dollar.
02184      * 3: currency style -- plural long name, such as "US Dollar" for
02185      *                      "1.00 US Dollar", or "US Dollars" for
02186      *                      "3.00 US Dollars".
02187      */
02188     int fCurrencySignCount;
02189 
02190 
02191     /* For currency parsing purose,
02192      * Need to remember all prefix patterns and suffix patterns of
02193      * every currency format pattern,
02194      * including the pattern of default currecny style
02195      * and plural currency style. And the patterns are set through applyPattern.
02196      */
02197     // TODO: innerclass?
02198     /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
02199     struct AffixPatternsForCurrency : public UMemory {
02200         // negative prefix pattern
02201         UnicodeString negPrefixPatternForCurrency;
02202         // negative suffix pattern
02203         UnicodeString negSuffixPatternForCurrency;
02204         // positive prefix pattern
02205         UnicodeString posPrefixPatternForCurrency;
02206         // positive suffix pattern
02207         UnicodeString posSuffixPatternForCurrency;
02208         int8_t patternType;
02209 
02210         AffixPatternsForCurrency(const UnicodeString& negPrefix,
02211                                  const UnicodeString& negSuffix,
02212                                  const UnicodeString& posPrefix,
02213                                  const UnicodeString& posSuffix,
02214                                  int8_t type) {
02215             negPrefixPatternForCurrency = negPrefix;
02216             negSuffixPatternForCurrency = negSuffix;
02217             posPrefixPatternForCurrency = posPrefix;
02218             posSuffixPatternForCurrency = posSuffix;
02219             patternType = type;
02220         }
02221     };
02222     */
02223 
02224     /* affix for currency formatting when the currency sign in the pattern
02225      * equals to 3, such as the pattern contains 3 currency sign or
02226      * the formatter style is currency plural format style.
02227      */
02228     /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
02229     struct AffixesForCurrency : public UMemory {
02230         // negative prefix
02231         UnicodeString negPrefixForCurrency;
02232         // negative suffix
02233         UnicodeString negSuffixForCurrency;
02234         // positive prefix
02235         UnicodeString posPrefixForCurrency;
02236         // positive suffix
02237         UnicodeString posSuffixForCurrency;
02238 
02239         int32_t formatWidth;
02240 
02241         AffixesForCurrency(const UnicodeString& negPrefix,
02242                            const UnicodeString& negSuffix,
02243                            const UnicodeString& posPrefix,
02244                            const UnicodeString& posSuffix) {
02245             negPrefixForCurrency = negPrefix;
02246             negSuffixForCurrency = negSuffix;
02247             posPrefixForCurrency = posPrefix;
02248             posSuffixForCurrency = posSuffix;
02249         }
02250     };
02251     */
02252 
02253     // Affix pattern set for currency.
02254     // It is a set of AffixPatternsForCurrency,
02255     // each element of the set saves the negative prefix pattern,
02256     // negative suffix pattern, positive prefix pattern,
02257     // and positive suffix  pattern of a pattern.
02258     // It is used for currency mixed style parsing.
02259     // It is actually is a set.
02260     // The set contains the default currency pattern from the locale,
02261     // and the currency plural patterns.
02262     // Since it is a set, it does not contain duplicated items.
02263     // For example, if 2 currency plural patterns are the same, only one pattern
02264     // is included in the set. When parsing, we do not check whether the plural
02265     // count match or not.
02266     Hashtable* fAffixPatternsForCurrency;
02267 
02268     // Following 2 are affixes for currency.
02269     // It is a hash map from plural count to AffixesForCurrency.
02270     // AffixesForCurrency saves the negative prefix,
02271     // negative suffix, positive prefix, and positive suffix of a pattern.
02272     // It is used during currency formatting only when the currency sign count
02273     // is 3. In which case, the affixes are getting from here, not
02274     // from the fNegativePrefix etc.
02275     Hashtable* fAffixesForCurrency;  // for current pattern
02276     Hashtable* fPluralAffixesForCurrency;  // for plural pattern
02277 
02278     // Information needed for DecimalFormat to format/parse currency plural.
02279     CurrencyPluralInfo* fCurrencyPluralInfo;
02280 
02281 #if UCONFIG_HAVE_PARSEALLINPUT
02282     UNumberFormatAttributeValue fParseAllInput;
02283 #endif
02284 
02285 
02286 protected:
02287 
02296     virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
02297 
02301     static const int32_t  kDoubleIntegerDigits;
02305     static const int32_t  kDoubleFractionDigits;
02306 
02317     static const int32_t  kMaxScientificIntegerDigits;
02318 
02319 #if UCONFIG_FORMAT_FASTPATHS_49
02320  private:
02325     uint8_t fReserved[UNUM_DECIMALFORMAT_INTERNAL_SIZE];
02326 
02327 
02331     void handleChanged();
02332 #endif
02333 };
02334 
02335 inline UnicodeString&
02336 DecimalFormat::format(const Formattable& obj,
02337                       UnicodeString& appendTo,
02338                       UErrorCode& status) const {
02339     // Don't use Format:: - use immediate base class only,
02340     // in case immediate base modifies behavior later.
02341     return NumberFormat::format(obj, appendTo, status);
02342 }
02343 
02344 inline UnicodeString&
02345 DecimalFormat::format(double number,
02346                       UnicodeString& appendTo) const {
02347     FieldPosition pos(0);
02348     return format(number, appendTo, pos);
02349 }
02350 
02351 inline UnicodeString&
02352 DecimalFormat::format(int32_t number,
02353                       UnicodeString& appendTo) const {
02354     FieldPosition pos(0);
02355     return format((int64_t)number, appendTo, pos);
02356 }
02357 
02358 #ifndef U_HIDE_INTERNAL_API
02359 inline const UnicodeString &
02360 DecimalFormat::getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const {
02361     return fSymbols->getConstSymbol(symbol);
02362 }
02363 #endif
02364 
02365 U_NAMESPACE_END
02366 
02367 #endif /* #if !UCONFIG_NO_FORMATTING */
02368 
02369 #endif // _DECIMFMT
02370 //eof