ICU 72.1 72.1
|
The result of a number range formatting operation. More...
#include <numberrangeformatter.h>
Public Member Functions | |
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 > | |
std::pair< StringClass, StringClass > | getDecimalNumbers (UErrorCode &status) const |
Extracts the formatted range as a pair of decimal numbers. More... | |
UNumberRangeIdentityResult | getIdentityResult (UErrorCode &status) const |
Returns whether the pair of numbers was successfully formatted as a range or whether an identity fallback was used. More... | |
FormattedNumberRange () | |
Default constructor; makes an empty FormattedNumberRange. More... | |
FormattedNumberRange (const FormattedNumberRange &)=delete | |
Copying not supported; use move constructor instead. | |
FormattedNumberRange & | operator= (const FormattedNumberRange &)=delete |
Copying not supported; use move assignment instead. | |
FormattedNumberRange (FormattedNumberRange &&src) U_NOEXCEPT | |
Move constructor: Leaves the source FormattedNumberRange in an undefined state. More... | |
FormattedNumberRange & | operator= (FormattedNumberRange &&src) U_NOEXCEPT |
Move assignment: Leaves the source FormattedNumberRange in an undefined state. More... | |
~FormattedNumberRange () | |
Destruct an instance of FormattedNumberRange, cleaning up any memory it might own. 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 | ::icu::PluralRules |
class | LocalizedNumberRangeFormatter |
struct | impl::UFormattedNumberRangeImpl |
The result of a number range 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 579 of file numberrangeformatter.h.
|
inline |
Default constructor; makes an empty FormattedNumberRange.
Definition at line 646 of file numberrangeformatter.h.
icu::number::FormattedNumberRange::FormattedNumberRange | ( | FormattedNumberRange && | src | ) |
Move constructor: Leaves the source FormattedNumberRange in an undefined state.
icu::number::FormattedNumberRange::~FormattedNumberRange | ( | ) |
Destruct an instance of FormattedNumberRange, cleaning up any memory it might own.
|
virtual |
Appends the formatted string to an Appendable.
For more information, see FormattedValue::appendTo()
Implements icu::FormattedValue.
|
inline |
Extracts the formatted range as a pair of decimal numbers.
This endpoint is useful for obtaining the exact number being printed after scaling and rounding have been applied by the number range formatting pipeline.
The syntax of the unformatted numbers is a "numeric string" as defined in the Decimal Arithmetic Specification, available at http://speleotrove.com/decimal
Example C++17 call site:
auto [ first, second ] = range.getDecimalNumbers<std::string>(status);
StringClass | A string class compatible with StringByteSink; for example, std::string. |
status | Set if an error occurs. |
Definition at line 711 of file numberrangeformatter.h.
UNumberRangeIdentityResult icu::number::FormattedNumberRange::getIdentityResult | ( | UErrorCode & | status | ) | const |
Returns whether the pair of numbers was successfully formatted as a range or whether an identity fallback was used.
For example, if the first and second number were the same either before or after rounding occurred, an identity fallback was used.
|
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.
FormattedNumberRange & icu::number::FormattedNumberRange::operator= | ( | FormattedNumberRange && | src | ) |
Move assignment: Leaves the source FormattedNumberRange in an undefined state.
|
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 700 of file numberrangeformatter.h.
|
friend |
Definition at line 706 of file numberrangeformatter.h.
|
friend |
Definition at line 703 of file numberrangeformatter.h.