ICU 60.3
60.3
|
The result of a number formatting operation. More...
#include <numberformatter.h>
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 |
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.
Definition at line 1876 of file numberformatter.h.
icu::number::FormattedNumber::~FormattedNumber | ( | ) |
Destruct an instance of FormattedNumber, cleaning up any memory it might own.
Appendable& icu::number::FormattedNumber::appendTo | ( | Appendable & | appendable | ) |
Appends the formatted number to an Appendable.
appendable | The Appendable to which to append the formatted number string. |
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.
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. |
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.
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. |
UnicodeString icu::number::FormattedNumber::toString | ( | ) | const |
Returns a UnicodeString representation of the formatted number.