ICU 4.2.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-2009, 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 
39 union UHashTok;
40 
42 
44 
48 UBool U_CALLCONV decimfmtAffixValueComparator(UHashTok val1, UHashTok val2) ;
49 
53 UBool U_CALLCONV decimfmtAffixPatternValueComparator(UHashTok val1, UHashTok val2) ;
54 
56 
57 class DigitList;
58 class ChoiceFormat;
59 class CurrencyPluralInfo;
60 class Hashtable;
61 
651 public:
661  kRoundHalfEven,
663  kRoundHalfDown,
665  kRoundHalfUp
667  // We don't support ROUND_UNNECESSARY
668  };
669 
675  kPadBeforePrefix,
676  kPadAfterPrefix,
677  kPadBeforeSuffix,
678  kPadAfterSuffix
679  };
680 
694  DecimalFormat(UErrorCode& status);
695 
710  DecimalFormat(const UnicodeString& pattern,
711  UErrorCode& status);
712 
731  DecimalFormat( const UnicodeString& pattern,
732  DecimalFormatSymbols* symbolsToAdopt,
733  UErrorCode& status);
734 
747  DecimalFormat( const UnicodeString& pattern,
748  DecimalFormatSymbols* symbolsToAdopt,
749  NumberFormat::EStyles style,
750  UErrorCode& status);
751 
771  DecimalFormat( const UnicodeString& pattern,
772  DecimalFormatSymbols* symbolsToAdopt,
773  UParseError& parseError,
774  UErrorCode& status);
792  DecimalFormat( const UnicodeString& pattern,
793  const DecimalFormatSymbols& symbols,
794  UErrorCode& status);
795 
802  DecimalFormat(const DecimalFormat& source);
803 
811 
816  virtual ~DecimalFormat();
817 
825  virtual Format* clone(void) const;
826 
835  virtual UBool operator==(const Format& other) const;
836 
848  virtual UnicodeString& format(double number,
849  UnicodeString& appendTo,
850  FieldPosition& pos) const;
862  virtual UnicodeString& format(int32_t number,
863  UnicodeString& appendTo,
864  FieldPosition& pos) const;
876  virtual UnicodeString& format(int64_t number,
877  UnicodeString& appendTo,
878  FieldPosition& pos) const;
879 
892  virtual UnicodeString& format(const Formattable& obj,
893  UnicodeString& appendTo,
894  FieldPosition& pos,
895  UErrorCode& status) const;
896 
908  UnicodeString& format(const Formattable& obj,
909  UnicodeString& appendTo,
910  UErrorCode& status) const;
911 
922  UnicodeString& format(double number,
923  UnicodeString& appendTo) const;
924 
936  UnicodeString& format(int32_t number,
937  UnicodeString& appendTo) const;
938 
950  UnicodeString& format(int64_t number,
951  UnicodeString& appendTo) const;
971  virtual void parse(const UnicodeString& text,
972  Formattable& result,
973  ParsePosition& parsePosition) const;
974 
975  // Declare here again to get rid of function hiding problems.
984  virtual void parse(const UnicodeString& text,
985  Formattable& result,
986  UErrorCode& status) const;
987 
1007  virtual Formattable& parseCurrency(const UnicodeString& text,
1008  Formattable& result,
1009  ParsePosition& pos) const;
1010 
1018  virtual const DecimalFormatSymbols* getDecimalFormatSymbols(void) const;
1019 
1026  virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt);
1027 
1034  virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols);
1035 
1036 
1043  virtual const CurrencyPluralInfo* getCurrencyPluralInfo(void) const;
1044 
1051  virtual void adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt);
1052 
1059  virtual void setCurrencyPluralInfo(const CurrencyPluralInfo& info);
1060 
1061 
1070  UnicodeString& getPositivePrefix(UnicodeString& result) const;
1071 
1079  virtual void setPositivePrefix(const UnicodeString& newValue);
1080 
1089  UnicodeString& getNegativePrefix(UnicodeString& result) const;
1090 
1098  virtual void setNegativePrefix(const UnicodeString& newValue);
1099 
1108  UnicodeString& getPositiveSuffix(UnicodeString& result) const;
1109 
1117  virtual void setPositiveSuffix(const UnicodeString& newValue);
1118 
1127  UnicodeString& getNegativeSuffix(UnicodeString& result) const;
1128 
1136  virtual void setNegativeSuffix(const UnicodeString& newValue);
1137 
1148  int32_t getMultiplier(void) const;
1149 
1160  virtual void setMultiplier(int32_t newValue);
1161 
1171  virtual double getRoundingIncrement(void) const;
1172 
1183  virtual void setRoundingIncrement(double newValue);
1184 
1193  virtual ERoundingMode getRoundingMode(void) const;
1194 
1204  virtual void setRoundingMode(ERoundingMode roundingMode);
1205 
1217  virtual int32_t getFormatWidth(void) const;
1218 
1233  virtual void setFormatWidth(int32_t width);
1234 
1247  virtual UnicodeString getPadCharacterString() const;
1248 
1263  virtual void setPadCharacter(const UnicodeString &padChar);
1264 
1280  virtual EPadPosition getPadPosition(void) const;
1281 
1298  virtual void setPadPosition(EPadPosition padPos);
1299 
1310  virtual UBool isScientificNotation(void);
1311 
1327  virtual void setScientificNotation(UBool useScientific);
1328 
1339  virtual int8_t getMinimumExponentDigits(void) const;
1340 
1353  virtual void setMinimumExponentDigits(int8_t minExpDig);
1354 
1367  virtual UBool isExponentSignAlwaysShown(void);
1368 
1382  virtual void setExponentSignAlwaysShown(UBool expSignAlways);
1383 
1395  int32_t getGroupingSize(void) const;
1396 
1408  virtual void setGroupingSize(int32_t newValue);
1409 
1428  int32_t getSecondaryGroupingSize(void) const;
1429 
1441  virtual void setSecondaryGroupingSize(int32_t newValue);
1442 
1451  UBool isDecimalSeparatorAlwaysShown(void) const;
1452 
1461  virtual void setDecimalSeparatorAlwaysShown(UBool newValue);
1462 
1473  virtual UnicodeString& toPattern(UnicodeString& result) const;
1474 
1485  virtual UnicodeString& toLocalizedPattern(UnicodeString& result) const;
1486 
1516  virtual void applyPattern(const UnicodeString& pattern,
1517  UParseError& parseError,
1518  UErrorCode& status);
1527  virtual void applyPattern(const UnicodeString& pattern,
1528  UErrorCode& status);
1529 
1560  virtual void applyLocalizedPattern(const UnicodeString& pattern,
1561  UParseError& parseError,
1562  UErrorCode& status);
1563 
1573  virtual void applyLocalizedPattern(const UnicodeString& pattern,
1574  UErrorCode& status);
1575 
1576 
1586  virtual void setMaximumIntegerDigits(int32_t newValue);
1587 
1597  virtual void setMinimumIntegerDigits(int32_t newValue);
1598 
1608  virtual void setMaximumFractionDigits(int32_t newValue);
1609 
1619  virtual void setMinimumFractionDigits(int32_t newValue);
1620 
1628  int32_t getMinimumSignificantDigits() const;
1629 
1637  int32_t getMaximumSignificantDigits() const;
1638 
1648  void setMinimumSignificantDigits(int32_t min);
1649 
1660  void setMaximumSignificantDigits(int32_t max);
1661 
1668  UBool areSignificantDigitsUsed() const;
1669 
1677  void setSignificantDigitsUsed(UBool useSignificantDigits);
1678 
1679  public:
1692  virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
1693 
1699  virtual void setCurrency(const UChar* theCurrency);
1700 
1706  static const char fgNumberPatterns[];
1707 
1708 public:
1709 
1721  static UClassID U_EXPORT2 getStaticClassID(void);
1722 
1734  virtual UClassID getDynamicClassID(void) const;
1735 
1736 private:
1737  friend UBool U_CALLCONV decimfmtAffixValueComparator(UHashTok val1, UHashTok val2);
1738  friend UBool U_CALLCONV decimfmtAffixPatternValueComparator(UHashTok val1, UHashTok val2);
1739 
1740  DecimalFormat(); // default constructor not implemented
1741 
1742  int32_t precision(UBool isIntegral) const;
1743 
1747  void construct(UErrorCode& status,
1748  UParseError& parseErr,
1749  const UnicodeString* pattern = 0,
1750  DecimalFormatSymbols* symbolsToAdopt = 0
1751  );
1752 
1761  UnicodeString& toPattern(UnicodeString& result, UBool localized) const;
1762 
1773  void applyPattern(const UnicodeString& pattern,
1774  UBool localized,
1775  UParseError& parseError,
1776  UErrorCode& status);
1777 
1778  /*
1779  * similar to applyPattern, but without re-gen affix for currency
1780  */
1781  void applyPatternInternally(const UnicodeString& pluralCount,
1782  const UnicodeString& pattern,
1783  UBool localized,
1784  UParseError& parseError,
1785  UErrorCode& status);
1786 
1787  /*
1788  * only apply pattern without expand affixes
1789  */
1790  void applyPatternWithoutExpandAffix(const UnicodeString& pattern,
1791  UBool localized,
1792  UParseError& parseError,
1793  UErrorCode& status);
1794 
1795 
1796  /*
1797  * expand affixes (after apply patter) and re-compute fFormatWidth
1798  */
1799  void expandAffixAdjustWidth(const UnicodeString* pluralCount);
1800 
1801 
1813  UnicodeString& subformat(UnicodeString& appendTo,
1814  FieldPosition& fieldPosition,
1815  DigitList& digits,
1816  UBool isInteger) const;
1817 
1818 
1819  void parse(const UnicodeString& text,
1820  Formattable& result,
1821  ParsePosition& pos,
1822  UBool parseCurrency) const;
1823 
1824  enum {
1825  fgStatusInfinite,
1826  fgStatusLength // Leave last in list.
1827  } StatusFlags;
1828 
1829  UBool subparse(const UnicodeString& text,
1830  const UnicodeString* negPrefix,
1831  const UnicodeString* negSuffix,
1832  const UnicodeString* posPrefix,
1833  const UnicodeString* posSuffix,
1834  UBool currencyParsing,
1835  int8_t type,
1836  ParsePosition& parsePosition,
1837  DigitList& digits, UBool* status,
1838  UChar* currency) const;
1839 
1840  // Mixed style parsing for currency.
1841  // It parses against the current currency pattern
1842  // using complex affix comparison
1843  // parses against the currency plural patterns using complex affix comparison,
1844  // and parses against the current pattern using simple affix comparison.
1845  UBool parseForCurrency(const UnicodeString& text,
1846  ParsePosition& parsePosition,
1847  DigitList& digits,
1848  UBool* status,
1849  UChar* currency) const;
1850 
1851  int32_t skipPadding(const UnicodeString& text, int32_t position) const;
1852 
1853  int32_t compareAffix(const UnicodeString& input,
1854  int32_t pos,
1855  UBool isNegative,
1856  UBool isPrefix,
1857  const UnicodeString* affixPat,
1858  UBool currencyParsing,
1859  int8_t type,
1860  UChar* currency) const;
1861 
1862  static int32_t compareSimpleAffix(const UnicodeString& affix,
1863  const UnicodeString& input,
1864  int32_t pos);
1865 
1866  static int32_t skipRuleWhiteSpace(const UnicodeString& text, int32_t pos);
1867 
1868  static int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos);
1869 
1870  int32_t compareComplexAffix(const UnicodeString& affixPat,
1871  const UnicodeString& input,
1872  int32_t pos,
1873  int8_t type,
1874  UChar* currency) const;
1875 
1876  static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch);
1877 
1878  static int32_t match(const UnicodeString& text, int32_t pos, const UnicodeString& str);
1879 
1885  inline const UnicodeString &getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const;
1886 
1887  int32_t appendAffix(UnicodeString& buf, double number,
1888  UBool isNegative, UBool isPrefix) const;
1889 
1895  void appendAffixPattern(UnicodeString& appendTo, const UnicodeString& affix,
1896  UBool localized) const;
1897 
1898  void appendAffixPattern(UnicodeString& appendTo,
1899  const UnicodeString* affixPattern,
1900  const UnicodeString& expAffix, UBool localized) const;
1901 
1902  void expandAffix(const UnicodeString& pattern,
1903  UnicodeString& affix,
1904  double number,
1905  UBool doFormat,
1906  const UnicodeString* pluralCount) const;
1907 
1908  void expandAffixes(const UnicodeString* pluralCount);
1909 
1910  static double round(double a, ERoundingMode mode, UBool isNegative);
1911 
1912  void addPadding(UnicodeString& appendTo,
1913  FieldPosition& fieldPosition,
1914  int32_t prefixLen, int32_t suffixLen) const;
1915 
1916  UBool isGroupingPosition(int32_t pos) const;
1917 
1918  void setCurrencyForSymbols();
1919 
1920  // similar to setCurrency without re-compute the affixes for currency.
1921  // If currency changes, the affix pattern for currency is not changed,
1922  // but the affix will be changed. So, affixes need to be
1923  // re-computed in setCurrency(), but not in setCurrencyInternally().
1924  virtual void setCurrencyInternally(const UChar* theCurrency, UErrorCode& ec);
1925 
1926  // set up currency affix patterns for mix parsing.
1927  // The patterns saved here are the affix patterns of default currency
1928  // pattern and the unique affix patterns of the plural currency patterns.
1929  // Those patterns are used by parseForCurrency().
1930  void setupCurrencyAffixPatterns(UErrorCode& status);
1931 
1932  // set up the currency affixes used in currency plural formatting.
1933  // It sets up both fAffixesForCurrency for currency pattern if the current
1934  // pattern contains 3 currency signs,
1935  // and it sets up fPluralAffixesForCurrency for currency plural patterns.
1936  void setupCurrencyAffixes(const UnicodeString& pattern,
1937  UBool setupForCurrentPattern,
1938  UBool setupForPluralPattern,
1939  UErrorCode& status);
1940 
1941  // hashtable operations
1942  Hashtable* initHashForAffixPattern(UErrorCode& status);
1943  Hashtable* initHashForAffix(UErrorCode& status);
1944 
1945  void deleteHashForAffixPattern();
1946  void deleteHashForAffix(Hashtable*& table);
1947 
1948  void copyHashForAffixPattern(const Hashtable* source,
1949  Hashtable* target, UErrorCode& status);
1950  void copyHashForAffix(const Hashtable* source,
1951  Hashtable* target, UErrorCode& status);
1952 
1953  // currency sign count
1954  enum {
1955  fgCurrencySignCountZero,
1956  fgCurrencySignCountInSymbolFormat,
1957  fgCurrencySignCountInISOFormat,
1958  fgCurrencySignCountInPluralFormat
1959  } CurrencySignCount;
1960 
1964  //static const int8_t fgMaxDigit; // The largest digit, in this case 9
1965 
1966  /*transient*/ //DigitList* fDigitList;
1967 
1968  UnicodeString fPositivePrefix;
1969  UnicodeString fPositiveSuffix;
1970  UnicodeString fNegativePrefix;
1971  UnicodeString fNegativeSuffix;
1972  UnicodeString* fPosPrefixPattern;
1973  UnicodeString* fPosSuffixPattern;
1974  UnicodeString* fNegPrefixPattern;
1975  UnicodeString* fNegSuffixPattern;
1976 
1982  ChoiceFormat* fCurrencyChoice;
1983 
1984  int32_t fMultiplier;
1985  int32_t fGroupingSize;
1986  int32_t fGroupingSize2;
1987  UBool fDecimalSeparatorAlwaysShown;
1988  DecimalFormatSymbols* fSymbols;
1989 
1990  UBool fUseSignificantDigits;
1991  int32_t fMinSignificantDigits;
1992  int32_t fMaxSignificantDigits;
1993 
1994  UBool fUseExponentialNotation;
1995  int8_t fMinExponentDigits;
1996  UBool fExponentSignAlwaysShown;
1997 
1998  /* If fRoundingIncrement is NULL, there is no rounding. Otherwise, round to
1999  * fRoundingIncrement.getDouble(). Since this operation may be expensive,
2000  * we cache the result in fRoundingDouble. All methods that update
2001  * fRoundingIncrement also update fRoundingDouble. */
2002  DigitList* fRoundingIncrement;
2003  /*transient*/ double fRoundingDouble;
2004  ERoundingMode fRoundingMode;
2005 
2006  UChar32 fPad;
2007  int32_t fFormatWidth;
2008  EPadPosition fPadPosition;
2009 
2010  /*
2011  * Following are used for currency format
2012  */
2013  // pattern used in this formatter
2014  UnicodeString fFormatPattern;
2015  // style is only valid when decimal formatter is constructed by
2016  // DecimalFormat(pattern, decimalFormatSymbol, style)
2017  int fStyle;
2018  /*
2019  * Represents whether this is a currency format, and which
2020  * currency format style.
2021  * 0: not currency format type;
2022  * 1: currency style -- symbol name, such as "$" for US dollar.
2023  * 2: currency style -- ISO name, such as USD for US dollar.
2024  * 3: currency style -- plural long name, such as "US Dollar" for
2025  * "1.00 US Dollar", or "US Dollars" for
2026  * "3.00 US Dollars".
2027  */
2028  int fCurrencySignCount;
2029 
2030 
2031  /* For currency parsing purose,
2032  * Need to remember all prefix patterns and suffix patterns of
2033  * every currency format pattern,
2034  * including the pattern of default currecny style
2035  * and plural currency style. And the patterns are set through applyPattern.
2036  */
2037  // TODO: innerclass?
2038  struct AffixPatternsForCurrency : public UMemory {
2039  // negative prefix pattern
2040  UnicodeString negPrefixPatternForCurrency;
2041  // negative suffix pattern
2042  UnicodeString negSuffixPatternForCurrency;
2043  // positive prefix pattern
2044  UnicodeString posPrefixPatternForCurrency;
2045  // positive suffix pattern
2046  UnicodeString posSuffixPatternForCurrency;
2047  int8_t patternType;
2048 
2049  AffixPatternsForCurrency(const UnicodeString& negPrefix,
2050  const UnicodeString& negSuffix,
2051  const UnicodeString& posPrefix,
2052  const UnicodeString& posSuffix,
2053  int8_t type) {
2054  negPrefixPatternForCurrency = negPrefix;
2055  negSuffixPatternForCurrency = negSuffix;
2056  posPrefixPatternForCurrency = posPrefix;
2057  posSuffixPatternForCurrency = posSuffix;
2058  patternType = type;
2059  }
2060  };
2061 
2062  /* affix for currency formatting when the currency sign in the pattern
2063  * equals to 3, such as the pattern contains 3 currency sign or
2064  * the formatter style is currency plural format style.
2065  */
2066  struct AffixesForCurrency : public UMemory {
2067  // negative prefix
2068  UnicodeString negPrefixForCurrency;
2069  // negative suffix
2070  UnicodeString negSuffixForCurrency;
2071  // positive prefix
2072  UnicodeString posPrefixForCurrency;
2073  // positive suffix
2074  UnicodeString posSuffixForCurrency;
2075 
2076  int32_t formatWidth;
2077 
2078  AffixesForCurrency(const UnicodeString& negPrefix,
2079  const UnicodeString& negSuffix,
2080  const UnicodeString& posPrefix,
2081  const UnicodeString& posSuffix) {
2082  negPrefixForCurrency = negPrefix;
2083  negSuffixForCurrency = negSuffix;
2084  posPrefixForCurrency = posPrefix;
2085  posSuffixForCurrency = posSuffix;
2086  }
2087  };
2088 
2089  // Affix pattern set for currency.
2090  // It is a set of AffixPatternsForCurrency,
2091  // each element of the set saves the negative prefix pattern,
2092  // negative suffix pattern, positive prefix pattern,
2093  // and positive suffix pattern of a pattern.
2094  // It is used for currency mixed style parsing.
2095  // It is actually is a set.
2096  // The set contains the default currency pattern from the locale,
2097  // and the currency plural patterns.
2098  // Since it is a set, it does not contain duplicated items.
2099  // For example, if 2 currency plural patterns are the same, only one pattern
2100  // is included in the set. When parsing, we do not check whether the plural
2101  // count match or not.
2102  Hashtable* fAffixPatternsForCurrency;
2103 
2104  // Following 2 are affixes for currency.
2105  // It is a hash map from plural count to AffixesForCurrency.
2106  // AffixesForCurrency saves the negative prefix,
2107  // negative suffix, positive prefix, and positive suffix of a pattern.
2108  // It is used during currency formatting only when the currency sign count
2109  // is 3. In which case, the affixes are getting from here, not
2110  // from the fNegativePrefix etc.
2111  Hashtable* fAffixesForCurrency; // for current pattern
2112  Hashtable* fPluralAffixesForCurrency; // for plural pattern
2113 
2114  // Information needed for DecimalFormat to format/parse currency plural.
2115  CurrencyPluralInfo* fCurrencyPluralInfo;
2116 
2117 protected:
2118 
2127  virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
2128 
2137 
2149 };
2150 
2151 inline UnicodeString&
2153  UnicodeString& appendTo,
2154  UErrorCode& status) const {
2155  // Don't use Format:: - use immediate base class only,
2156  // in case immediate base modifies behavior later.
2157  return NumberFormat::format(obj, appendTo, status);
2158 }
2159 
2160 inline UnicodeString&
2162  UnicodeString& appendTo) const {
2163  FieldPosition pos(0);
2164  return format(number, appendTo, pos);
2165 }
2166 
2167 inline UnicodeString&
2169  UnicodeString& appendTo) const {
2170  FieldPosition pos(0);
2171  return format((int64_t)number, appendTo, pos);
2172 }
2173 
2174 inline const UnicodeString &
2175 DecimalFormat::getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const {
2176  return fSymbols->getConstSymbol(symbol);
2177 }
2178 
2180 
2181 #endif /* #if !UCONFIG_NO_FORMATTING */
2182 
2183 #endif // _DECIMFMT
2184 //eof
Round towards negative infinity.
Definition: decimfmt.h:658
UBool decimfmtAffixValueComparator(UHashTok val1, UHashTok val2)
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
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition: utypes.h:254
static const int32_t kDoubleIntegerDigits
number of integer digits
Definition: decimfmt.h:2132
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:2148
UBool decimfmtAffixPatternValueComparator(UHashTok val1, UHashTok val2)
This class represents the set of symbols needed by DecimalFormat to format numbers.
Definition: dcfmtsym.h:82
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition: umachine.h:101
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:475
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:183
Abstract base class for all number formats.
Definition: numfmt.h:162
virtual void setMinimumFractionDigits(int32_t newValue)
Sets the minimum number of digits allowed in the fraction portion of a number.
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:656
EStyles
Constants for various number format styles.
Definition: numfmt.h:178
virtual void getEffectiveCurrency(UChar *result, UErrorCode &ec) const
Returns the currency in effect for this formatter.
EPadPosition
Pad position.
Definition: decimfmt.h:674
ENumberFormatSymbol
Constants for specifying a number format symbol.
Definition: dcfmtsym.h:88
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:319
virtual Formattable & parseCurrency(const UnicodeString &text, Formattable &result, ParsePosition &pos) const
Parses text from the given string as a currency amount.
UMemory is the common ICU base class.
Definition: uobject.h:98
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:382
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:187
#define U_EXPORT2
Definition: platform.h:338
Round away from zero.
Definition: decimfmt.h:660
ChoiceFormat converts between ranges of numeric values and string names for those ranges...
Definition: choicfmt.h:259
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:299
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition: umachine.h:102
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API If the compiler doesn't support namespaces...
Definition: uversion.h:184
signed char int8_t
Define 64 bit limits.
Definition: pwin32.h:127
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:47
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
Definition: utypes.h:339
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:593
virtual UClassID getDynamicClassID(void) const =0
Returns a unique class ID POLYMORPHICALLY.
static const int32_t kDoubleFractionDigits
number of fraction digits
Definition: decimfmt.h:2136
C++ API: Symbols for formatting numbers.
C++ API: Locale ID object.
signed long long int64_t
Define 64 bit limits.
Definition: pwin32.h:152
DecimalFormat is a concrete subclass of NumberFormat that formats decimal numbers.
Definition: decimfmt.h:650
Round towards zero.
Definition: decimfmt.h:659
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:56
Base class for all formats.
Definition: format.h:93
Basic definitions for ICU, for both C and C++ APIs.
Round towards positive infinity.
Definition: decimfmt.h:657
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.
signed int int32_t
Define 64 bit limits.
Definition: pwin32.h:143
int8_t UBool
The ICU boolean type.
Definition: umachine.h:208
virtual void setCurrency(const UChar *theCurrency, UErrorCode &ec)
Sets the currency used to display currency amounts.