ICU 76.1 76.1
|
The result of a number formatting operation. More...
#include <formattednumber.h>
Public Member Functions | |
FormattedNumber () | |
Default constructor; makes an empty FormattedNumber. | |
FormattedNumber (FormattedNumber &&src) noexcept | |
Move constructor: Leaves the source FormattedNumber in an undefined state. | |
virtual | ~FormattedNumber () override |
Destruct an instance of FormattedNumber. | |
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) noexcept |
Move assignment: Leaves the source FormattedNumber in an undefined state. | |
UnicodeString | toString (UErrorCode &status) const override |
Returns the formatted string as a self-contained UnicodeString. | |
UnicodeString | toTempString (UErrorCode &status) const override |
Returns the formatted string as a read-only alias to memory owned by the FormattedValue. | |
Appendable & | appendTo (Appendable &appendable, UErrorCode &status) const override |
Appends the formatted string to an Appendable. | |
UBool | nextPosition (ConstrainedFieldPosition &cfpos, UErrorCode &status) const override |
Iterates over field positions in the FormattedValue. | |
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. | |
MeasureUnit | getOutputUnit (UErrorCode &status) const |
Gets the resolved output unit. | |
UDisplayOptionsNounClass | getNounClass (UErrorCode &status) const |
Gets the noun class of the formatted output. | |
void | getDecimalQuantity (impl::DecimalQuantity &output, UErrorCode &status) const |
Gets the raw DecimalQuantity for plural rule selection. | |
void | getAllFieldPositionsImpl (FieldPositionIteratorHandler &fpih, UErrorCode &status) const |
Populates the mutable builder type FieldPositionIteratorHandler. | |
Public Member Functions inherited from icu::FormattedValue | |
virtual | ~FormattedValue () |
Friends | |
class | LocalizedNumberFormatter |
class | SimpleNumberFormatter |
struct | impl::UFormattedNumberImpl |
class | icu::SimpleDateFormat |
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 48 of file formattednumber.h.
|
inline |
Default constructor; makes an empty FormattedNumber.
Definition at line 55 of file formattednumber.h.
|
noexcept |
Move constructor: Leaves the source FormattedNumber in an undefined state.
|
overridevirtual |
Destruct an instance of FormattedNumber.
|
overridevirtual |
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
.
|
overridevirtual |
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.
|
noexcept |
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 200 of file formattednumber.h.
|
overridevirtual |
Returns the formatted string as a self-contained UnicodeString.
For more information, see FormattedValue::toString()
Implements icu::FormattedValue.
|
overridevirtual |
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 196 of file formattednumber.h.
Definition at line 193 of file formattednumber.h.
|
friend |
Definition at line 189 of file formattednumber.h.
|
friend |
Definition at line 190 of file formattednumber.h.