ICU 60.2 60.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Data Structure Index
- Class Hierarchy
- Data Fields

Public Member Functions | Friends
icu::number::FormattedNumber Class Reference

The result of a number formatting operation. More...

`#include <numberformatter.h>`

Inheritance diagram for icu::number::FormattedNumber:

## Public Member Functions
UnicodeString | toString () const
| Returns a UnicodeString representation of the formatted number. More...
Appendable & | appendTo (Appendable &appendable)
| Appends the formatted number to an Appendable. More...
void | populateFieldPosition (FieldPosition &fieldPosition, UErrorCode &status)
| Determine the start and end indices of the first occurrence of the given field in the output string. More...
void | populateFieldPositionIterator (FieldPositionIterator &iterator, UErrorCode &status)
| Export the formatted number to a FieldPositionIterator. More...
| ~FormattedNumber ()
| Destruct an instance of FormattedNumber, cleaning up any memory it might own. More...

## Friends
class | LocalizedNumberFormatter

## Detailed Description

The result of a number formatting operation.

This class allows the result to be exported in several data types, including a UnicodeString and a FieldPositionIterator.

Draft:
  This API may be changed in the future versions and was introduced in ICU 60

Definition at line 1876 of file numberformatter.h.

## Constructor & Destructor Documentation

icu::number::FormattedNumber::~FormattedNumber | ( |  | ) |

Destruct an instance of FormattedNumber, cleaning up any memory it might own.

Draft:
  This API may be changed in the future versions and was introduced in ICU 60

## Member Function Documentation

Appendable& icu::number::FormattedNumber::appendTo | ( | Appendable & | appendable | ) |

Appends the formatted number to an Appendable.

Parameters

  appendable | The Appendable to which to append the formatted number string.

Returns
  The same Appendable, for chaining.

Draft:
  This API may be changed in the future versions and was introduced in ICU 60

See also
  Appendable

void icu::number::FormattedNumber::populateFieldPosition | ( | FieldPosition & | fieldPosition,
|  | UErrorCode & | status
| ) |  |

Determine the start and end indices of the first occurrence of the given field in the output string.

This allows you to determine the locations of the integer part, fraction part, and sign.

If multiple different field attributes are needed, this method can be called repeatedly, or if all field attributes are needed, consider using populateFieldPositionIterator().

If a field occurs multiple times in an output string, such as a grouping separator, this method will only ever return the first occurrence. Use populateFieldPositionIterator() to access all occurrences of an attribute.

Parameters

  fieldPosition | The FieldPosition to populate with the start and end indices of the desired field.
  status | Set if an error occurs while populating the FieldPosition.

Draft:
  This API may be changed in the future versions and was introduced in ICU 60

See also
  UNumberFormatFields

void icu::number::FormattedNumber::populateFieldPositionIterator | ( | FieldPositionIterator & | iterator,
|  | UErrorCode & | status
| ) |  |

Export the formatted number to a FieldPositionIterator.

This allows you to determine which characters in the output string correspond to which fields, such as the integer part, fraction part, and sign.

If information on only one field is needed, consider using populateFieldPosition() instead.

Parameters

  iterator | The FieldPositionIterator to populate with all of the fields present in the formatted number.
  status | Set if an error occurs while populating the FieldPositionIterator.

Draft:
  This API may be changed in the future versions and was introduced in ICU 60

See also
  UNumberFormatFields

UnicodeString icu::number::FormattedNumber::toString | ( |  | ) | const

Returns a UnicodeString representation of the formatted number.

Returns
  a UnicodeString containing the localized number.

Draft:
  This API may be changed in the future versions and was introduced in ICU 60

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

- numberformatter.h