ICU 63.1 63.1

Public Member Functions | Friends
icu::number::FormattedNumberRange Class Reference

The result of a number range formatting operation. More...

`#include <numberrangeformatter.h>`

Inheritance diagram for icu::number::FormattedNumberRange:

## Public Member Functions
UnicodeString | toString (UErrorCode &status) const
| Returns a UnicodeString representation of the formatted number range. More...
Appendable & | appendTo (Appendable &appendable, UErrorCode &status) const
| Appends the formatted number range to an Appendable. More...
UBool | nextFieldPosition (FieldPosition &fieldPosition, UErrorCode &status) const
| Determines the start (inclusive) and end (exclusive) indices of the next occurrence of the given field in the output string. More...
void | getAllFieldPositions (FieldPositionIterator &iterator, UErrorCode &status) const
| Export the formatted number range to a FieldPositionIterator. More...
UnicodeString | getFirstDecimal (UErrorCode &status) const
| Export the first formatted number as a decimal number. More...
UnicodeString | getSecondDecimal (UErrorCode &status) const
| Export the second formatted number as a decimal number. 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 (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...

## Friends
class | LocalizedNumberRangeFormatter

## Detailed Description

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.

Draft:
  This API may be changed in the future versions and was introduced in ICU 63

Definition at line 659 of file numberrangeformatter.h.

## Constructor & Destructor Documentation

## ◆ FormattedNumberRange()

icu::number::FormattedNumberRange::FormattedNumberRange | ( | FormattedNumberRange && | src | ) |

Move constructor: Leaves the source FormattedNumberRange in an undefined state.

Draft:
  This API may be changed in the future versions and was introduced in ICU 63

## ◆ ~FormattedNumberRange()

icu::number::FormattedNumberRange::~FormattedNumberRange | ( |  | ) |

Destruct an instance of FormattedNumberRange, cleaning up any memory it might own.

Draft:
  This API may be changed in the future versions and was introduced in ICU 63

## Member Function Documentation

## ◆ appendTo()

Appendable& icu::number::FormattedNumberRange::appendTo | ( | Appendable & | appendable,
|  | UErrorCode & | status
| ) |  | const

Appends the formatted number range to an Appendable.

Parameters

  appendable | The Appendable to which to append the formatted number range string.
  status | Set if an error occurs while formatting the number range to the Appendable.

Returns
  The same Appendable, for chaining.

Draft:
  This API may be changed in the future versions and was introduced in ICU 63

See also
  Appendable

## ◆ getAllFieldPositions()

void icu::number::FormattedNumberRange::getAllFieldPositions | ( | FieldPositionIterator & | iterator,
|  | UErrorCode & | status
| ) |  | const

Export the formatted number range 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.

Parameters

  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.

Draft:
  This API may be changed in the future versions and was introduced in ICU 63

See also
  UNumberFormatFields

## ◆ getFirstDecimal()

UnicodeString icu::number::FormattedNumberRange::getFirstDecimal | ( | UErrorCode & | status | ) | const

Export the first formatted number as a decimal number.

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 number is a "numeric string" as defined in the Decimal Arithmetic Specification, available at http://speleotrove.com/decimal

Returns
  A decimal representation of the first formatted number.

Draft:
  This API may be changed in the future versions and was introduced in ICU 63

See also
  NumberRangeFormatter
  getSecondDecimal

## ◆ getIdentityResult()

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.

Returns
  An indication the resulting identity situation in the formatted number range.

Draft:
  This API may be changed in the future versions and was introduced in ICU 63

See also
  UNumberRangeIdentityFallback

## ◆ getSecondDecimal()

UnicodeString icu::number::FormattedNumberRange::getSecondDecimal | ( | UErrorCode & | status | ) | const

Export the second formatted number as a decimal number.

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 number is a "numeric string" as defined in the Decimal Arithmetic Specification, available at http://speleotrove.com/decimal

Returns
  A decimal representation of the second formatted number.

Draft:
  This API may be changed in the future versions and was introduced in ICU 63

See also
  NumberRangeFormatter
  getFirstDecimal

## ◆ nextFieldPosition()

UBool icu::number::FormattedNumberRange::nextFieldPosition | ( | FieldPosition & | fieldPosition,
|  | UErrorCode & | status
| ) |  | const

Determines the start (inclusive) and end (exclusive) 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 both sides of the range have the same field, the field will occur twice, once before the range separator and once after the range separator, if applicable.

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_INTEGER_FIELD);
    while (formattedNumberRange.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().

Parameters

  fieldPosition | Input+output variable. See FormattedNumber#nextFieldPosition.
  status | Set if an error occurs while populating the FieldPosition.

Returns
  TRUE if a new occurrence of the field was found; FALSE otherwise.

Draft:
  This API may be changed in the future versions and was introduced in ICU 63

See also
  UNumberFormatFields

## ◆ operator=()

FormattedNumberRange& icu::number::FormattedNumberRange::operator= | ( | FormattedNumberRange && | src | ) |

Move assignment: Leaves the source FormattedNumberRange in an undefined state.

Draft:
  This API may be changed in the future versions and was introduced in ICU 63

## ◆ toString()

UnicodeString icu::number::FormattedNumberRange::toString | ( | UErrorCode & | status | ) | const

Returns a UnicodeString representation of the formatted number range.

Parameters

  status | Set if an error occurs while formatting the number to the UnicodeString.

Returns
  a UnicodeString containing the localized number range.

Draft:
  This API may be changed in the future versions and was introduced in ICU 63

The documentation for this class was generated from the following file:

- numberrangeformatter.h