ICU 4.8.1.1  4.8.1.1
 All Data Structures 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-2011, 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 ********************************************************************************
22 */
23 
24 #ifndef DECIMFMT_H
25 #define DECIMFMT_H
26 
27 #include "unicode/utypes.h"
33 #if !UCONFIG_NO_FORMATTING
34 
35 #include "unicode/dcfmtsym.h"
36 #include "unicode/numfmt.h"
37 #include "unicode/locid.h"
38 #include "unicode/fpositer.h"
39 #include "unicode/stringpiece.h"
40 
41 union UHashTok;
42 
44 
45 class DigitList;
46 class ChoiceFormat;
47 class CurrencyPluralInfo;
48 class Hashtable;
49 class UnicodeSet;
50 class FieldPositionHandler;
51 
646 public:
656  kRoundHalfEven,
658  kRoundHalfDown,
660  kRoundHalfUp,
666  kRoundUnnecessary
667  };
668 
674  kPadBeforePrefix,
675  kPadAfterPrefix,
676  kPadBeforeSuffix,
677  kPadAfterSuffix
678  };
679 
693  DecimalFormat(UErrorCode& status);
694 
709  DecimalFormat(const UnicodeString& pattern,
710  UErrorCode& status);
711 
730  DecimalFormat( const UnicodeString& pattern,
731  DecimalFormatSymbols* symbolsToAdopt,
732  UErrorCode& status);
733 
746  DecimalFormat( const UnicodeString& pattern,
747  DecimalFormatSymbols* symbolsToAdopt,
748  UNumberFormatStyle style,
749  UErrorCode& status);
750 
770  DecimalFormat( const UnicodeString& pattern,
771  DecimalFormatSymbols* symbolsToAdopt,
772  UParseError& parseError,
773  UErrorCode& status);
791  DecimalFormat( const UnicodeString& pattern,
792  const DecimalFormatSymbols& symbols,
793  UErrorCode& status);
794 
801  DecimalFormat(const DecimalFormat& source);
802 
810 
815  virtual ~DecimalFormat();
816 
824  virtual Format* clone(void) const;
825 
834  virtual UBool operator==(const Format& other) const;
835 
836 
837  using NumberFormat::format;
838 
850  virtual UnicodeString& format(double number,
851  UnicodeString& appendTo,
852  FieldPosition& pos) const;
853 
867  virtual UnicodeString& format(double number,
868  UnicodeString& appendTo,
869  FieldPositionIterator* posIter,
870  UErrorCode& status) const;
871 
883  virtual UnicodeString& format(int32_t number,
884  UnicodeString& appendTo,
885  FieldPosition& pos) const;
886 
900  virtual UnicodeString& format(int32_t number,
901  UnicodeString& appendTo,
902  FieldPositionIterator* posIter,
903  UErrorCode& status) const;
904 
916  virtual UnicodeString& format(int64_t number,
917  UnicodeString& appendTo,
918  FieldPosition& pos) const;
919 
933  virtual UnicodeString& format(int64_t number,
934  UnicodeString& appendTo,
935  FieldPositionIterator* posIter,
936  UErrorCode& status) const;
937 
954  virtual UnicodeString& format(const StringPiece &number,
955  UnicodeString& appendTo,
956  FieldPositionIterator* posIter,
957  UErrorCode& status) const;
958 
959 
975  virtual UnicodeString& format(const DigitList &number,
976  UnicodeString& appendTo,
977  FieldPositionIterator* posIter,
978  UErrorCode& status) const;
979 
995  virtual UnicodeString& format(const DigitList &number,
996  UnicodeString& appendTo,
997  FieldPosition& pos,
998  UErrorCode& status) const;
999 
1000 
1013  virtual UnicodeString& format(const Formattable& obj,
1014  UnicodeString& appendTo,
1015  FieldPosition& pos,
1016  UErrorCode& status) const;
1017 
1029  UnicodeString& format(const Formattable& obj,
1030  UnicodeString& appendTo,
1031  UErrorCode& status) const;
1032 
1043  UnicodeString& format(double number,
1044  UnicodeString& appendTo) const;
1045 
1057  UnicodeString& format(int32_t number,
1058  UnicodeString& appendTo) const;
1059 
1071  UnicodeString& format(int64_t number,
1072  UnicodeString& appendTo) const;
1092  virtual void parse(const UnicodeString& text,
1093  Formattable& result,
1094  ParsePosition& parsePosition) const;
1095 
1096  // Declare here again to get rid of function hiding problems.
1105  virtual void parse(const UnicodeString& text,
1106  Formattable& result,
1107  UErrorCode& status) const;
1108 
1128  virtual Formattable& parseCurrency(const UnicodeString& text,
1129  Formattable& result,
1130  ParsePosition& pos) const;
1131 
1139  virtual const DecimalFormatSymbols* getDecimalFormatSymbols(void) const;
1140 
1147  virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt);
1148 
1155  virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols);
1156 
1157 
1164  virtual const CurrencyPluralInfo* getCurrencyPluralInfo(void) const;
1165 
1172  virtual void adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt);
1173 
1180  virtual void setCurrencyPluralInfo(const CurrencyPluralInfo& info);
1181 
1182 
1191  UnicodeString& getPositivePrefix(UnicodeString& result) const;
1192 
1200  virtual void setPositivePrefix(const UnicodeString& newValue);
1201 
1210  UnicodeString& getNegativePrefix(UnicodeString& result) const;
1211 
1219  virtual void setNegativePrefix(const UnicodeString& newValue);
1220 
1229  UnicodeString& getPositiveSuffix(UnicodeString& result) const;
1230 
1238  virtual void setPositiveSuffix(const UnicodeString& newValue);
1239 
1248  UnicodeString& getNegativeSuffix(UnicodeString& result) const;
1249 
1257  virtual void setNegativeSuffix(const UnicodeString& newValue);
1258 
1269  int32_t getMultiplier(void) const;
1270 
1281  virtual void setMultiplier(int32_t newValue);
1282 
1292  virtual double getRoundingIncrement(void) const;
1293 
1304  virtual void setRoundingIncrement(double newValue);
1305 
1314  virtual ERoundingMode getRoundingMode(void) const;
1315 
1324  virtual void setRoundingMode(ERoundingMode roundingMode);
1325 
1337  virtual int32_t getFormatWidth(void) const;
1338 
1353  virtual void setFormatWidth(int32_t width);
1354 
1367  virtual UnicodeString getPadCharacterString() const;
1368 
1383  virtual void setPadCharacter(const UnicodeString &padChar);
1384 
1400  virtual EPadPosition getPadPosition(void) const;
1401 
1418  virtual void setPadPosition(EPadPosition padPos);
1419 
1430  virtual UBool isScientificNotation(void);
1431 
1447  virtual void setScientificNotation(UBool useScientific);
1448 
1459  virtual int8_t getMinimumExponentDigits(void) const;
1460 
1473  virtual void setMinimumExponentDigits(int8_t minExpDig);
1474 
1487  virtual UBool isExponentSignAlwaysShown(void);
1488 
1502  virtual void setExponentSignAlwaysShown(UBool expSignAlways);
1503 
1515  int32_t getGroupingSize(void) const;
1516 
1528  virtual void setGroupingSize(int32_t newValue);
1529 
1548  int32_t getSecondaryGroupingSize(void) const;
1549 
1561  virtual void setSecondaryGroupingSize(int32_t newValue);
1562 
1571  UBool isDecimalSeparatorAlwaysShown(void) const;
1572 
1581  virtual void setDecimalSeparatorAlwaysShown(UBool newValue);
1582 
1593  virtual UnicodeString& toPattern(UnicodeString& result) const;
1594 
1605  virtual UnicodeString& toLocalizedPattern(UnicodeString& result) const;
1606 
1636  virtual void applyPattern(const UnicodeString& pattern,
1637  UParseError& parseError,
1638  UErrorCode& status);
1647  virtual void applyPattern(const UnicodeString& pattern,
1648  UErrorCode& status);
1649 
1680  virtual void applyLocalizedPattern(const UnicodeString& pattern,
1681  UParseError& parseError,
1682  UErrorCode& status);
1683 
1693  virtual void applyLocalizedPattern(const UnicodeString& pattern,
1694  UErrorCode& status);
1695 
1696 
1706  virtual void setMaximumIntegerDigits(int32_t newValue);
1707 
1717  virtual void setMinimumIntegerDigits(int32_t newValue);
1718 
1728  virtual void setMaximumFractionDigits(int32_t newValue);
1729 
1739  virtual void setMinimumFractionDigits(int32_t newValue);
1740 
1748  int32_t getMinimumSignificantDigits() const;
1749 
1757  int32_t getMaximumSignificantDigits() const;
1758 
1768  void setMinimumSignificantDigits(int32_t min);
1769 
1780  void setMaximumSignificantDigits(int32_t max);
1781 
1788  UBool areSignificantDigitsUsed() const;
1789 
1797  void setSignificantDigitsUsed(UBool useSignificantDigits);
1798 
1799  public:
1812  virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
1813 
1819  virtual void setCurrency(const UChar* theCurrency);
1820 
1826  static const char fgNumberPatterns[];
1827 
1828 public:
1829 
1841  static UClassID U_EXPORT2 getStaticClassID(void);
1842 
1854  virtual UClassID getDynamicClassID(void) const;
1855 
1856 private:
1857 
1858  DecimalFormat(); // default constructor not implemented
1859 
1860  int32_t precision() const;
1861 
1866  void init();
1867 
1871  void construct(UErrorCode& status,
1872  UParseError& parseErr,
1873  const UnicodeString* pattern = 0,
1874  DecimalFormatSymbols* symbolsToAdopt = 0
1875  );
1876 
1885  UnicodeString& toPattern(UnicodeString& result, UBool localized) const;
1886 
1897  void applyPattern(const UnicodeString& pattern,
1898  UBool localized,
1899  UParseError& parseError,
1900  UErrorCode& status);
1901 
1902  /*
1903  * similar to applyPattern, but without re-gen affix for currency
1904  */
1905  void applyPatternInternally(const UnicodeString& pluralCount,
1906  const UnicodeString& pattern,
1907  UBool localized,
1908  UParseError& parseError,
1909  UErrorCode& status);
1910 
1911  /*
1912  * only apply pattern without expand affixes
1913  */
1914  void applyPatternWithoutExpandAffix(const UnicodeString& pattern,
1915  UBool localized,
1916  UParseError& parseError,
1917  UErrorCode& status);
1918 
1919 
1920  /*
1921  * expand affixes (after apply patter) and re-compute fFormatWidth
1922  */
1923  void expandAffixAdjustWidth(const UnicodeString* pluralCount);
1924 
1925 
1936  UnicodeString& subformat(UnicodeString& appendTo,
1937  FieldPositionHandler& handler,
1938  DigitList& digits,
1939  UBool isInteger) const;
1940 
1941 
1942  void parse(const UnicodeString& text,
1943  Formattable& result,
1944  ParsePosition& pos,
1945  UBool parseCurrency) const;
1946 
1947  enum {
1948  fgStatusInfinite,
1949  fgStatusLength // Leave last in list.
1950  } StatusFlags;
1951 
1952  UBool subparse(const UnicodeString& text,
1953  const UnicodeString* negPrefix,
1954  const UnicodeString* negSuffix,
1955  const UnicodeString* posPrefix,
1956  const UnicodeString* posSuffix,
1957  UBool currencyParsing,
1958  int8_t type,
1959  ParsePosition& parsePosition,
1960  DigitList& digits, UBool* status,
1961  UChar* currency) const;
1962 
1963  // Mixed style parsing for currency.
1964  // It parses against the current currency pattern
1965  // using complex affix comparison
1966  // parses against the currency plural patterns using complex affix comparison,
1967  // and parses against the current pattern using simple affix comparison.
1968  UBool parseForCurrency(const UnicodeString& text,
1969  ParsePosition& parsePosition,
1970  DigitList& digits,
1971  UBool* status,
1972  UChar* currency) const;
1973 
1974  int32_t skipPadding(const UnicodeString& text, int32_t position) const;
1975 
1976  int32_t compareAffix(const UnicodeString& input,
1977  int32_t pos,
1978  UBool isNegative,
1979  UBool isPrefix,
1980  const UnicodeString* affixPat,
1981  UBool currencyParsing,
1982  int8_t type,
1983  UChar* currency) const;
1984 
1985  static int32_t compareSimpleAffix(const UnicodeString& affix,
1986  const UnicodeString& input,
1987  int32_t pos,
1988  UBool lenient);
1989 
1990  static int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos);
1991 
1992  static int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos);
1993 
1994  int32_t compareComplexAffix(const UnicodeString& affixPat,
1995  const UnicodeString& input,
1996  int32_t pos,
1997  int8_t type,
1998  UChar* currency) const;
1999 
2000  static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch);
2001 
2002  static int32_t match(const UnicodeString& text, int32_t pos, const UnicodeString& str);
2003 
2004  static UBool matchSymbol(const UnicodeString &text, int32_t position, int32_t length, const UnicodeString &symbol,
2005  UnicodeSet *sset, UChar32 schar);
2006 
2007  static UBool matchDecimal(UChar32 symbolChar,
2008  UBool sawDecimal, UChar32 sawDecimalChar,
2009  const UnicodeSet *sset, UChar32 schar);
2010 
2011  static UBool matchGrouping(UChar32 groupingChar,
2012  UBool sawGrouping, UChar32 sawGroupingChar,
2013  const UnicodeSet *sset,
2014  UChar32 decimalChar, const UnicodeSet *decimalSet,
2015  UChar32 schar);
2016 
2022  inline const UnicodeString &getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const;
2023 
2024  int32_t appendAffix(UnicodeString& buf,
2025  double number,
2026  FieldPositionHandler& handler,
2027  UBool isNegative,
2028  UBool isPrefix) const;
2029 
2035  void appendAffixPattern(UnicodeString& appendTo, const UnicodeString& affix,
2036  UBool localized) const;
2037 
2038  void appendAffixPattern(UnicodeString& appendTo,
2039  const UnicodeString* affixPattern,
2040  const UnicodeString& expAffix, UBool localized) const;
2041 
2042  void expandAffix(const UnicodeString& pattern,
2043  UnicodeString& affix,
2044  double number,
2045  FieldPositionHandler& handler,
2046  UBool doFormat,
2047  const UnicodeString* pluralCount) const;
2048 
2049  void expandAffixes(const UnicodeString* pluralCount);
2050 
2051  void addPadding(UnicodeString& appendTo,
2052  FieldPositionHandler& handler,
2053  int32_t prefixLen, int32_t suffixLen) const;
2054 
2055  UBool isGroupingPosition(int32_t pos) const;
2056 
2057  void setCurrencyForSymbols();
2058 
2059  // similar to setCurrency without re-compute the affixes for currency.
2060  // If currency changes, the affix pattern for currency is not changed,
2061  // but the affix will be changed. So, affixes need to be
2062  // re-computed in setCurrency(), but not in setCurrencyInternally().
2063  virtual void setCurrencyInternally(const UChar* theCurrency, UErrorCode& ec);
2064 
2065  // set up currency affix patterns for mix parsing.
2066  // The patterns saved here are the affix patterns of default currency
2067  // pattern and the unique affix patterns of the plural currency patterns.
2068  // Those patterns are used by parseForCurrency().
2069  void setupCurrencyAffixPatterns(UErrorCode& status);
2070 
2071  // set up the currency affixes used in currency plural formatting.
2072  // It sets up both fAffixesForCurrency for currency pattern if the current
2073  // pattern contains 3 currency signs,
2074  // and it sets up fPluralAffixesForCurrency for currency plural patterns.
2075  void setupCurrencyAffixes(const UnicodeString& pattern,
2076  UBool setupForCurrentPattern,
2077  UBool setupForPluralPattern,
2078  UErrorCode& status);
2079 
2080  // hashtable operations
2081  Hashtable* initHashForAffixPattern(UErrorCode& status);
2082  Hashtable* initHashForAffix(UErrorCode& status);
2083 
2084  void deleteHashForAffixPattern();
2085  void deleteHashForAffix(Hashtable*& table);
2086 
2087  void copyHashForAffixPattern(const Hashtable* source,
2088  Hashtable* target, UErrorCode& status);
2089  void copyHashForAffix(const Hashtable* source,
2090  Hashtable* target, UErrorCode& status);
2091 
2092  UnicodeString& _format(int64_t number,
2093  UnicodeString& appendTo,
2094  FieldPositionHandler& handler) const;
2095  UnicodeString& _format(double number,
2096  UnicodeString& appendTo,
2097  FieldPositionHandler& handler) const;
2098  UnicodeString& _format(const DigitList &number,
2099  UnicodeString& appendTo,
2100  FieldPositionHandler& handler,
2101  UErrorCode &status) const;
2102 
2103  // currency sign count
2104  enum {
2105  fgCurrencySignCountZero,
2106  fgCurrencySignCountInSymbolFormat,
2107  fgCurrencySignCountInISOFormat,
2108  fgCurrencySignCountInPluralFormat
2109  } CurrencySignCount;
2110 
2115  UnicodeString fPositivePrefix;
2116  UnicodeString fPositiveSuffix;
2117  UnicodeString fNegativePrefix;
2118  UnicodeString fNegativeSuffix;
2119  UnicodeString* fPosPrefixPattern;
2120  UnicodeString* fPosSuffixPattern;
2121  UnicodeString* fNegPrefixPattern;
2122  UnicodeString* fNegSuffixPattern;
2123 
2129  ChoiceFormat* fCurrencyChoice;
2130 
2131  DigitList * fMultiplier; // NULL for multiplier of one
2132  int32_t fGroupingSize;
2133  int32_t fGroupingSize2;
2134  UBool fDecimalSeparatorAlwaysShown;
2135  DecimalFormatSymbols* fSymbols;
2136 
2137  UBool fUseSignificantDigits;
2138  int32_t fMinSignificantDigits;
2139  int32_t fMaxSignificantDigits;
2140 
2141  UBool fUseExponentialNotation;
2142  int8_t fMinExponentDigits;
2143  UBool fExponentSignAlwaysShown;
2144 
2145  DigitList* fRoundingIncrement; // NULL if no rounding increment specified.
2146  ERoundingMode fRoundingMode;
2147 
2148  UChar32 fPad;
2149  int32_t fFormatWidth;
2150  EPadPosition fPadPosition;
2151 
2152  /*
2153  * Following are used for currency format
2154  */
2155  // pattern used in this formatter
2156  UnicodeString fFormatPattern;
2157  // style is only valid when decimal formatter is constructed by
2158  // DecimalFormat(pattern, decimalFormatSymbol, style)
2159  int fStyle;
2160  /*
2161  * Represents whether this is a currency format, and which
2162  * currency format style.
2163  * 0: not currency format type;
2164  * 1: currency style -- symbol name, such as "$" for US dollar.
2165  * 2: currency style -- ISO name, such as USD for US dollar.
2166  * 3: currency style -- plural long name, such as "US Dollar" for
2167  * "1.00 US Dollar", or "US Dollars" for
2168  * "3.00 US Dollars".
2169  */
2170  int fCurrencySignCount;
2171 
2172 
2173  /* For currency parsing purose,
2174  * Need to remember all prefix patterns and suffix patterns of
2175  * every currency format pattern,
2176  * including the pattern of default currecny style
2177  * and plural currency style. And the patterns are set through applyPattern.
2178  */
2179  // TODO: innerclass?
2180  /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
2181  struct AffixPatternsForCurrency : public UMemory {
2182  // negative prefix pattern
2183  UnicodeString negPrefixPatternForCurrency;
2184  // negative suffix pattern
2185  UnicodeString negSuffixPatternForCurrency;
2186  // positive prefix pattern
2187  UnicodeString posPrefixPatternForCurrency;
2188  // positive suffix pattern
2189  UnicodeString posSuffixPatternForCurrency;
2190  int8_t patternType;
2191 
2192  AffixPatternsForCurrency(const UnicodeString& negPrefix,
2193  const UnicodeString& negSuffix,
2194  const UnicodeString& posPrefix,
2195  const UnicodeString& posSuffix,
2196  int8_t type) {
2197  negPrefixPatternForCurrency = negPrefix;
2198  negSuffixPatternForCurrency = negSuffix;
2199  posPrefixPatternForCurrency = posPrefix;
2200  posSuffixPatternForCurrency = posSuffix;
2201  patternType = type;
2202  }
2203  };
2204  */
2205 
2206  /* affix for currency formatting when the currency sign in the pattern
2207  * equals to 3, such as the pattern contains 3 currency sign or
2208  * the formatter style is currency plural format style.
2209  */
2210  /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
2211  struct AffixesForCurrency : public UMemory {
2212  // negative prefix
2213  UnicodeString negPrefixForCurrency;
2214  // negative suffix
2215  UnicodeString negSuffixForCurrency;
2216  // positive prefix
2217  UnicodeString posPrefixForCurrency;
2218  // positive suffix
2219  UnicodeString posSuffixForCurrency;
2220 
2221  int32_t formatWidth;
2222 
2223  AffixesForCurrency(const UnicodeString& negPrefix,
2224  const UnicodeString& negSuffix,
2225  const UnicodeString& posPrefix,
2226  const UnicodeString& posSuffix) {
2227  negPrefixForCurrency = negPrefix;
2228  negSuffixForCurrency = negSuffix;
2229  posPrefixForCurrency = posPrefix;
2230  posSuffixForCurrency = posSuffix;
2231  }
2232  };
2233  */
2234 
2235  // Affix pattern set for currency.
2236  // It is a set of AffixPatternsForCurrency,
2237  // each element of the set saves the negative prefix pattern,
2238  // negative suffix pattern, positive prefix pattern,
2239  // and positive suffix pattern of a pattern.
2240  // It is used for currency mixed style parsing.
2241  // It is actually is a set.
2242  // The set contains the default currency pattern from the locale,
2243  // and the currency plural patterns.
2244  // Since it is a set, it does not contain duplicated items.
2245  // For example, if 2 currency plural patterns are the same, only one pattern
2246  // is included in the set. When parsing, we do not check whether the plural
2247  // count match or not.
2248  Hashtable* fAffixPatternsForCurrency;
2249 
2250  // Following 2 are affixes for currency.
2251  // It is a hash map from plural count to AffixesForCurrency.
2252  // AffixesForCurrency saves the negative prefix,
2253  // negative suffix, positive prefix, and positive suffix of a pattern.
2254  // It is used during currency formatting only when the currency sign count
2255  // is 3. In which case, the affixes are getting from here, not
2256  // from the fNegativePrefix etc.
2257  Hashtable* fAffixesForCurrency; // for current pattern
2258  Hashtable* fPluralAffixesForCurrency; // for plural pattern
2259 
2260  // Information needed for DecimalFormat to format/parse currency plural.
2261  CurrencyPluralInfo* fCurrencyPluralInfo;
2262 
2263 protected:
2264 
2273  virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
2274 
2278  static const int32_t kDoubleIntegerDigits;
2282  static const int32_t kDoubleFractionDigits;
2283 
2294  static const int32_t kMaxScientificIntegerDigits;
2295 };
2296 
2297 inline UnicodeString&
2299  UnicodeString& appendTo,
2300  UErrorCode& status) const {
2301  // Don't use Format:: - use immediate base class only,
2302  // in case immediate base modifies behavior later.
2303  return NumberFormat::format(obj, appendTo, status);
2304 }
2305 
2306 inline UnicodeString&
2308  UnicodeString& appendTo) const {
2309  FieldPosition pos(0);
2310  return format(number, appendTo, pos);
2311 }
2312 
2313 inline UnicodeString&
2314 DecimalFormat::format(int32_t number,
2315  UnicodeString& appendTo) const {
2316  FieldPosition pos(0);
2317  return format((int64_t)number, appendTo, pos);
2318 }
2319 
2320 inline const UnicodeString &
2321 DecimalFormat::getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const {
2322  return fSymbols->getConstSymbol(symbol);
2323 }
2324 
2326 
2327 #endif /* #if !UCONFIG_NO_FORMATTING */
2328 
2329 #endif // _DECIMFMT
2330 //eof
Round towards negative infinity.
Definition: decimfmt.h:653
static UClassID getStaticClassID(void)
Return the class ID for this class.
virtual void parse(const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const =0
Return a long if possible (e.g.
This class represents the information needed by DecimalFormat to format currency plural, such as "3.00 US dollars" or "1.00 US dollar".
Definition: currpinf.h:46
A mutable set of Unicode characters and multicharacter strings.
Definition: uniset.h:272
C++ API: FieldPosition Iterator.
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:52
static const int32_t kDoubleIntegerDigits
number of integer digits
Definition: decimfmt.h:2278
virtual UBool operator==(const Format &other) const
Return true if the given Format objects are semantically equal.
static const int32_t kMaxScientificIntegerDigits
When someone turns on scientific mode, we assume that more than this number of digits is due to flipp...
Definition: decimfmt.h:2294
This class represents the set of symbols needed by DecimalFormat to format numbers.
Definition: dcfmtsym.h:84
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:521
C++ API: StringPiece: Read-only byte string wrapper class.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
Abstract base class for all number formats.
Definition: numfmt.h:165
virtual void setMinimumFractionDigits(int32_t newValue)
Sets the minimum number of digits allowed in the fraction portion of a number.
UNumberFormatStyle
The possible number format styles.
Definition: unum.h:135
virtual void setMaximumFractionDigits(int32_t newValue)
Sets the maximum number of digits allowed in the fraction portion of a number.
NumberFormat & operator=(const NumberFormat &)
Assignment operator.
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:47
ERoundingMode
Rounding mode.
Definition: decimfmt.h:651
virtual void getEffectiveCurrency(UChar *result, UErrorCode &ec) const
Returns the currency in effect for this formatter.
EPadPosition
Pad position.
Definition: decimfmt.h:673
ENumberFormatSymbol
Constants for specifying a number format symbol.
Definition: dcfmtsym.h:90
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:345
virtual Formattable & parseCurrency(const UnicodeString &text, Formattable &result, ParsePosition &pos) const
Parses text from the given string as a currency amount.
const UnicodeString & getConstSymbol(ENumberFormatSymbol symbol) const
Internal function - more efficient version of getSymbol, returning a const reference to one of the sy...
Definition: dcfmtsym.h:403
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:188
#define U_EXPORT2
Definition: platform.h:314
FieldPositionIterator returns the field ids and their start/limit positions generated by a call to Fo...
Definition: fpositer.h:53
Round away from zero.
Definition: decimfmt.h:655
ChoiceFormat converts between ranges of numeric values and strings for those ranges.
Definition: choicfmt.h:168
virtual void setMaximumIntegerDigits(int32_t newValue)
Sets the maximum number of digits allowed in the integer portion of a number.
virtual UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Format an object to produce a string.
virtual Format * clone() const =0
Clone this object polymorphically.
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:106
uint16_t UChar
Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
Definition: umachine.h:325
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:52
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
Definition: utypes.h:385
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:639
virtual UClassID getDynamicClassID(void) const =0
Returns a unique class ID POLYMORPHICALLY.
static const int32_t kDoubleFractionDigits
number of fraction digits
Definition: decimfmt.h:2282
C++ API: Symbols for formatting numbers.
C++ API: Locale ID object.
DecimalFormat is a concrete subclass of NumberFormat that formats decimal numbers.
Definition: decimfmt.h:645
Round towards zero.
Definition: decimfmt.h:654
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:56
Base class for all formats.
Definition: format.h:94
Basic definitions for ICU, for both C and C++ APIs.
Round towards positive infinity.
Definition: decimfmt.h:652
virtual UnicodeString & format(double number, UnicodeString &appendTo, FieldPosition &pos) const
Format a double or long number using base-10 representation.
C++ API: Abstract base class for all number formats.
virtual void setMinimumIntegerDigits(int32_t newValue)
Sets the minimum number of digits allowed in the integer portion of a number.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:228
virtual void setCurrency(const UChar *theCurrency, UErrorCode &ec)
Sets the currency used to display currency amounts.