ICU 57.1 57.1
decimfmt.h
Go to the documentation of this file.
1/*
2********************************************************************************
3* Copyright (C) 1997-2016, 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
44#ifndef U_HIDE_INTERNAL_API
49#if UCONFIG_FORMAT_FASTPATHS_49
50#define UNUM_DECIMALFORMAT_INTERNAL_SIZE 16
51#endif
52#endif /* U_HIDE_INTERNAL_API */
53
55
56class DigitList;
58class Hashtable;
59class UnicodeSet;
62class FixedDecimal;
63class DecimalFormatImpl;
64class PluralRules;
66
67// explicit template instantiation. see digitlst.h
68#if defined (_MSC_VER)
72#endif
73
668public:
678 kRoundHalfEven,
680 kRoundHalfDown,
682 kRoundHalfUp,
688 kRoundUnnecessary
689 };
690
696 kPadBeforePrefix,
697 kPadAfterPrefix,
698 kPadBeforeSuffix,
699 kPadAfterSuffix
700 };
701
716
733
755
756#ifndef U_HIDE_INTERNAL_API
773
774#if UCONFIG_HAVE_PARSEALLINPUT
779#endif
780
781#endif /* U_HIDE_INTERNAL_API */
782
783
795 int32_t newvalue,
797
808 UErrorCode &status) const;
809
810
818
826 virtual void setParseIntegerOnly(UBool value);
827
838
882
890
898
903 virtual ~DecimalFormat();
904
912 virtual Format* clone(void) const;
913
922 virtual UBool operator==(const Format& other) const;
923
924
926
938 virtual UnicodeString& format(double number,
940 FieldPosition& pos) const;
941
942
955 virtual UnicodeString& format(double number,
957 FieldPosition& pos,
958 UErrorCode &status) const;
959
973 virtual UnicodeString& format(double number,
976 UErrorCode& status) const;
977
989 virtual UnicodeString& format(int32_t number,
991 FieldPosition& pos) const;
992
1004 virtual UnicodeString& format(int32_t number,
1006 FieldPosition& pos,
1007 UErrorCode &status) const;
1008
1022 virtual UnicodeString& format(int32_t number,
1025 UErrorCode& status) const;
1026
1038 virtual UnicodeString& format(int64_t number,
1040 FieldPosition& pos) const;
1041
1053 virtual UnicodeString& format(int64_t number,
1055 FieldPosition& pos,
1056 UErrorCode &status) const;
1057
1071 virtual UnicodeString& format(int64_t number,
1074 UErrorCode& status) const;
1075
1092 virtual UnicodeString& format(const StringPiece &number,
1095 UErrorCode& status) const;
1096
1097
1113 virtual UnicodeString& format(const DigitList &number,
1116 UErrorCode& status) const;
1117
1130 const VisibleDigitsWithExponent &number,
1132 FieldPosition& pos,
1133 UErrorCode& status) const;
1134
1147 const VisibleDigitsWithExponent &number,
1150 UErrorCode& status) const;
1151
1167 virtual UnicodeString& format(const DigitList &number,
1169 FieldPosition& pos,
1170 UErrorCode& status) const;
1171
1172 using NumberFormat::parse;
1173
1193 virtual void parse(const UnicodeString& text,
1196
1217 ParsePosition& pos) const;
1218
1227
1235
1243
1244
1251 virtual const CurrencyPluralInfo* getCurrencyPluralInfo(void) const;
1252
1260
1268
1269
1279
1288
1298
1307
1317
1326
1336
1345
1356 int32_t getMultiplier(void) const;
1357
1368 virtual void setMultiplier(int32_t newValue);
1369
1379 virtual double getRoundingIncrement(void) const;
1380
1392 virtual void setRoundingIncrement(double newValue);
1393
1402 virtual ERoundingMode getRoundingMode(void) const;
1403
1413
1425 virtual int32_t getFormatWidth(void) const;
1426
1441 virtual void setFormatWidth(int32_t width);
1442
1456
1472
1488 virtual EPadPosition getPadPosition(void) const;
1489
1507
1518 virtual UBool isScientificNotation(void) const;
1519
1536
1547 virtual int8_t getMinimumExponentDigits(void) const;
1548
1562
1576
1591
1603 int32_t getGroupingSize(void) const;
1604
1616 virtual void setGroupingSize(int32_t newValue);
1617
1636 int32_t getSecondaryGroupingSize(void) const;
1637
1649 virtual void setSecondaryGroupingSize(int32_t newValue);
1650
1651#ifndef U_HIDE_INTERNAL_API
1652
1675
1676#endif /* U_HIDE_INTERNAL_API */
1677
1678 /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following draft method since it is virtual. */
1687 virtual void setMinimumGroupingDigits(int32_t newValue);
1688
1689
1699
1709
1717
1728
1729
1741
1753
1783 virtual void applyPattern(const UnicodeString& pattern,
1794 virtual void applyPattern(const UnicodeString& pattern,
1796
1827 virtual void applyLocalizedPattern(const UnicodeString& pattern,
1830
1840 virtual void applyLocalizedPattern(const UnicodeString& pattern,
1842
1843
1853 virtual void setMaximumIntegerDigits(int32_t newValue);
1854
1864 virtual void setMinimumIntegerDigits(int32_t newValue);
1865
1875 virtual void setMaximumFractionDigits(int32_t newValue);
1876
1886 virtual void setMinimumFractionDigits(int32_t newValue);
1887
1896
1905
1918
1931
1939
1948
1949 public:
1963
1969 virtual void setCurrency(const UChar* theCurrency);
1970
1979
1985
1986
1987#ifndef U_HIDE_DEPRECATED_API
1993 static const char fgNumberPatterns[];
1994#endif /* U_HIDE_DEPRECATED_API */
1995
1996#ifndef U_HIDE_INTERNAL_API
2004
2012
2020
2028 double number,
2030 UErrorCode &status) const;
2031
2039 const Formattable &number,
2041 UErrorCode &status) const;
2042
2051 DigitList &number,
2053 UErrorCode &status) const;
2054
2055#endif /* U_HIDE_INTERNAL_API */
2056
2057public:
2058
2071
2083 virtual UClassID getDynamicClassID(void) const;
2084
2085private:
2086
2087 DecimalFormat(); // default constructor not implemented
2088
2093 void init();
2094
2098 void construct(UErrorCode& status,
2100 const UnicodeString* pattern = 0,
2102 );
2103
2104 void parse(const UnicodeString& text,
2106 ParsePosition& pos,
2107 UChar* currency) const;
2108
2109 enum {
2110 fgStatusInfinite,
2111 fgStatusLength // Leave last in list.
2112 } StatusFlags;
2113
2114 UBool subparse(const UnicodeString& text,
2115 const UnicodeString* negPrefix,
2116 const UnicodeString* negSuffix,
2117 const UnicodeString* posPrefix,
2118 const UnicodeString* posSuffix,
2120 int8_t type,
2123 UChar* currency) const;
2124
2125 // Mixed style parsing for currency.
2126 // It parses against the current currency pattern
2127 // using complex affix comparison
2128 // parses against the currency plural patterns using complex affix comparison,
2129 // and parses against the current pattern using simple affix comparison.
2130 UBool parseForCurrency(const UnicodeString& text,
2133 UBool* status,
2134 UChar* currency) const;
2135
2136 int32_t skipPadding(const UnicodeString& text, int32_t position) const;
2137
2138 int32_t compareAffix(const UnicodeString& input,
2139 int32_t pos,
2142 const UnicodeString* affixPat,
2144 int8_t type,
2145 UChar* currency) const;
2146
2147 static UnicodeString& trimMarksFromAffix(const UnicodeString& affix, UnicodeString& trimmedAffix);
2148
2149 UBool equalWithSignCompatibility(UChar32 lhs, UChar32 rhs) const;
2150
2151 int32_t compareSimpleAffix(const UnicodeString& affix,
2152 const UnicodeString& input,
2153 int32_t pos,
2154 UBool lenient) const;
2155
2156 static int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos);
2157
2158 static int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos);
2159
2160 static int32_t skipUWhiteSpaceAndMarks(const UnicodeString& text, int32_t pos);
2161
2162 static int32_t skipBidiMarks(const UnicodeString& text, int32_t pos);
2163
2164 int32_t compareComplexAffix(const UnicodeString& affixPat,
2165 const UnicodeString& input,
2166 int32_t pos,
2167 int8_t type,
2168 UChar* currency) const;
2169
2170 static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch);
2171
2172 static int32_t match(const UnicodeString& text, int32_t pos, const UnicodeString& str);
2173
2174 static UBool matchSymbol(const UnicodeString &text, int32_t position, int32_t length, const UnicodeString &symbol,
2176
2177 static UBool matchDecimal(UChar32 symbolChar,
2179 const UnicodeSet *sset, UChar32 schar);
2180
2181 static UBool matchGrouping(UChar32 groupingChar,
2183 const UnicodeSet *sset,
2185 UChar32 schar);
2186
2187 // set up currency affix patterns for mix parsing.
2188 // The patterns saved here are the affix patterns of default currency
2189 // pattern and the unique affix patterns of the plural currency patterns.
2190 // Those patterns are used by parseForCurrency().
2191 void setupCurrencyAffixPatterns(UErrorCode& status);
2192
2193 // get the currency rounding with respect to currency usage
2194 double getCurrencyRounding(const UChar* currency,
2195 UErrorCode* ec) const;
2196
2197 // get the currency fraction with respect to currency usage
2198 int getCurrencyFractionDigits(const UChar* currency,
2199 UErrorCode* ec) const;
2200
2201 // hashtable operations
2202 Hashtable* initHashForAffixPattern(UErrorCode& status);
2203
2204 void deleteHashForAffixPattern();
2205
2206 void copyHashForAffixPattern(const Hashtable* source,
2207 Hashtable* target, UErrorCode& status);
2208
2209 DecimalFormatImpl *fImpl;
2210
2219 fBoolFlags;
2220
2221
2222 // style is only valid when decimal formatter is constructed by
2223 // DecimalFormat(pattern, decimalFormatSymbol, style)
2224 int fStyle;
2225
2226
2227 // Affix pattern set for currency.
2228 // It is a set of AffixPatternsForCurrency,
2229 // each element of the set saves the negative prefix pattern,
2230 // negative suffix pattern, positive prefix pattern,
2231 // and positive suffix pattern of a pattern.
2232 // It is used for currency mixed style parsing.
2233 // It is actually is a set.
2234 // The set contains the default currency pattern from the locale,
2235 // and the currency plural patterns.
2236 // Since it is a set, it does not contain duplicated items.
2237 // For example, if 2 currency plural patterns are the same, only one pattern
2238 // is included in the set. When parsing, we do not check whether the plural
2239 // count match or not.
2240 Hashtable* fAffixPatternsForCurrency;
2241
2242 // Information needed for DecimalFormat to format/parse currency plural.
2243 CurrencyPluralInfo* fCurrencyPluralInfo;
2244
2245#if UCONFIG_HAVE_PARSEALLINPUT
2247#endif
2248
2249 // Decimal Format Static Sets singleton.
2250 const DecimalFormatStaticSets *fStaticSets;
2251
2252protected:
2253
2254#ifndef U_HIDE_INTERNAL_API
2260#endif /* U_HIDE_INTERNAL_API */
2261
2271
2275 static const int32_t kDoubleIntegerDigits;
2279 static const int32_t kDoubleFractionDigits;
2280
2291 static const int32_t kMaxScientificIntegerDigits;
2292
2293};
2294
2296
2297#endif /* #if !UCONFIG_NO_FORMATTING */
2298
2299#endif // _DECIMFMT
2300//eof
A currency together with a numeric amount, such as 200 USD.
Definition curramt.h:35
This class represents the information needed by DecimalFormat to format currency plural,...
Definition currpinf.h:44
This class represents the set of symbols needed by DecimalFormat to format numbers.
Definition dcfmtsym.h:84
DecimalFormat is a concrete subclass of NumberFormat that formats decimal numbers.
Definition decimfmt.h:667
ERoundingMode
Rounding mode.
Definition decimfmt.h:673
@ kRoundDown
Round towards zero.
Definition decimfmt.h:676
@ kRoundUp
Round away from zero.
Definition decimfmt.h:677
@ kRoundFloor
Round towards negative infinity.
Definition decimfmt.h:675
@ kRoundCeiling
Round towards positive infinity.
Definition decimfmt.h:674
virtual CurrencyAmount * parseCurrency(const UnicodeString &text, ParsePosition &pos) const
Parses text from the given string as a currency amount.
virtual void setMinimumGroupingDigits(int32_t newValue)
Sets the minimum grouping digits.
virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols *symbolsToAdopt)
Sets the decimal format symbols, which is generally not changed by the programmer or user.
virtual void setFormatWidth(int32_t width)
Set the width to which the output of format() is padded.
virtual void adoptCurrencyPluralInfo(CurrencyPluralInfo *toAdopt)
Sets the currency plural format information, which is generally not changed by the programmer or user...
virtual ~DecimalFormat()
Destructor.
virtual void setDecimalSeparatorAlwaysShown(UBool newValue)
Allows you to set the behavior of the decimal separator with integers.
virtual void applyPattern(const UnicodeString &pattern, UErrorCode &status)
Sets the pattern.
virtual void getEffectiveCurrency(UChar *result, UErrorCode &ec) const
Returns the currency in effect for this formatter.
UBool areSignificantDigitsUsed() const
Returns true if significant digits are in use, or false if integer and fraction digit counts are in u...
UBool isDecimalPatternMatchRequired(void) const
Allows you to get the parse behavior of the pattern decimal mark.
virtual void setPadCharacter(const UnicodeString &padChar)
Set the character used to pad to the format width.
int32_t getMultiplier(void) const
Get the multiplier for use in percent, permill, etc.
virtual void setScientificNotation(UBool useScientific)
Set whether or not scientific notation is used.
virtual void setCurrency(const UChar *theCurrency)
Sets the currency used to display currency amounts.
virtual UnicodeString & format(double number, UnicodeString &appendTo, FieldPosition &pos) const
Format a double or long number using base-10 representation.
static UClassID getStaticClassID(void)
Return the class ID for this class.
virtual void setMaximumFractionDigits(int32_t newValue)
Sets the maximum number of digits allowed in the fraction portion of a number.
virtual void applyLocalizedPattern(const UnicodeString &pattern, UParseError &parseError, UErrorCode &status)
Apply the given pattern to this Format object.
virtual void setCurrencyPluralInfo(const CurrencyPluralInfo &info)
Sets the currency plural format information, which is generally not changed by the programmer or user...
virtual void setPadPosition(EPadPosition padPos)
Set the position at which padding will take place.
virtual UnicodeString & format(const VisibleDigitsWithExponent &number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Format a decimal number.
virtual void setSecondaryGroupingSize(int32_t newValue)
Set the secondary grouping size.
virtual UnicodeString & format(int32_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Format a long number using base-10 representation.
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
virtual void setExponentSignAlwaysShown(UBool expSignAlways)
Set whether the exponent sign is always shown.
virtual void setRoundingMode(ERoundingMode roundingMode)
Set the rounding mode.
virtual void setCurrency(const UChar *theCurrency, UErrorCode &ec)
Sets the currency used to display currency amounts.
virtual UnicodeString & format(int64_t number, UnicodeString &appendTo, FieldPosition &pos) const
Format an int64 number using base-10 representation.
virtual void setParseIntegerOnly(UBool value)
Sets whether or not numbers should be parsed as integers only.
virtual UnicodeString & format(int32_t number, UnicodeString &appendTo, FieldPosition &pos) const
Format a long number using base-10 representation.
DecimalFormat(const UnicodeString &pattern, const DecimalFormatSymbols &symbols, UErrorCode &status)
Create a DecimalFormat from the given pattern and symbols.
virtual int32_t getFormatWidth(void) const
Get the width to which the output of format() is padded.
virtual int32_t getAttribute(UNumberFormatAttribute attr, UErrorCode &status) const
Get an integer May return U_UNSUPPORTED_ERROR if this instance does not support the specified attribu...
VisibleDigitsWithExponent & initVisibleDigitsWithExponent(DigitList &number, VisibleDigitsWithExponent &digits, UErrorCode &status) const
Get a VisibleDigitsWithExponent corresponding to a DigitList as it would be formatted by this Decimal...
virtual UBool operator==(const Format &other) const
Return true if the given Format objects are semantically equal.
int32_t getMinimumSignificantDigits() const
Returns the minimum number of significant digits that will be displayed.
virtual Format * clone(void) const
Clone this Format object polymorphically.
FixedDecimal getFixedDecimal(DigitList &number, UErrorCode &status) const
Get a FixedDecimal corresponding to a DigitList as it would be formatted by this DecimalFormat.
virtual UnicodeString & format(int32_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
Format a long number using base-10 representation.
virtual UnicodeString & toPattern(UnicodeString &result) const
Synthesizes a pattern string that represents the current state of this Format object.
DigitList & _round(const DigitList &number, DigitList &adjustedNum, UBool &isNegative, UErrorCode &status) const
Rounds a value according to the rules of this object.
virtual void setRoundingIncrement(double newValue)
Set the rounding increment.
virtual void setDecimalPatternMatchRequired(UBool newValue)
Allows you to set the behavior of the pattern decimal mark.
DecimalFormat(UErrorCode &status)
Create a DecimalFormat using the default pattern and symbols for the default locale.
UnicodeString & getNegativeSuffix(UnicodeString &result) const
Get the negative suffix.
static const int32_t kDoubleIntegerDigits
number of integer digits
Definition decimfmt.h:2275
virtual UnicodeString & format(const VisibleDigitsWithExponent &number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
Format a decimal number.
UnicodeString & getPositiveSuffix(UnicodeString &result) const
Get the positive suffix.
virtual void setNegativePrefix(const UnicodeString &newValue)
Set the negative prefix.
virtual void setPositivePrefix(const UnicodeString &newValue)
Set the positive prefix.
virtual UBool isExponentSignAlwaysShown(void) const
Return whether the exponent sign is always shown.
virtual void setDecimalFormatSymbols(const DecimalFormatSymbols &symbols)
Sets the decimal format symbols, which is generally not changed by the programmer or user.
void setMaximumSignificantDigits(int32_t max)
Sets the maximum number of significant digits that will be displayed.
virtual void setContext(UDisplayContext value, UErrorCode &status)
Set a particular UDisplayContext value in the formatter, such as UDISPCTX_CAPITALIZATION_FOR_STANDALO...
virtual const CurrencyPluralInfo * getCurrencyPluralInfo(void) const
Returns the currency plural format information, which is generally not changed by the programmer or u...
virtual void setGroupingUsed(UBool newValue)
Set whether or not grouping will be used in this format.
UnicodeString & getPositivePrefix(UnicodeString &result) const
Get the positive prefix.
int32_t getMinimumGroupingDigits() const
Returns the minimum number of grouping digits.
virtual void parse(const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const
Parse the given string using this object's choices.
virtual ERoundingMode getRoundingMode(void) const
Get the rounding mode.
virtual UnicodeString & toLocalizedPattern(UnicodeString &result) const
Synthesizes a localized pattern string that represents the current state of this Format object.
DecimalFormat & operator=(const DecimalFormat &rhs)
Assignment operator.
virtual UnicodeString & format(double number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Format a double or long number using base-10 representation.
virtual void setMinimumExponentDigits(int8_t minExpDig)
Set the minimum exponent digits that will be shown.
DecimalFormat(const UnicodeString &pattern, UErrorCode &status)
Create a DecimalFormat from the given pattern and the symbols for the default locale.
UBool isDecimalSeparatorAlwaysShown(void) const
Allows you to get the behavior of the decimal separator with integers.
virtual UnicodeString & format(int64_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Format an int64 number using base-10 representation.
virtual int8_t getMinimumExponentDigits(void) const
Return the minimum exponent digits that will be shown.
virtual void setMaximumIntegerDigits(int32_t newValue)
Sets the maximum number of digits allowed in the integer portion of a number.
virtual DecimalFormat & setAttribute(UNumberFormatAttribute attr, int32_t newvalue, UErrorCode &status)
Set an integer attribute on this DecimalFormat.
virtual const DecimalFormatSymbols * getDecimalFormatSymbols(void) const
Returns the decimal format symbols, which is generally not changed by the programmer or user.
static const int32_t kDoubleFractionDigits
number of fraction digits
Definition decimfmt.h:2279
DecimalFormat(const DecimalFormat &source)
Copy constructor.
virtual UnicodeString & format(double number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
Format a double or long number using base-10 representation.
FixedDecimal getFixedDecimal(const Formattable &number, UErrorCode &status) const
Get a FixedDecimal corresponding to a formattable as it would be formatted by this DecimalFormat.
virtual UnicodeString getPadCharacterString() const
Get the pad character used to pad to the format width.
virtual void setMinimumFractionDigits(int32_t newValue)
Sets the minimum number of digits allowed in the fraction portion of a number.
virtual void setPositiveSuffix(const UnicodeString &newValue)
Set the positive suffix.
virtual void setMinimumIntegerDigits(int32_t newValue)
Sets the minimum number of digits allowed in the integer portion of a number.
virtual double getRoundingIncrement(void) const
Get the rounding increment.
virtual EPadPosition getPadPosition(void) const
Get the position at which padding will take place.
virtual void applyLocalizedPattern(const UnicodeString &pattern, UErrorCode &status)
Apply the given pattern to this Format object.
virtual UBool isScientificNotation(void) const
Return whether or not scientific notation is used.
EPadPosition
Pad position.
Definition decimfmt.h:695
virtual UnicodeString & format(const DigitList &number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
Format a decimal number.
virtual UnicodeString & format(const StringPiece &number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
Format a decimal number.
int32_t getGroupingSize(void) const
Return the grouping size.
UnicodeString & getNegativePrefix(UnicodeString &result) const
Get the negative prefix.
FixedDecimal getFixedDecimal(double number, UErrorCode &status) const
Get a FixedDecimal corresponding to a double as it would be formatted by this DecimalFormat.
void setSignificantDigitsUsed(UBool useSignificantDigits)
Sets whether significant digits are in use, or integer and fraction digit counts are in use.
virtual void setMultiplier(int32_t newValue)
Set the multiplier for use in percent, permill, etc.
DecimalFormat(const UnicodeString &pattern, DecimalFormatSymbols *symbolsToAdopt, UErrorCode &status)
Create a DecimalFormat from the given pattern and symbols.
VisibleDigitsWithExponent & initVisibleDigitsWithExponent(const Formattable &number, VisibleDigitsWithExponent &digits, UErrorCode &status) const
Get a VisibleDigitsWithExponent corresponding to a formattable as it would be formatted by this Decim...
virtual void setNegativeSuffix(const UnicodeString &newValue)
Set the negative suffix.
DecimalFormat(const UnicodeString &pattern, DecimalFormatSymbols *symbolsToAdopt, UNumberFormatStyle style, UErrorCode &status)
This API is for ICU use only.
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:2291
virtual void setGroupingSize(int32_t newValue)
Set the grouping size.
virtual UnicodeString & format(int64_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
Format an int64 number using base-10 representation.
int32_t getSecondaryGroupingSize(void) const
Return the secondary grouping size.
virtual void applyPattern(const UnicodeString &pattern, UParseError &parseError, UErrorCode &status)
Apply the given pattern to this Format object.
virtual UnicodeString & format(const DigitList &number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Format a decimal number.
void setCurrencyUsage(UCurrencyUsage newUsage, UErrorCode *ec)
Sets the Currency Context object used to display currency.
DecimalFormat(const UnicodeString &pattern, DecimalFormatSymbols *symbolsToAdopt, UParseError &parseError, UErrorCode &status)
Create a DecimalFormat from the given pattern and symbols.
int32_t getMaximumSignificantDigits() const
Returns the maximum number of significant digits that will be displayed.
VisibleDigitsWithExponent & initVisibleDigitsWithExponent(double number, VisibleDigitsWithExponent &digits, UErrorCode &status) const
Get a VisibleDigitsWithExponent corresponding to a double as it would be formatted by this DecimalFor...
void setMinimumSignificantDigits(int32_t min)
Sets the minimum number of significant digits that will be displayed.
UCurrencyUsage getCurrencyUsage() const
Returns the Currency Context object used to display currency.
enum bitset for boolean fields.
Definition enumset.h:31
FieldPositionIterator returns the field ids and their start/limit positions generated by a call to Fo...
Definition fpositer.h:53
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition fieldpos.h:106
Base class for all formats.
Definition format.h:94
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition fmtable.h:66
"Smart pointer" base class; do not use directly: use LocalPointer etc.
Abstract base class for all number formats.
Definition numfmt.h:167
virtual void parse(const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const =0
Return a long if possible (e.g.
virtual UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Format an object to produce a string.
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition parsepos.h:47
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition plurrule.h:192
A string-like object that points to a sized piece of memory.
Definition stringpiece.h:52
A mutable set of Unicode characters and multicharacter strings.
Definition uniset.h:276
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:294
C++ API: Currency Amount Object.
C++ API: Symbols for formatting numbers.
C++: internal template EnumSet<>
C++ API: FieldPosition Iterator.
C++ API: Locale ID object.
C++ API: Abstract base class for all number formats.
C++ API: StringPiece: Read-only byte string wrapper class.
A UParseError struct is used to returned detailed information about parsing errors.
Definition parseerr.h:56
UCurrencyUsage
Currency Usage used for Decimal Format.
Definition ucurr.h:39
UDisplayContext
Display context settings.
int8_t UBool
The ICU boolean type.
Definition umachine.h:234
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition umachine.h:312
UNumberFormatAttribute
The possible UNumberFormat numeric attributes.
Definition unum.h:882
@ UNUM_LIMIT_BOOLEAN_ATTRIBUTE
Limit of boolean attributes.
Definition unum.h:997
@ UNUM_MAX_NONBOOLEAN_ATTRIBUTE
One below the first bitfield-boolean item.
Definition unum.h:968
UNumberFormatStyle
The possible number format styles.
Definition unum.h:139
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:476
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:358
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129