ICU 62.1
62.1
|
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... | |
UnicodeString | toString (UErrorCode &status) const |
Returns a UnicodeString representation of the formatted number. More... | |
Appendable & | appendTo (Appendable &appendable) |
Appends the formatted number to an Appendable. More... | |
Appendable & | appendTo (Appendable &appendable, UErrorCode &status) |
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... | |
UBool | nextFieldPosition (FieldPosition &fieldPosition, UErrorCode &status) const |
Determines the start and end indices of the next occurrence of the given field in the output string. More... | |
void | populateFieldPositionIterator (FieldPositionIterator &iterator, UErrorCode &status) |
Export the formatted number to a FieldPositionIterator. More... | |
void | getAllFieldPositions (FieldPositionIterator &iterator, UErrorCode &status) const |
Export the formatted number to a FieldPositionIterator. More... | |
void | getDecimalQuantity (impl::DecimalQuantity &output, UErrorCode &status) const |
Gets the raw DecimalQuantity for plural rule selection. More... | |
void | getAllFieldPositionsImpl (FieldPositionIteratorHandler &fpih, UErrorCode &status) const |
Populates the mutable builder type FieldPositionIteratorHandler. More... | |
FormattedNumber (const FormattedNumber &)=delete | |
Copying not supported; use move constructor instead. | |
FormattedNumber & | operator= (const FormattedNumber &)=delete |
Copying not supported; use move assignment instead. | |
FormattedNumber (FormattedNumber &&src) | |
Move constructor: Leaves the source FormattedNumber in an undefined state. More... | |
FormattedNumber & | operator= (FormattedNumber &&src) |
Move assignment: Leaves the source FormattedNumber in an undefined state. 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 2383 of file numberformatter.h.
icu::number::FormattedNumber::FormattedNumber | ( | FormattedNumber && | src | ) |
Move constructor: Leaves the source FormattedNumber in an undefined state.
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. |
Appendable& icu::number::FormattedNumber::appendTo | ( | Appendable & | appendable, |
UErrorCode & | status | ||
) |
Appends the formatted number to an Appendable.
appendable | The Appendable to which to append the formatted number string. |
status | Set if an error occurs while formatting the number to the Appendable. |
void icu::number::FormattedNumber::getAllFieldPositions | ( | FieldPositionIterator & | iterator, |
UErrorCode & | status | ||
) | const |
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, use nextFieldPosition() 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. |
void icu::number::FormattedNumber::getAllFieldPositionsImpl | ( | FieldPositionIteratorHandler & | fpih, |
UErrorCode & | status | ||
) | const |
Populates the mutable builder type FieldPositionIteratorHandler.
void icu::number::FormattedNumber::getDecimalQuantity | ( | impl::DecimalQuantity & | output, |
UErrorCode & | status | ||
) | const |
Gets the raw DecimalQuantity for plural rule selection.
UBool icu::number::FormattedNumber::nextFieldPosition | ( | FieldPosition & | fieldPosition, |
UErrorCode & | status | ||
) | const |
Determines the start and end indices of the next occurrence of the given field in the output string.
This allows you to determine the locations of, for example, the integer part, fraction part, or symbols.
If a field occurs just once, calling this method will find that occurrence and return it. If a field occurs multiple times, this method may be called repeatedly with the following pattern:
FieldPosition fpos(UNUM_GROUPING_SEPARATOR_FIELD); while (formattedNumber.nextFieldPosition(fpos, status)) { // do something with fpos. }
This method is useful if you know which field to query. If you want all available field position information, use getAllFieldPositions().
fieldPosition | Input+output variable. On input, the "field" property determines which field to look up, and the "beginIndex" and "endIndex" properties determine where to begin the search. On output, the "beginIndex" is set to the beginning of the first occurrence of the field with either begin or end indices after the input indices, "endIndex" is set to the end of that occurrence of the field (exclusive index). If a field position is not found, the method returns FALSE and the FieldPosition may or may not be changed. |
status | Set if an error occurs while populating the FieldPosition. |
FormattedNumber& icu::number::FormattedNumber::operator= | ( | FormattedNumber && | src | ) |
Move assignment: Leaves the source FormattedNumber in an undefined state.
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.
UnicodeString icu::number::FormattedNumber::toString | ( | UErrorCode & | status | ) | const |
Returns a UnicodeString representation of the formatted number.
status | Set if an error occurs while formatting the number to the UnicodeString. |