icu::CompactDecimalFormat Class Reference

The CompactDecimalFormat produces abbreviated numbers, suitable for display in environments will limited real estate. 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.
virtual ~CompactDecimalFormat ()
 Destructor.
CompactDecimalFormatoperator= (const CompactDecimalFormat &rhs)
 Assignment operator.
virtual Formatclone () const
 Clone this Format object polymorphically.
virtual UBool operator== (const Format &other) const
 Return TRUE if the given Format objects are semantically equal.
virtual UnicodeStringformat (double number, UnicodeString &appendTo, FieldPosition &pos) const
 Format a double or long number using base-10 representation.
virtual UnicodeStringformat (double number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format a double or long number using base-10 representation.
virtual UnicodeStringformat (double number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format a double or long number using base-10 representation.
virtual UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPosition &pos) const
 Format a long number using base-10 representation.
virtual UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format a long number using base-10 representation.
virtual UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format a long number using base-10 representation.
virtual UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPosition &pos) const
 Format an int64 number using base-10 representation.
virtual UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format an int64 number using base-10 representation.
virtual UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format an int64 number using base-10 representation.
virtual UnicodeStringformat (const StringPiece &number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format a decimal number.
virtual UnicodeStringformat (const DigitList &number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
 Format a decimal number.
virtual UnicodeStringformat (const DigitList &number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format a decimal number.
virtual void parse (const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const
 CompactDecimalFormat does not support parsing.
virtual void parse (const UnicodeString &text, Formattable &result, UErrorCode &status) const
 CompactDecimalFormat does not support parsing.
virtual CurrencyAmountparseCurrency (const UnicodeString &text, ParsePosition &pos) const
 Parses text from the given string as a currency amount.
virtual UClassID getDynamicClassID () const
 Returns a unique class ID POLYMORPHICALLY.

Static Public Member Functions

static CompactDecimalFormatcreateInstance (const Locale &inLocale, UNumberCompactStyle style, UErrorCode &status)
 Returns a compact decimal instance for specified locale.
static UClassID getStaticClassID ()
 Return the class ID for this class.

Detailed Description

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 52 of file compactdecimalformat.h.


Constructor & Destructor Documentation

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

Copy constructor.

Parameters:
source the DecimalFormat object to be copied from.
Stable:
ICU 51
virtual icu::CompactDecimalFormat::~CompactDecimalFormat (  )  [virtual]

Destructor.

Stable:
ICU 51

Member Function Documentation

virtual Format* 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

Reimplemented from icu::DecimalFormat.

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

Returns a compact decimal instance for specified locale.

Parameters:
inLocale the given locale.
style whether to use short or long style.
status error code returned here.
Stable:
ICU 51
virtual UnicodeString& icu::CompactDecimalFormat::format ( const DigitList &  number,
UnicodeString appendTo,
FieldPosition pos,
UErrorCode status 
) const [virtual]

Format a decimal number.

Currently sets status to U_UNSUPPORTED_ERROR. The number is a DigitList wrapper onto a floating point decimal number. The default implementation in NumberFormat converts the decimal number to a double and formats that.

Parameters:
number The number, a DigitList format Decimal Floating Point.
appendTo Output parameter to receive result. Result is appended to existing contents.
pos On input: an alignment field, if desired. On output: the offsets of the alignment field.
status Output 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.

virtual UnicodeString& icu::CompactDecimalFormat::format ( const DigitList &  number,
UnicodeString appendTo,
FieldPositionIterator posIter,
UErrorCode status 
) const [virtual]

Format a decimal number.

Currently sets status to U_UNSUPPORTED_ERROR The number is a DigitList wrapper onto a floating point decimal number. The default implementation in NumberFormat converts the decimal number to a double and formats that.

Parameters:
number The number, a DigitList format Decimal Floating Point.
appendTo Output parameter to receive result. Result is appended to existing contents.
posIter On return, can be used to iterate over positions of fields generated by this format call.
status Output 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.

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

Format a decimal number.

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

Parameters:
number The unformatted number, as a string.
appendTo Output parameter to receive result. Result is appended to existing contents.
posIter On return, can be used to iterate over positions of fields generated by this format call. Can be NULL.
status Output 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.

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

Format an int64 number using base-10 representation.

Currently sets status to U_UNSUPPORTED_ERROR

Parameters:
number The value to be formatted.
appendTo Output parameter to receive result. Result is appended to existing contents.
posIter On return, can be used to iterate over positions of fields generated by this format call. Can be NULL.
status Output 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.

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

Format an int64 number using base-10 representation.

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

Reimplemented from icu::DecimalFormat.

virtual UnicodeString& icu::CompactDecimalFormat::format ( int64_t  number,
UnicodeString appendTo,
FieldPosition pos 
) const [virtual]

Format an int64 number using base-10 representation.

Parameters:
number The value to be formatted.
appendTo Output parameter to receive result. Result is appended to existing contents.
pos On input: an alignment field, if desired. On output: the offsets of the alignment field.
Returns:
Reference to 'appendTo' parameter.
Stable:
ICU 51

Reimplemented from icu::DecimalFormat.

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

Format a long number using base-10 representation.

Currently sets status to U_UNSUPPORTED_ERROR

Parameters:
number The value to be formatted.
appendTo Output parameter to receive result. Result is appended to existing contents.
posIter On return, can be used to iterate over positions of fields generated by this format call. Can be NULL.
status Output 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.

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

Format a long number using base-10 representation.

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

Reimplemented from icu::DecimalFormat.

virtual UnicodeString& icu::CompactDecimalFormat::format ( int32_t  number,
UnicodeString appendTo,
FieldPosition pos 
) const [virtual]

Format a long number using base-10 representation.

Parameters:
number The value to be formatted.
appendTo Output parameter to receive result. Result is appended to existing contents.
pos On input: an alignment field, if desired. On output: the offsets of the alignment field.
Returns:
Reference to 'appendTo' parameter.
Draft:
This API may be changed in the future versions and was introduced in ICU 56

Reimplemented from icu::DecimalFormat.

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

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

Currently sets status to U_UNSUPPORTED_ERROR.

Parameters:
number The value to be formatted.
appendTo Output parameter to receive result. Result is appended to existing contents.
posIter On return, can be used to iterate over positions of fields generated by this format call. Can be NULL.
status Output 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.

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

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

Parameters:
number The value to be formatted.
appendTo Output parameter to receive result. Result is appended to existing contents.
pos On 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.

virtual UnicodeString& icu::CompactDecimalFormat::format ( double  number,
UnicodeString appendTo,
FieldPosition pos 
) const [virtual]

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

Parameters:
number The value to be formatted.
appendTo Output parameter to receive result. Result is appended to existing contents.
pos On input: an alignment field, if desired. On output: the offsets of the alignment field.
Returns:
Reference to 'appendTo' parameter.
Stable:
ICU 51

Reimplemented from icu::DecimalFormat.

virtual 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

Reimplemented from icu::DecimalFormat.

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

Reimplemented from icu::DecimalFormat.

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

Assignment operator.

Parameters:
rhs the DecimalFormat object to be copied.
Stable:
ICU 51

Reimplemented from icu::DecimalFormat.

virtual UBool icu::CompactDecimalFormat::operator== ( const Format other  )  const [virtual]

Return TRUE if the given Format objects are semantically equal.

Objects of different subclasses are considered unequal.

Parameters:
other the object to be compared with.
Returns:
TRUE if the given Format objects are semantically equal.
Stable:
ICU 51

Reimplemented from icu::DecimalFormat.

virtual 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:
text Unused.
result Does not change.
status Always set to U_UNSUPPORTED_ERROR.
Stable:
ICU 51

Reimplemented from icu::NumberFormat.

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

CompactDecimalFormat does not support parsing.

This implementation does nothing.

Parameters:
text Unused.
result Does not change.
parsePosition Does not change.
See also:
Formattable
Stable:
ICU 51

Reimplemented from icu::DecimalFormat.

virtual 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:
text the string to parse
pos input-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::DecimalFormat.


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

Generated on 24 Jul 2019 for ICU 57.1 by  doxygen 1.6.1