ICU 72.1 72.1
Public Member Functions | Static Public Member Functions
icu::CompactDecimalFormat Class Reference

IMPORTANT: New users are strongly encouraged to see if numberformatter.h fits their use case. More...

#include <compactdecimalformat.h>

Inheritance diagram for icu::CompactDecimalFormat:
icu::DecimalFormat icu::NumberFormat icu::Format icu::UObject icu::UMemory

Public Member Functions

 CompactDecimalFormat (const CompactDecimalFormat &source)
 Copy constructor. More...
 
 ~CompactDecimalFormat () U_OVERRIDE
 Destructor. More...
 
CompactDecimalFormatoperator= (const CompactDecimalFormat &rhs)
 Assignment operator. More...
 
CompactDecimalFormatclone () const U_OVERRIDE
 Clone this Format object polymorphically. More...
 
void parse (const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const U_OVERRIDE
 CompactDecimalFormat does not support parsing. More...
 
void parse (const UnicodeString &text, Formattable &result, UErrorCode &status) const U_OVERRIDE
 CompactDecimalFormat does not support parsing. More...
 
CurrencyAmountparseCurrency (const UnicodeString &text, ParsePosition &pos) const U_OVERRIDE
 Parses text from the given string as a currency amount. More...
 
UClassID getDynamicClassID () const U_OVERRIDE
 Returns a unique class ID POLYMORPHICALLY. More...
 
UnicodeStringformat (double number, UnicodeString &appendTo, FieldPosition &pos) const U_OVERRIDE
 Format a double or long number using base-10 representation. More...
 
UnicodeStringformat (double number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const U_OVERRIDE
 Format a double or long number using base-10 representation. More...
 
UnicodeStringformat (double number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const U_OVERRIDE
 Format a double or long number using base-10 representation. More...
 
UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPosition &pos) const U_OVERRIDE
 Format a long number using base-10 representation. More...
 
UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const U_OVERRIDE
 Format a long number using base-10 representation. More...
 
UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const U_OVERRIDE
 Format a long number using base-10 representation. More...
 
UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPosition &pos) const U_OVERRIDE
 Format an int64 number using base-10 representation. More...
 
UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const U_OVERRIDE
 Format an int64 number using base-10 representation. More...
 
UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const U_OVERRIDE
 Format an int64 number using base-10 representation. More...
 
UnicodeStringformat (StringPiece number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const U_OVERRIDE
 Format a decimal number. More...
 
UnicodeStringformat (const number::impl::DecimalQuantity &number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const U_OVERRIDE
 Format a decimal number. More...
 
UnicodeStringformat (const number::impl::DecimalQuantity &number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const U_OVERRIDE
 Format a decimal number. More...
 
- Public Member Functions inherited from icu::DecimalFormat
 DecimalFormat (UErrorCode &status)
 Create a DecimalFormat using the default pattern and symbols for the default locale. More...
 
 DecimalFormat (const UnicodeString &pattern, UErrorCode &status)
 Create a DecimalFormat from the given pattern and the symbols for the default locale. More...
 
 DecimalFormat (const UnicodeString &pattern, DecimalFormatSymbols *symbolsToAdopt, UErrorCode &status)
 Create a DecimalFormat from the given pattern and symbols. More...
 
 DecimalFormat (const UnicodeString &pattern, DecimalFormatSymbols *symbolsToAdopt, UNumberFormatStyle style, UErrorCode &status)
 This API is for ICU use only. More...
 
virtual DecimalFormatsetAttribute (UNumberFormatAttribute attr, int32_t newValue, UErrorCode &status)
 Set an integer attribute on this DecimalFormat. More...
 
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 attribute. More...
 
void setGroupingUsed (UBool newValue) U_OVERRIDE
 Set whether or not grouping will be used in this format. More...
 
void setParseIntegerOnly (UBool value) U_OVERRIDE
 Sets whether or not numbers should be parsed as integers only. More...
 
void setLenient (UBool enable) U_OVERRIDE
 Sets whether lenient parsing should be enabled (it is off by default). More...
 
 DecimalFormat (const UnicodeString &pattern, DecimalFormatSymbols *symbolsToAdopt, UParseError &parseError, UErrorCode &status)
 Create a DecimalFormat from the given pattern and symbols. More...
 
 DecimalFormat (const UnicodeString &pattern, const DecimalFormatSymbols &symbols, UErrorCode &status)
 Create a DecimalFormat from the given pattern and symbols. More...
 
 DecimalFormat (const DecimalFormat &source)
 Copy constructor. More...
 
DecimalFormatoperator= (const DecimalFormat &rhs)
 Assignment operator. More...
 
 ~DecimalFormat () U_OVERRIDE
 Destructor. More...
 
DecimalFormatclone () const U_OVERRIDE
 Clone this Format object polymorphically. More...
 
bool operator== (const Format &other) const U_OVERRIDE
 Return true if the given Format objects are semantically equal. More...
 
UnicodeStringformat (double number, UnicodeString &appendTo, FieldPosition &pos) const U_OVERRIDE
 Format a double or long number using base-10 representation. More...
 
UnicodeStringformat (double number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const U_OVERRIDE
 Format a double or long number using base-10 representation. More...
 
UnicodeStringformat (double number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const U_OVERRIDE
 Format a double or long number using base-10 representation. More...
 
UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPosition &pos) const U_OVERRIDE
 Format a long number using base-10 representation. More...
 
UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const U_OVERRIDE
 Format a long number using base-10 representation. More...
 
UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const U_OVERRIDE
 Format a long number using base-10 representation. More...
 
UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPosition &pos) const U_OVERRIDE
 Format an int64 number using base-10 representation. More...
 
UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const U_OVERRIDE
 Format an int64 number using base-10 representation. More...
 
UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const U_OVERRIDE
 Format an int64 number using base-10 representation. More...
 
UnicodeStringformat (StringPiece number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const U_OVERRIDE
 Format a decimal number. More...
 
UnicodeStringformat (const number::impl::DecimalQuantity &number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const U_OVERRIDE
 Format a decimal number. More...
 
UnicodeStringformat (const number::impl::DecimalQuantity &number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const U_OVERRIDE
 Format a decimal number. More...
 
void parse (const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const U_OVERRIDE
 Parse the given string using this object's choices. More...
 
CurrencyAmountparseCurrency (const UnicodeString &text, ParsePosition &pos) const U_OVERRIDE
 Parses text from the given string as a currency amount. More...
 
virtual const DecimalFormatSymbolsgetDecimalFormatSymbols (void) const
 Returns the decimal format symbols, which is generally not changed by the programmer or user. More...
 
virtual void adoptDecimalFormatSymbols (DecimalFormatSymbols *symbolsToAdopt)
 Sets the decimal format symbols, which is generally not changed by the programmer or user. More...
 
virtual void setDecimalFormatSymbols (const DecimalFormatSymbols &symbols)
 Sets the decimal format symbols, which is generally not changed by the programmer or user. More...
 
virtual const CurrencyPluralInfogetCurrencyPluralInfo (void) const
 Returns the currency plural format information, which is generally not changed by the programmer or user. More...
 
virtual void adoptCurrencyPluralInfo (CurrencyPluralInfo *toAdopt)
 Sets the currency plural format information, which is generally not changed by the programmer or user. More...
 
virtual void setCurrencyPluralInfo (const CurrencyPluralInfo &info)
 Sets the currency plural format information, which is generally not changed by the programmer or user. More...
 
UnicodeStringgetPositivePrefix (UnicodeString &result) const
 Get the positive prefix. More...
 
virtual void setPositivePrefix (const UnicodeString &newValue)
 Set the positive prefix. More...
 
UnicodeStringgetNegativePrefix (UnicodeString &result) const
 Get the negative prefix. More...
 
virtual void setNegativePrefix (const UnicodeString &newValue)
 Set the negative prefix. More...
 
UnicodeStringgetPositiveSuffix (UnicodeString &result) const
 Get the positive suffix. More...
 
virtual void setPositiveSuffix (const UnicodeString &newValue)
 Set the positive suffix. More...
 
UnicodeStringgetNegativeSuffix (UnicodeString &result) const
 Get the negative suffix. More...
 
virtual void setNegativeSuffix (const UnicodeString &newValue)
 Set the negative suffix. More...
 
UBool isSignAlwaysShown () const
 Whether to show the plus sign on positive (non-negative) numbers; for example, "+12". More...
 
void setSignAlwaysShown (UBool value)
 Set whether to show the plus sign on positive (non-negative) numbers; for example, "+12". More...
 
int32_t getMultiplier (void) const
 Get the multiplier for use in percent, permill, etc. More...
 
virtual void setMultiplier (int32_t newValue)
 Set the multiplier for use in percent, permill, etc. More...
 
int32_t getMultiplierScale (void) const
 Gets the power of ten by which number should be multiplied before formatting, which can be combined with setMultiplier() to multiply by any arbitrary decimal value. More...
 
void setMultiplierScale (int32_t newValue)
 Sets a power of ten by which number should be multiplied before formatting, which can be combined with setMultiplier() to multiply by any arbitrary decimal value. More...
 
virtual double getRoundingIncrement (void) const
 Get the rounding increment. More...
 
virtual void setRoundingIncrement (double newValue)
 Set the rounding increment. More...
 
virtual ERoundingMode getRoundingMode (void) const U_OVERRIDE
 Get the rounding mode. More...
 
virtual void setRoundingMode (ERoundingMode roundingMode) U_OVERRIDE
 Set the rounding mode. More...
 
virtual int32_t getFormatWidth (void) const
 Get the width to which the output of format() is padded. More...
 
virtual void setFormatWidth (int32_t width)
 Set the width to which the output of format() is padded. More...
 
virtual UnicodeString getPadCharacterString () const
 Get the pad character used to pad to the format width. More...
 
virtual void setPadCharacter (const UnicodeString &padChar)
 Set the character used to pad to the format width. More...
 
virtual EPadPosition getPadPosition (void) const
 Get the position at which padding will take place. More...
 
virtual void setPadPosition (EPadPosition padPos)
 Set the position at which padding will take place. More...
 
virtual UBool isScientificNotation (void) const
 Return whether or not scientific notation is used. More...
 
virtual void setScientificNotation (UBool useScientific)
 Set whether or not scientific notation is used. More...
 
virtual int8_t getMinimumExponentDigits (void) const
 Return the minimum exponent digits that will be shown. More...
 
virtual void setMinimumExponentDigits (int8_t minExpDig)
 Set the minimum exponent digits that will be shown. More...
 
virtual UBool isExponentSignAlwaysShown (void) const
 Return whether the exponent sign is always shown. More...
 
virtual void setExponentSignAlwaysShown (UBool expSignAlways)
 Set whether the exponent sign is always shown. More...
 
int32_t getGroupingSize (void) const
 Return the grouping size. More...
 
virtual void setGroupingSize (int32_t newValue)
 Set the grouping size. More...
 
int32_t getSecondaryGroupingSize (void) const
 Return the secondary grouping size. More...
 
virtual void setSecondaryGroupingSize (int32_t newValue)
 Set the secondary grouping size. More...
 
int32_t getMinimumGroupingDigits () const
 Returns the minimum number of grouping digits. More...
 
void setMinimumGroupingDigits (int32_t newValue)
 Sets the minimum grouping digits. More...
 
UBool isDecimalSeparatorAlwaysShown (void) const
 Allows you to get the behavior of the decimal separator with integers. More...
 
virtual void setDecimalSeparatorAlwaysShown (UBool newValue)
 Allows you to set the behavior of the decimal separator with integers. More...
 
UBool isDecimalPatternMatchRequired (void) const
 Allows you to get the parse behavior of the pattern decimal mark. More...
 
virtual void setDecimalPatternMatchRequired (UBool newValue)
 Allows you to set the parse behavior of the pattern decimal mark. More...
 
UBool isParseNoExponent () const
 Returns whether to ignore exponents when parsing. More...
 
void setParseNoExponent (UBool value)
 Specifies whether to stop parsing when an exponent separator is encountered. More...
 
UBool isParseCaseSensitive () const
 Returns whether parsing is sensitive to case (lowercase/uppercase). More...
 
void setParseCaseSensitive (UBool value)
 Whether to pay attention to case when parsing; default is to ignore case (perform case-folding). More...
 
UBool isFormatFailIfMoreThanMaxDigits () const
 Returns whether truncation of high-order integer digits should result in an error. More...
 
void setFormatFailIfMoreThanMaxDigits (UBool value)
 Sets whether truncation of high-order integer digits should result in an error. More...
 
virtual UnicodeStringtoPattern (UnicodeString &result) const
 Synthesizes a pattern string that represents the current state of this Format object. More...
 
virtual UnicodeStringtoLocalizedPattern (UnicodeString &result) const
 Synthesizes a localized pattern string that represents the current state of this Format object. More...
 
virtual void applyPattern (const UnicodeString &pattern, UParseError &parseError, UErrorCode &status)
 Apply the given pattern to this Format object. More...
 
virtual void applyPattern (const UnicodeString &pattern, UErrorCode &status)
 Sets the pattern. More...
 
virtual void applyLocalizedPattern (const UnicodeString &pattern, UParseError &parseError, UErrorCode &status)
 Apply the given pattern to this Format object. More...
 
virtual void applyLocalizedPattern (const UnicodeString &pattern, UErrorCode &status)
 Apply the given pattern to this Format object. More...
 
void setMaximumIntegerDigits (int32_t newValue) U_OVERRIDE
 Sets the maximum number of digits allowed in the integer portion of a number. More...
 
void setMinimumIntegerDigits (int32_t newValue) U_OVERRIDE
 Sets the minimum number of digits allowed in the integer portion of a number. More...
 
void setMaximumFractionDigits (int32_t newValue) U_OVERRIDE
 Sets the maximum number of digits allowed in the fraction portion of a number. More...
 
void setMinimumFractionDigits (int32_t newValue) U_OVERRIDE
 Sets the minimum number of digits allowed in the fraction portion of a number. More...
 
int32_t getMinimumSignificantDigits () const
 Returns the minimum number of significant digits that will be displayed. More...
 
int32_t getMaximumSignificantDigits () const
 Returns the maximum number of significant digits that will be displayed. More...
 
void setMinimumSignificantDigits (int32_t min)
 Sets the minimum number of significant digits that will be displayed. More...
 
void setMaximumSignificantDigits (int32_t max)
 Sets the maximum number of significant digits that will be displayed. More...
 
UBool areSignificantDigitsUsed () const
 Returns true if significant digits are in use, or false if integer and fraction digit counts are in use. More...
 
void setSignificantDigitsUsed (UBool useSignificantDigits)
 Sets whether significant digits are in use, or integer and fraction digit counts are in use. More...
 
void setCurrency (const char16_t *theCurrency, UErrorCode &ec) U_OVERRIDE
 Sets the currency used to display currency amounts. More...
 
virtual void setCurrency (const char16_t *theCurrency)
 Sets the currency used to display currency amounts. More...
 
void setCurrencyUsage (UCurrencyUsage newUsage, UErrorCode *ec)
 Sets the Currency Usage object used to display currency. More...
 
UCurrencyUsage getCurrencyUsage () const
 Returns the Currency Usage object used to display currency. More...
 
void formatToDecimalQuantity (double number, number::impl::DecimalQuantity &output, UErrorCode &status) const
 Format a number and save it into the given DecimalQuantity. More...
 
void formatToDecimalQuantity (const Formattable &number, number::impl::DecimalQuantity &output, UErrorCode &status) const
 Get a DecimalQuantity corresponding to a formattable as it would be formatted by this DecimalFormat. More...
 
const number::LocalizedNumberFormattertoNumberFormatter (UErrorCode &status) const
 Converts this DecimalFormat to a (Localized)NumberFormatter. More...
 
UClassID getDynamicClassID (void) const U_OVERRIDE
 Returns a unique class ID POLYMORPHICALLY. More...
 
virtual UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const override
 Format an object to produce a string. More...
 
virtual UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const override
 Format an object to produce a string. More...
 
UnicodeStringformat (double number, UnicodeString &appendTo) const
 Format a double number. More...
 
UnicodeStringformat (int32_t number, UnicodeString &appendTo) const
 Format a long number. More...
 
UnicodeStringformat (int64_t number, UnicodeString &appendTo) const
 Format an int64 number. More...
 
virtual UnicodeStringformat (double number, UnicodeString &appendTo, FieldPosition &pos) const=0
 Format a double number. More...
 
virtual UnicodeStringformat (double number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format a double number. More...
 
virtual UnicodeStringformat (double number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format a double number. More...
 
virtual UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPosition &pos) const=0
 Format a long number. More...
 
virtual UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format a long number. More...
 
virtual UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format an int32 number. More...
 
virtual UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPosition &pos) const
 Format an int64 number. More...
 
virtual UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format an int64 number. More...
 
virtual UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format an int64 number. More...
 
virtual UnicodeStringformat (StringPiece number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format a decimal number. More...
 
virtual UnicodeStringformat (const number::impl::DecimalQuantity &number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format a decimal number. More...
 
virtual UnicodeStringformat (const number::impl::DecimalQuantity &number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format a decimal number. More...
 
virtual void parse (const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const=0
 Return a long if possible (e.g. More...
 
virtual void parse (const UnicodeString &text, Formattable &result, UErrorCode &status) const
 Parse a string as a numeric value, and return a Formattable numeric object. More...
 
- Public Member Functions inherited from icu::NumberFormat
virtual ~NumberFormat ()
 Destructor. More...
 
virtual NumberFormatclone () const override=0
 Clones this object polymorphically. More...
 
virtual bool operator== (const Format &other) const override
 Return true if the given Format objects are semantically equal. More...
 
virtual UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const override
 Format an object to produce a string. More...
 
virtual UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const override
 Format an object to produce a string. More...
 
virtual void parseObject (const UnicodeString &source, Formattable &result, ParsePosition &parse_pos) const override
 Parse a string to produce an object. More...
 
UnicodeStringformat (double number, UnicodeString &appendTo) const
 Format a double number. More...
 
UnicodeStringformat (int32_t number, UnicodeString &appendTo) const
 Format a long number. More...
 
UnicodeStringformat (int64_t number, UnicodeString &appendTo) const
 Format an int64 number. More...
 
virtual UnicodeStringformat (double number, UnicodeString &appendTo, FieldPosition &pos) const =0
 Format a double number. More...
 
virtual UnicodeStringformat (double number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format a double number. More...
 
virtual UnicodeStringformat (double number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format a double number. More...
 
virtual UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPosition &pos) const =0
 Format a long number. More...
 
virtual UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format a long number. More...
 
virtual UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format an int32 number. More...
 
virtual UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPosition &pos) const
 Format an int64 number. More...
 
virtual UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format an int64 number. More...
 
virtual UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format an int64 number. More...
 
virtual UnicodeStringformat (StringPiece number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format a decimal number. More...
 
virtual UnicodeStringformat (const number::impl::DecimalQuantity &number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format a decimal number. More...
 
virtual UnicodeStringformat (const number::impl::DecimalQuantity &number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format a decimal number. More...
 
virtual void parse (const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const =0
 Return a long if possible (e.g. More...
 
virtual void parse (const UnicodeString &text, Formattable &result, UErrorCode &status) const
 Parse a string as a numeric value, and return a Formattable numeric object. More...
 
virtual CurrencyAmountparseCurrency (const UnicodeString &text, ParsePosition &pos) const
 Parses text from the given string as a currency amount. More...
 
UBool isParseIntegerOnly (void) const
 Return true if this format will parse numbers as integers only. More...
 
virtual void setParseIntegerOnly (UBool value)
 Sets whether or not numbers should be parsed as integers only. More...
 
virtual void setLenient (UBool enable)
 Sets whether lenient parsing should be enabled (it is off by default). More...
 
virtual UBool isLenient (void) const
 Returns whether lenient parsing is enabled (it is off by default). More...
 
UBool isGroupingUsed (void) const
 Returns true if grouping is used in this format. More...
 
virtual void setGroupingUsed (UBool newValue)
 Set whether or not grouping will be used in this format. More...
 
int32_t getMaximumIntegerDigits (void) const
 Returns the maximum number of digits allowed in the integer portion of a number. More...
 
virtual void setMaximumIntegerDigits (int32_t newValue)
 Sets the maximum number of digits allowed in the integer portion of a number. More...
 
int32_t getMinimumIntegerDigits (void) const
 Returns the minimum number of digits allowed in the integer portion of a number. More...
 
virtual void setMinimumIntegerDigits (int32_t newValue)
 Sets the minimum number of digits allowed in the integer portion of a number. More...
 
int32_t getMaximumFractionDigits (void) const
 Returns the maximum number of digits allowed in the fraction portion of a number. More...
 
virtual void setMaximumFractionDigits (int32_t newValue)
 Sets the maximum number of digits allowed in the fraction portion of a number. More...
 
int32_t getMinimumFractionDigits (void) const
 Returns the minimum number of digits allowed in the fraction portion of a number. More...
 
virtual void setMinimumFractionDigits (int32_t newValue)
 Sets the minimum number of digits allowed in the fraction portion of a number. More...
 
virtual void setCurrency (const char16_t *theCurrency, UErrorCode &ec)
 Sets the currency used to display currency amounts. More...
 
const char16_t * getCurrency () const
 Gets the currency used to display currency amounts. More...
 
virtual void setContext (UDisplayContext value, UErrorCode &status)
 Set a particular UDisplayContext value in the formatter, such as UDISPCTX_CAPITALIZATION_FOR_STANDALONE. More...
 
virtual UDisplayContext getContext (UDisplayContextType type, UErrorCode &status) const
 Get the formatter's UDisplayContext value for the specified UDisplayContextType, such as UDISPCTX_TYPE_CAPITALIZATION. More...
 
virtual ERoundingMode getRoundingMode (void) const
 Get the rounding mode. More...
 
virtual void setRoundingMode (ERoundingMode roundingMode)
 Set the rounding mode. More...
 
virtual UClassID getDynamicClassID (void) const override=0
 Returns a unique class ID POLYMORPHICALLY. More...
 
UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
 Formats an object to produce a string. More...
 
virtual UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const=0
 Format an object to produce a string. More...
 
virtual UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format an object to produce a string. More...
 
- Public Member Functions inherited from icu::Format
virtual ~Format ()
 Destructor. More...
 
virtual bool operator== (const Format &other) const =0
 Return true if the given Format objects are semantically equal. More...
 
bool operator!= (const Format &other) const
 Return true if the given Format objects are not semantically equal. More...
 
virtual Formatclone () const =0
 Clone this object polymorphically. More...
 
UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
 Formats an object to produce a string. More...
 
virtual UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const =0
 Format an object to produce a string. More...
 
virtual UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format an object to produce a string. More...
 
virtual void parseObject (const UnicodeString &source, Formattable &result, ParsePosition &parse_pos) const =0
 Parse a string to produce an object. More...
 
void parseObject (const UnicodeString &source, Formattable &result, UErrorCode &status) const
 Parses a string to produce an object. More...
 
Locale getLocale (ULocDataLocaleType type, UErrorCode &status) const
 Get the locale for this format object. More...
 
const char * getLocaleID (ULocDataLocaleType type, UErrorCode &status) const
 Get the locale for this format object. More...
 
- Public Member Functions inherited from icu::UObject
virtual ~UObject ()
 Destructor. More...
 
virtual UClassID getDynamicClassID () const
 ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class. More...
 

Static Public Member Functions

static CompactDecimalFormatcreateInstance (const Locale &inLocale, UNumberCompactStyle style, UErrorCode &status)
 Returns a compact decimal instance for specified locale. More...
 
static UClassID getStaticClassID ()
 Return the class ID for this class. More...
 
- Static Public Member Functions inherited from icu::DecimalFormat
static UClassID getStaticClassID (void)
 Return the class ID for this class. More...
 
- Static Public Member Functions inherited from icu::NumberFormat
static NumberFormatcreateInstance (UErrorCode &)
 Create a default style NumberFormat for the current default locale. More...
 
static NumberFormatcreateInstance (const Locale &inLocale, UErrorCode &)
 Create a default style NumberFormat for the specified locale. More...
 
static NumberFormatcreateInstance (const Locale &desiredLocale, UNumberFormatStyle style, UErrorCode &errorCode)
 Create a specific style NumberFormat for the specified locale. More...
 
static NumberFormatinternalCreateInstance (const Locale &desiredLocale, UNumberFormatStyle style, UErrorCode &errorCode)
 ICU use only. More...
 
static const SharedNumberFormat * createSharedInstance (const Locale &inLocale, UNumberFormatStyle style, UErrorCode &status)
 ICU use only. More...
 
static NumberFormatcreateCurrencyInstance (UErrorCode &)
 Returns a currency format for the current default locale. More...
 
static NumberFormatcreateCurrencyInstance (const Locale &inLocale, UErrorCode &)
 Returns a currency format for the specified locale. More...
 
static NumberFormatcreatePercentInstance (UErrorCode &)
 Returns a percentage format for the current default locale. More...
 
static NumberFormatcreatePercentInstance (const Locale &inLocale, UErrorCode &)
 Returns a percentage format for the specified locale. More...
 
static NumberFormatcreateScientificInstance (UErrorCode &)
 Returns a scientific format for the current default locale. More...
 
static NumberFormatcreateScientificInstance (const Locale &inLocale, UErrorCode &)
 Returns a scientific format for the specified locale. More...
 
static const LocalegetAvailableLocales (int32_t &count)
 Get the set of Locales for which NumberFormats are installed. More...
 
static URegistryKey registerFactory (NumberFormatFactory *toAdopt, UErrorCode &status)
 Register a new NumberFormatFactory. More...
 
static UBool unregister (URegistryKey key, UErrorCode &status)
 Unregister a previously-registered NumberFormatFactory using the key returned from the register call. More...
 
static StringEnumerationgetAvailableLocales (void)
 Return a StringEnumeration over the locales available at the time of the call, including registered locales. More...
 
static UClassID getStaticClassID (void)
 Return the class ID for this class. More...
 

Additional Inherited Members

- Public Types inherited from icu::DecimalFormat
enum  EPadPosition { kPadBeforePrefix , kPadAfterPrefix , kPadBeforeSuffix , kPadAfterSuffix }
 Pad position. More...
 
- Public Types inherited from icu::NumberFormat
enum  ERoundingMode {
  kRoundCeiling , kRoundFloor , kRoundDown , kRoundUp ,
  kRoundHalfEven , kRoundHalfDown , kRoundHalfUp , kRoundUnnecessary
}
 Rounding mode. More...
 
enum  EAlignmentFields {
  kIntegerField = UNUM_INTEGER_FIELD , kFractionField = UNUM_FRACTION_FIELD , kDecimalSeparatorField = UNUM_DECIMAL_SEPARATOR_FIELD , kExponentSymbolField = UNUM_EXPONENT_SYMBOL_FIELD ,
  kExponentSignField = UNUM_EXPONENT_SIGN_FIELD , kExponentField = UNUM_EXPONENT_FIELD , kGroupingSeparatorField = UNUM_GROUPING_SEPARATOR_FIELD , kCurrencyField = UNUM_CURRENCY_FIELD ,
  kPercentField = UNUM_PERCENT_FIELD , kPermillField = UNUM_PERMILL_FIELD , kSignField = UNUM_SIGN_FIELD , kMeasureUnitField = UNUM_MEASURE_UNIT_FIELD ,
  kCompactField = UNUM_COMPACT_FIELD , INTEGER_FIELD = UNUM_INTEGER_FIELD , FRACTION_FIELD = UNUM_FRACTION_FIELD
}
 Alignment Field constants used to construct a FieldPosition object. More...
 
- Protected Member Functions inherited from icu::NumberFormat
 NumberFormat ()
 Default constructor for subclass use only. More...
 
 NumberFormat (const NumberFormat &)
 Copy constructor. More...
 
NumberFormatoperator= (const NumberFormat &)
 Assignment operator. More...
 
virtual void getEffectiveCurrency (char16_t *result, UErrorCode &ec) const
 Returns the currency in effect for this formatter. More...
 
- Protected Member Functions inherited from icu::Format
void setLocaleIDs (const char *valid, const char *actual)
 
 Format ()
 Default constructor for subclass use only. More...
 
 Format (const Format &)
 
Formatoperator= (const Format &)
 
- Static Protected Member Functions inherited from icu::NumberFormat
static NumberFormatmakeInstance (const Locale &desiredLocale, UNumberFormatStyle style, UBool mustBeDecimalFormat, UErrorCode &errorCode)
 Creates the specified number format style of the desired locale. More...
 
- Static Protected Member Functions inherited from icu::Format
static void syntaxError (const UnicodeString &pattern, int32_t pos, UParseError &parseError)
 Simple function for initializing a UParseError from a UnicodeString. More...
 
- Static Protected Attributes inherited from icu::NumberFormat
static const int32_t gDefaultMaxIntegerDigits
 
static const int32_t gDefaultMinIntegerDigits
 

Detailed Description

IMPORTANT: New users are strongly encouraged to see if numberformatter.h fits their use case.

Although not deprecated, this header is provided for backwards compatibility only.


The CompactDecimalFormat produces abbreviated numbers, suitable for display in environments will limited real estate. For example, 'Hits: 1.2B' instead of 'Hits: 1,200,000,000'. The format will be appropriate for the given language, such as "1,2 Mrd." for German.

For numbers under 1000 trillion (under 10^15, such as 123,456,789,012,345), the result will be short for supported languages. However, the result may sometimes exceed 7 characters, such as when there are combining marks or thin characters. In such cases, the visual width in fonts should still be short.

By default, there are 3 significant digits. After creation, if more than three significant digits are set (with setMaximumSignificantDigits), or if a fixed number of digits are set (with setMaximumIntegerDigits or setMaximumFractionDigits), then result may be wider.

At this time, parsing is not supported, and will produce a U_UNSUPPORTED_ERROR. Resetting the pattern prefixes or suffixes is not supported; the method calls are ignored.

Stable:
ICU 51

Definition at line 63 of file compactdecimalformat.h.

Constructor & Destructor Documentation

◆ CompactDecimalFormat()

icu::CompactDecimalFormat::CompactDecimalFormat ( const CompactDecimalFormat source)

Copy constructor.

Parameters
sourcethe DecimalFormat object to be copied from.
Stable:
ICU 51

◆ ~CompactDecimalFormat()

icu::CompactDecimalFormat::~CompactDecimalFormat ( )

Destructor.

Stable:
ICU 51

Member Function Documentation

◆ clone()

CompactDecimalFormat * icu::CompactDecimalFormat::clone ( ) const
virtual

Clone this Format object polymorphically.

The caller owns the result and should delete it when done.

Returns
a polymorphic copy of this CompactDecimalFormat.
Stable:
ICU 51

Implements icu::NumberFormat.

◆ createInstance()

static CompactDecimalFormat * icu::CompactDecimalFormat::createInstance ( const Locale inLocale,
UNumberCompactStyle  style,
UErrorCode status 
)
static

Returns a compact decimal instance for specified locale.

NOTE: New users are strongly encouraged to use number::NumberFormatter instead of NumberFormat.

Parameters
inLocalethe given locale.
stylewhether to use short or long style.
statuserror code returned here.
Stable:
ICU 51

◆ format() [1/12]

UnicodeString & icu::DecimalFormat::format ( const number::impl::DecimalQuantity &  number,
UnicodeString appendTo,
FieldPosition pos,
UErrorCode status 
) const
virtual

Format a decimal number.

The number is a DecimalQuantity wrapper onto a floating point decimal number. The default implementation in NumberFormat converts the decimal number to a double and formats that.

Parameters
numberThe number, a DecimalQuantity format Decimal Floating Point.
appendToOutput parameter to receive result. Result is appended to existing contents.
posOn input: an alignment field, if desired. On output: the offsets of the alignment field.
statusOutput param filled with success/failure status.
Returns
Reference to 'appendTo' parameter.
Internal:
Do not use. This API is for internal use only.

Reimplemented from icu::DecimalFormat.

◆ format() [2/12]

UnicodeString & icu::DecimalFormat::format ( const number::impl::DecimalQuantity &  number,
UnicodeString appendTo,
FieldPositionIterator posIter,
UErrorCode status 
) const
virtual

Format a decimal number.

The number is a DecimalQuantity wrapper onto a floating point decimal number. The default implementation in NumberFormat converts the decimal number to a double and formats that.

Parameters
numberThe number, a DecimalQuantity format Decimal Floating Point.
appendToOutput parameter to receive result. Result is appended to existing contents.
posIterOn return, can be used to iterate over positions of fields generated by this format call.
statusOutput param filled with success/failure status.
Returns
Reference to 'appendTo' parameter.
Internal:
Do not use. This API is for internal use only.

Reimplemented from icu::DecimalFormat.

◆ format() [3/12]

UnicodeString & icu::DecimalFormat::format ( double  number,
UnicodeString appendTo,
FieldPosition pos 
) const
virtual

Format a double or long number using base-10 representation.

Parameters
numberThe value to be formatted.
appendToOutput parameter to receive result. Result is appended to existing contents.
posOn input: an alignment field, if desired. On output: the offsets of the alignment field.
Returns
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

Reimplemented from icu::DecimalFormat.

◆ format() [4/12]

UnicodeString & icu::DecimalFormat::format ( double  number,
UnicodeString appendTo,
FieldPosition pos,
UErrorCode status 
) const
virtual

Format a double or long number using base-10 representation.

Parameters
numberThe value to be formatted.
appendToOutput parameter to receive result. Result is appended to existing contents.
posOn input: an alignment field, if desired. On output: the offsets of the alignment field.
status
Returns
Reference to 'appendTo' parameter.
Internal:
Do not use. This API is for internal use only.

Reimplemented from icu::DecimalFormat.

◆ format() [5/12]

UnicodeString & icu::DecimalFormat::format ( double  number,
UnicodeString appendTo,
FieldPositionIterator posIter,
UErrorCode status 
) const
virtual

Format a double or long number using base-10 representation.

Parameters
numberThe value to be formatted.
appendToOutput parameter to receive result. Result is appended to existing contents.
posIterOn return, can be used to iterate over positions of fields generated by this format call. Can be NULL.
statusOutput param filled with success/failure status.
Returns
Reference to 'appendTo' parameter.
Stable:
ICU 4.4

Reimplemented from icu::DecimalFormat.

◆ format() [6/12]

UnicodeString & icu::DecimalFormat::format ( int32_t  number,
UnicodeString appendTo,
FieldPosition pos 
) const
virtual

Format a long number using base-10 representation.

Parameters
numberThe value to be formatted.
appendToOutput parameter to receive result. Result is appended to existing contents.
posOn input: an alignment field, if desired. On output: the offsets of the alignment field.
Returns
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

Reimplemented from icu::DecimalFormat.

◆ format() [7/12]

UnicodeString & icu::DecimalFormat::format ( int32_t  number,
UnicodeString appendTo,
FieldPosition pos,
UErrorCode status 
) const
virtual

Format a long number using base-10 representation.

Parameters
numberThe value to be formatted.
appendToOutput parameter to receive result. Result is appended to existing contents.
posOn input: an alignment field, if desired. On output: the offsets of the alignment field.
statusOutput param filled with success/failure status.
Returns
Reference to 'appendTo' parameter.
Internal:
Do not use. This API is for internal use only.

Reimplemented from icu::DecimalFormat.

◆ format() [8/12]

UnicodeString & icu::DecimalFormat::format ( int32_t  number,
UnicodeString appendTo,
FieldPositionIterator posIter,
UErrorCode status 
) const
virtual

Format a long number using base-10 representation.

Parameters
numberThe value to be formatted.
appendToOutput parameter to receive result. Result is appended to existing contents.
posIterOn return, can be used to iterate over positions of fields generated by this format call. Can be NULL.
statusOutput param filled with success/failure status.
Returns
Reference to 'appendTo' parameter.
Stable:
ICU 4.4

Reimplemented from icu::DecimalFormat.

◆ format() [9/12]

UnicodeString & icu::DecimalFormat::format ( int64_t  number,
UnicodeString appendTo,
FieldPosition pos 
) const
virtual

Format an int64 number using base-10 representation.

Parameters
numberThe value to be formatted.
appendToOutput parameter to receive result. Result is appended to existing contents.
posOn input: an alignment field, if desired. On output: the offsets of the alignment field.
Returns
Reference to 'appendTo' parameter.
Stable:
ICU 2.8

Reimplemented from icu::DecimalFormat.

◆ format() [10/12]

UnicodeString & icu::DecimalFormat::format ( int64_t  number,
UnicodeString appendTo,
FieldPosition pos,
UErrorCode status 
) const
virtual

Format an int64 number using base-10 representation.

Parameters
numberThe value to be formatted.
appendToOutput parameter to receive result. Result is appended to existing contents.
posOn input: an alignment field, if desired. On output: the offsets of the alignment field.
statusOutput param filled with success/failure status.
Returns
Reference to 'appendTo' parameter.
Internal:
Do not use. This API is for internal use only.

Reimplemented from icu::DecimalFormat.

◆ format() [11/12]

UnicodeString & icu::DecimalFormat::format ( int64_t  number,
UnicodeString appendTo,
FieldPositionIterator posIter,
UErrorCode status 
) const
virtual

Format an int64 number using base-10 representation.

Parameters
numberThe value to be formatted.
appendToOutput parameter to receive result. Result is appended to existing contents.
posIterOn return, can be used to iterate over positions of fields generated by this format call. Can be NULL.
statusOutput param filled with success/failure status.
Returns
Reference to 'appendTo' parameter.
Stable:
ICU 4.4

Reimplemented from icu::DecimalFormat.

◆ format() [12/12]

UnicodeString & icu::DecimalFormat::format ( StringPiece  number,
UnicodeString appendTo,
FieldPositionIterator posIter,
UErrorCode status 
) const
virtual

Format a decimal number.

The syntax of the unformatted number is a "numeric string" as defined in the Decimal Arithmetic Specification, available at http://speleotrove.com/decimal

Parameters
numberThe unformatted number, as a string.
appendToOutput parameter to receive result. Result is appended to existing contents.
posIterOn return, can be used to iterate over positions of fields generated by this format call. Can be NULL.
statusOutput param filled with success/failure status.
Returns
Reference to 'appendTo' parameter.
Stable:
ICU 4.4

Reimplemented from icu::DecimalFormat.

◆ getDynamicClassID()

UClassID icu::CompactDecimalFormat::getDynamicClassID ( ) const
virtual

Returns a unique class ID POLYMORPHICALLY.

Pure virtual override. This method is to implement a simple version of RTTI, since not all C++ compilers support genuine RTTI. Polymorphic operator==() and clone() methods call this method.

Returns
The class ID for this object. All objects of a given class have the same class ID. Objects of other classes have different class IDs.
Stable:
ICU 51

Implements icu::NumberFormat.

◆ getStaticClassID()

static UClassID icu::CompactDecimalFormat::getStaticClassID ( )
static

Return the class ID for this class.

This is useful only for comparing to a return value from getDynamicClassID(). For example:

.      Base* polymorphic_pointer = createPolymorphicObject();
.      if (polymorphic_pointer->getDynamicClassID() ==
.          Derived::getStaticClassID()) ...
Returns
The class ID for all objects of this class.
Stable:
ICU 51

◆ operator=()

CompactDecimalFormat & icu::CompactDecimalFormat::operator= ( const CompactDecimalFormat rhs)

Assignment operator.

Parameters
rhsthe DecimalFormat object to be copied.
Stable:
ICU 51

◆ parse() [1/2]

void icu::CompactDecimalFormat::parse ( const UnicodeString text,
Formattable result,
ParsePosition parsePosition 
) const
virtual

CompactDecimalFormat does not support parsing.

This implementation does nothing.

Parameters
textUnused.
resultDoes not change.
parsePositionDoes not change.
See also
Formattable
Stable:
ICU 51

Implements icu::NumberFormat.

◆ parse() [2/2]

void icu::CompactDecimalFormat::parse ( const UnicodeString text,
Formattable result,
UErrorCode status 
) const
virtual

CompactDecimalFormat does not support parsing.

This implementation sets status to U_UNSUPPORTED_ERROR

Parameters
textUnused.
resultDoes not change.
statusAlways set to U_UNSUPPORTED_ERROR.
Stable:
ICU 51

Reimplemented from icu::NumberFormat.

◆ parseCurrency()

CurrencyAmount * icu::CompactDecimalFormat::parseCurrency ( const UnicodeString text,
ParsePosition pos 
) const
virtual

Parses text from the given string as a currency amount.

Unlike the parse() method, this method will attempt to parse a generic currency name, searching for a match of this object's locale's currency display names, or for a 3-letter ISO currency code. This method will fail if this format is not a currency format, that is, if it does not contain the currency pattern symbol (U+00A4) in its prefix or suffix. This implementation always returns NULL.

Parameters
textthe string to parse
posinput-output position; on input, the position within text to match; must have 0 <= pos.getIndex() < text.length(); on output, the position after the last matched character. If the parse fails, the position in unchanged upon output.
Returns
if parse succeeds, a pointer to a newly-created CurrencyAmount object (owned by the caller) containing information about the parsed currency; if parse fails, this is NULL.
Internal:
Do not use. This API is for internal use only.

Reimplemented from icu::NumberFormat.


The documentation for this class was generated from the following file: