ICU 72.1 72.1
|
The result of a number formatting operation. More...
#include <numberformatter.h>
Public Member Functions | |
FormattedNumber () | |
Default constructor; makes an empty FormattedNumber. More... | |
FormattedNumber (FormattedNumber &&src) U_NOEXCEPT | |
Move constructor: Leaves the source FormattedNumber in an undefined state. More... | |
virtual | ~FormattedNumber () U_OVERRIDE |
Destruct an instance of FormattedNumber. 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 & | operator= (FormattedNumber &&src) U_NOEXCEPT |
Move assignment: Leaves the source FormattedNumber in an undefined state. More... | |
UnicodeString | toString (UErrorCode &status) const U_OVERRIDE |
Returns the formatted string as a self-contained UnicodeString. More... | |
UnicodeString | toTempString (UErrorCode &status) const U_OVERRIDE |
Returns the formatted string as a read-only alias to memory owned by the FormattedValue. More... | |
Appendable & | appendTo (Appendable &appendable, UErrorCode &status) const U_OVERRIDE |
Appends the formatted string to an Appendable. More... | |
UBool | nextPosition (ConstrainedFieldPosition &cfpos, UErrorCode &status) const U_OVERRIDE |
Iterates over field positions in the FormattedValue. More... | |
template<typename StringClass > | |
StringClass | toDecimalNumber (UErrorCode &status) const |
Export the formatted number as a "numeric string" conforming to the syntax defined in the Decimal Arithmetic Specification, available at http://speleotrove.com/decimal. More... | |
MeasureUnit | getOutputUnit (UErrorCode &status) const |
Gets the resolved output unit. More... | |
UDisplayOptionsNounClass | getNounClass (UErrorCode &status) const |
Gets the noun class of the formatted output. 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... | |
Public Member Functions inherited from icu::FormattedValue | |
virtual | ~FormattedValue () |
virtual UnicodeString | toString (UErrorCode &status) const =0 |
Returns the formatted string as a self-contained UnicodeString. More... | |
virtual UnicodeString | toTempString (UErrorCode &status) const =0 |
Returns the formatted string as a read-only alias to memory owned by the FormattedValue. More... | |
virtual Appendable & | appendTo (Appendable &appendable, UErrorCode &status) const =0 |
Appends the formatted string to an Appendable. More... | |
virtual UBool | nextPosition (ConstrainedFieldPosition &cfpos, UErrorCode &status) const =0 |
Iterates over field positions in the FormattedValue. More... | |
Friends | |
class | LocalizedNumberFormatter |
struct | impl::UFormattedNumberImpl |
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.
Instances of this class are immutable and thread-safe.
Definition at line 2703 of file numberformatter.h.
|
inline |
Default constructor; makes an empty FormattedNumber.
Definition at line 2710 of file numberformatter.h.
icu::number::FormattedNumber::FormattedNumber | ( | FormattedNumber && | src | ) |
Move constructor: Leaves the source FormattedNumber in an undefined state.
|
virtual |
Destruct an instance of FormattedNumber.
|
virtual |
Appends the formatted string to an Appendable.
For more information, see FormattedValue::appendTo()
Implements icu::FormattedValue.
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.
UDisplayOptionsNounClass icu::number::FormattedNumber::getNounClass | ( | UErrorCode & | status | ) | const |
Gets the noun class of the formatted output.
Returns UNDEFINED
when the noun class is not supported yet.
MeasureUnit icu::number::FormattedNumber::getOutputUnit | ( | UErrorCode & | status | ) | const |
Gets the resolved output unit.
The output unit is dependent upon the localized preferences for the usage specified via NumberFormatterSettings::usage(), and may be a unit with UMEASURE_UNIT_MIXED unit complexity (MeasureUnit::getComplexity()), such as "foot-and-inch" or "hour-and-minute-and-second".
MeasureUnit
.
|
virtual |
Iterates over field positions in the FormattedValue.
This lets you determine the position of specific types of substrings, like a month or a decimal separator.
To loop over all field positions:
ConstrainedFieldPosition cfpos; while (fmtval.nextPosition(cfpos, status)) { // handle the field position; get information from cfpos }
cfpos | The object used for iteration state. This can provide constraints to iterate over only one specific category or field; see ConstrainedFieldPosition::constrainCategory and ConstrainedFieldPosition::constrainField. |
status | Set if an error occurs. |
Implements icu::FormattedValue.
FormattedNumber & icu::number::FormattedNumber::operator= | ( | FormattedNumber && | src | ) |
Move assignment: Leaves the source FormattedNumber in an undefined state.
|
inline |
Export the formatted number as a "numeric string" conforming to the syntax defined in the Decimal Arithmetic Specification, available at http://speleotrove.com/decimal.
This endpoint is useful for obtaining the exact number being printed after scaling and rounding have been applied by the number formatter.
Example call site:
auto decimalNumber = fn.toDecimalNumber<std::string>(status);
StringClass | A string class compatible with StringByteSink; for example, std::string. |
status | Set if an error occurs. |
Definition at line 2855 of file numberformatter.h.
|
virtual |
Returns the formatted string as a self-contained UnicodeString.
For more information, see FormattedValue::toString()
Implements icu::FormattedValue.
|
virtual |
Returns the formatted string as a read-only alias to memory owned by the FormattedValue.
The return value is valid only as long as this FormattedValue is present and unchanged in memory. If you need the string outside the current scope, consider toString.
The buffer returned by calling UnicodeString::getBuffer() on the return value is guaranteed to be NUL-terminated.
status | Set if an error occurs. |
Implements icu::FormattedValue.
|
friend |
Definition at line 2851 of file numberformatter.h.
|
friend |
Definition at line 2848 of file numberformatter.h.