ICU 60.1  60.1
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:
icu::UMemory

Public Member Functions

UnicodeString toString () const
 Returns a UnicodeString representation of the formatted number. More...
 
AppendableappendTo (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

◆ ~FormattedNumber()

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

◆ appendTo()

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

Appends the formatted number to an Appendable.

Parameters
appendableThe 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

◆ populateFieldPosition()

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
fieldPositionThe FieldPosition to populate with the start and end indices of the desired field.
statusSet 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

◆ populateFieldPositionIterator()

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
iteratorThe FieldPositionIterator to populate with all of the fields present in the formatted number.
statusSet 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

◆ toString()

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: