ICU 73.2  73.2
Public Member Functions | Friends
icu::number::LocalizedNumberFormatter Class Reference

A NumberFormatter that has a locale associated with it; this means .format() methods are available. More...

#include <numberformatter.h>

Inheritance diagram for icu::number::LocalizedNumberFormatter:
icu::number::NumberFormatterSettings< Derived > icu::UMemory

Public Member Functions

FormattedNumber formatInt (int64_t value, UErrorCode &status) const
 Format the given integer number to a string using the settings specified in the NumberFormatter fluent setting chain.
FormattedNumber formatDouble (double value, UErrorCode &status) const
 Format the given float or double to a string using the settings specified in the NumberFormatter fluent setting chain.
FormattedNumber formatDecimal (StringPiece value, UErrorCode &status) const
 Format the given decimal number to a string using the settings specified in the NumberFormatter fluent setting chain.
const DecimalFormatSymbolsgetDecimalFormatSymbols () const
FormattedNumber formatDecimalQuantity (const impl::DecimalQuantity &dq, UErrorCode &status) const
 Internal method.
void getAffixImpl (bool isPrefix, bool isNegative, UnicodeString &result, UErrorCode &status) const
 Internal method for DecimalFormat compatibility.
const impl::NumberFormatterImpl * getCompiled () const
 Internal method for testing.
int32_t getCallCount () const
 Internal method for testing.
FormattoFormat (UErrorCode &status) const
 Creates a representation of this LocalizedNumberFormat as an icu::Format, enabling the use of this number formatter with APIs that need an object of that type, such as MessageFormat.
 LocalizedNumberFormatter ()
 Default constructor: puts the formatter into a valid but undefined state.
 LocalizedNumberFormatter (const LocalizedNumberFormatter &other)
 Returns a copy of this LocalizedNumberFormatter.
 LocalizedNumberFormatter (LocalizedNumberFormatter &&src) noexcept
 Move constructor: The source LocalizedNumberFormatter will be left in a valid but undefined state.
LocalizedNumberFormatteroperator= (const LocalizedNumberFormatter &other)
 Copy assignment operator.
LocalizedNumberFormatteroperator= (LocalizedNumberFormatter &&src) noexcept
 Move assignment operator: The source LocalizedNumberFormatter will be left in a valid but undefined state.
void formatImpl (impl::UFormattedNumberData *results, UErrorCode &status) const
 This is the core entrypoint to the number formatting pipeline.
 ~LocalizedNumberFormatter ()
 Destruct this LocalizedNumberFormatter, cleaning up any memory it might own.

Friends

class NumberFormatterSettings< UnlocalizedNumberFormatter >
class NumberFormatterSettings< LocalizedNumberFormatter >
class UnlocalizedNumberFormatter

Detailed Description

A NumberFormatter that has a locale associated with it; this means .format() methods are available.

Instances of this class are immutable and thread-safe.

See also:
NumberFormatter
Stable:
ICU 60

Definition at line 2514 of file numberformatter.h.


Constructor & Destructor Documentation

Default constructor: puts the formatter into a valid but undefined state.

Stable:
ICU 62

Returns a copy of this LocalizedNumberFormatter.

Stable:
ICU 60

Move constructor: The source LocalizedNumberFormatter will be left in a valid but undefined state.

Stable:
ICU 62

Destruct this LocalizedNumberFormatter, cleaning up any memory it might own.

Stable:
ICU 60

Member Function Documentation

Format the given decimal number to a string using the settings specified in the NumberFormatter fluent setting chain.

The syntax of the unformatted number is a "numeric string" as defined in the Decimal Arithmetic Specification, available at http://speleotrove.com/decimal

Parameters:
valueThe number to format.
statusSet to an ErrorCode if one occurred in the setter chain or during formatting.
Returns:
A FormattedNumber object; call .toString() to get the string.
Stable:
ICU 60
FormattedNumber icu::number::LocalizedNumberFormatter::formatDecimalQuantity ( const impl::DecimalQuantity &  dq,
UErrorCode status 
) const

Internal method.

Internal:
Do not use. This API is for internal use only.

Format the given float or double to a string using the settings specified in the NumberFormatter fluent setting chain.

Parameters:
valueThe number to format.
statusSet to an ErrorCode if one occurred in the setter chain or during formatting.
Returns:
A FormattedNumber object; call .toString() to get the string.
Stable:
ICU 60
void icu::number::LocalizedNumberFormatter::formatImpl ( impl::UFormattedNumberData *  results,
UErrorCode status 
) const

This is the core entrypoint to the number formatting pipeline.

It performs self-regulation: a static code path for the first few calls, and compiling a more efficient data structure if called repeatedly.

This function is very hot, being called in every call to the number formatting pipeline.

Parameters:
resultsThe results object. This method will mutate it to save the results.
status
Internal:
Do not use. This API is for internal use only.

Format the given integer number to a string using the settings specified in the NumberFormatter fluent setting chain.

Parameters:
valueThe number to format.
statusSet to an ErrorCode if one occurred in the setter chain or during formatting.
Returns:
A FormattedNumber object; call .toString() to get the string.
Stable:
ICU 60
void icu::number::LocalizedNumberFormatter::getAffixImpl ( bool  isPrefix,
bool  isNegative,
UnicodeString result,
UErrorCode status 
) const

Internal method for DecimalFormat compatibility.

Internal:
Do not use. This API is for internal use only.

Internal method for testing.

Internal:
Do not use. This API is for internal use only.
const impl::NumberFormatterImpl* icu::number::LocalizedNumberFormatter::getCompiled ( ) const

Internal method for testing.

Internal:
Do not use. This API is for internal use only.
Internal:
Do not use.

This API is for internal use only.

LocalizedNumberFormatter& icu::number::LocalizedNumberFormatter::operator= ( const LocalizedNumberFormatter other)

Copy assignment operator.

Stable:
ICU 62
LocalizedNumberFormatter& icu::number::LocalizedNumberFormatter::operator= ( LocalizedNumberFormatter &&  src)

Move assignment operator: The source LocalizedNumberFormatter will be left in a valid but undefined state.

Stable:
ICU 62

Creates a representation of this LocalizedNumberFormat as an icu::Format, enabling the use of this number formatter with APIs that need an object of that type, such as MessageFormat.

This API is not intended to be used other than for enabling API compatibility. The formatDouble, formatInt, and formatDecimal methods should normally be used when formatting numbers, not the Format object returned by this method.

The caller owns the returned object and must delete it when finished.

Returns:
A Format wrapping this LocalizedNumberFormatter.
Stable:
ICU 62

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