ICU 54.1 54.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Data Structure Index
- Class Hierarchy
- Data Fields

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions
icu::MeasureFormat Class Reference

A formatter for measure objects. More...

`#include <measfmt.h>`

Inheritance diagram for icu::MeasureFormat:

## Public Member Functions
| MeasureFormat (const Locale &locale, UMeasureFormatWidth width, UErrorCode &status)
| Constructor.
| MeasureFormat (const Locale &locale, UMeasureFormatWidth width, NumberFormat *nfToAdopt, UErrorCode &status)
| Constructor.
| MeasureFormat (const MeasureFormat &other)
| Copy constructor.
MeasureFormat & | operator= (const MeasureFormat &rhs)
| Assignment operator.
virtual | ~MeasureFormat ()
| Destructor.
virtual UBool | operator== (const Format &other) const
| Return true if given Format objects are semantically equal.
virtual Format * | clone () const
| Clones this object polymorphically.
virtual UnicodeString & | format (const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
| Formats object to produce a string.
virtual void | parseObject (const UnicodeString &source, Formattable &reslt, ParsePosition &pos) const
| Parse a string to produce an object.
UnicodeString & | formatMeasures (const Measure *measures, int32_t measureCount, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
| Formats measure objects to produce a string.
UnicodeString & | formatMeasuresPer (const Measure *measures, int32_t measureCount, const MeasureUnit &perUnit, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
| Works like formatMeasures but adds a per unit.
virtual UClassID | getDynamicClassID (void) const
| Returns a unique class ID POLYMORPHICALLY.
Public Member Functions inherited from icu::Format
virtual | ~Format ()
| Destructor.
UBool | operator!= (const Format &other) const
| Return true if the given Format objects are not semantically equal.
UnicodeString & | format (const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
| Formats an object to produce a string.
virtual UnicodeString & | format (const Formattable &obj, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
| Format an object to produce a string.
void | parseObject (const UnicodeString &source, Formattable &result, UErrorCode &status) const
| Parses a string to produce an object.
Locale | getLocale (ULocDataLocaleType type, UErrorCode &status) const
| Get the locale for this format object.
const char * | getLocaleID (ULocDataLocaleType type, UErrorCode &status) const
| Get the locale for this format object.
Public Member Functions inherited from icu::UObject
virtual | ~UObject ()
| Destructor.

## Static Public Member Functions
static MeasureFormat * | createCurrencyFormat (const Locale &locale, UErrorCode &ec)
| Return a formatter for CurrencyAmount objects in the given locale.
static MeasureFormat * | createCurrencyFormat (UErrorCode &ec)
| Return a formatter for CurrencyAmount objects in the default locale.
static UClassID | getStaticClassID (void)
| Return the class ID for this class.

## Protected Member Functions
| MeasureFormat ()
| Default constructor.
void | initMeasureFormat (const Locale &locale, UMeasureFormatWidth width, NumberFormat *nfToAdopt, UErrorCode &status)
| ICU use only.
UBool | setMeasureFormatLocale (const Locale &locale, UErrorCode &status)
| ICU use only.
void | adoptNumberFormat (NumberFormat *nfToAdopt, UErrorCode &status)
| ICU use only.
const NumberFormat & | getNumberFormat () const
| ICU use only.
const PluralRules & | getPluralRules () const
| ICU use only.
Locale | getLocale (UErrorCode &status) const
| ICU use only.
const char * | getLocaleID (UErrorCode &status) const
| ICU use only.
Protected Member Functions inherited from icu::Format
void | setLocaleIDs (const char *valid, const char *actual)
| Format ()
| Default constructor for subclass use only.
| Format (const Format &)
Format & | operator= (const Format &)

## Additional Inherited Members
Static Protected Member Functions inherited from icu::Format
static void | syntaxError (const UnicodeString &pattern, int32_t pos, UParseError &parseError)
| Simple function for initializing a UParseError from a UnicodeString.

## Detailed Description

A formatter for measure objects.

See Also
  Format

Author
  Alan Liu

Stable:
  ICU 3.0

Definition at line 95 of file measfmt.h.

## Constructor & Destructor Documentation

icu::MeasureFormat::MeasureFormat | ( | const Locale & | locale,
|  | UMeasureFormatWidth | width,
|  | UErrorCode & | status
| ) |  |

Constructor.

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

icu::MeasureFormat::MeasureFormat | ( | const Locale & | locale,
|  | UMeasureFormatWidth | width,
|  | NumberFormat * | nfToAdopt,
|  | UErrorCode & | status
| ) |  |

Constructor.

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

icu::MeasureFormat::MeasureFormat | ( | const MeasureFormat & | other | ) |

Copy constructor.

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

virtual icu::MeasureFormat::~MeasureFormat | ( |  | ) |
| virtual

Destructor.

Stable:
  ICU 3.0

icu::MeasureFormat::MeasureFormat | ( |  | ) |
| protected

Default constructor.

Stable:
  ICU 3.0

## Member Function Documentation

void icu::MeasureFormat::adoptNumberFormat | ( | NumberFormat * | nfToAdopt,
|  | UErrorCode & | status
| ) |  |
| protected

ICU use only.

Let subclass change NumberFormat.

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

virtual Format* icu::MeasureFormat::clone | ( |  | ) | const
| virtual

Clones this object polymorphically.

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

Implements icu::Format.

Reimplemented in icu::TimeUnitFormat.

static MeasureFormat* icu::MeasureFormat::createCurrencyFormat | ( | const Locale & | locale,
|  | UErrorCode & | ec
| ) |  |
| static

Return a formatter for CurrencyAmount objects in the given locale.

Parameters

  locale | desired locale
  ec | input-output error code

Returns
  a formatter object, or NULL upon error

Stable:
  ICU 3.0

static MeasureFormat* icu::MeasureFormat::createCurrencyFormat | ( | UErrorCode & | ec | ) |
| static

Return a formatter for CurrencyAmount objects in the default locale.

Parameters

  ec | input-output error code

Returns
  a formatter object, or NULL upon error

Stable:
  ICU 3.0

virtual UnicodeString& icu::MeasureFormat::format | ( | const Formattable & | obj,
|  | UnicodeString & | appendTo,
|  | FieldPosition & | pos,
|  | UErrorCode & | status
| ) |  | const
| virtual

Formats object to produce a string.

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

Implements icu::Format.

UnicodeString& icu::MeasureFormat::formatMeasures | ( | const Measure * | measures,
|  | int32_t | measureCount,
|  | UnicodeString & | appendTo,
|  | FieldPosition & | pos,
|  | UErrorCode & | status
| ) |  | const

Formats measure objects to produce a string.

An example of such a formatted string is 3 meters, 3.5 centimeters. Measure objects appear in the formatted string in the same order they appear in the "measures" array. The NumberFormat of this object is used only to format the amount of the very last measure. The other amounts are formatted with zero decimal places while rounding toward zero.

Parameters

  measures | array of measure objects.
  measureCount | the number of measure objects.
  appendTo | formatted string appended here.
  pos | the field position.
  status | the error.

Returns
  appendTo reference

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

UnicodeString& icu::MeasureFormat::formatMeasuresPer | ( | const Measure * | measures,
|  | int32_t | measureCount,
|  | const MeasureUnit & | perUnit,
|  | UnicodeString & | appendTo,
|  | FieldPosition & | pos,
|  | UErrorCode & | status
| ) |  | const

Works like formatMeasures but adds a per unit.

An example of such a formatted string is 3 meters, 3.5 centimeters per second.

Parameters

  measures | array of measure objects.
  measureCount | the number of measure objects.
  perUnit | The per unit. In the example formatted string, it is *MeasureUnit::createSecond(status).
  appendTo | formatted string appended here.
  pos | the field position.
  status | the error.

Returns
  appendTo reference

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

virtual UClassID icu::MeasureFormat::getDynamicClassID | ( | void |  | ) | const
| virtual

Returns a unique class ID POLYMORPHICALLY.

Pure virtual override. This method is to implement a simple version of RTTI, since not all C++ compilers support genuine RTTI. Polymorphic operator==() and clone() methods call this method.

Returns
  The class ID for this object. All objects of a given class have the same class ID. Objects of other classes have different class IDs.

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

Reimplemented from icu::UObject.

Reimplemented in icu::TimeUnitFormat.

Locale icu::MeasureFormat::getLocale | ( | UErrorCode & | status | ) | const
| protected

ICU use only.

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

const char* icu::MeasureFormat::getLocaleID | ( | UErrorCode & | status | ) | const
| protected

ICU use only.

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

const NumberFormat& icu::MeasureFormat::getNumberFormat | ( |  | ) | const
| protected

ICU use only.

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

const PluralRules& icu::MeasureFormat::getPluralRules | ( |  | ) | const
| protected

ICU use only.

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

static UClassID icu::MeasureFormat::getStaticClassID | ( | void |  | ) |
| static

Return the class ID for this class.

This is useful only for comparing to a return value from getDynamicClassID(). For example:

    .   Base* polymorphic_pointer = createPolymorphicObject();
    .   if (polymorphic_pointer->getDynamicClassID() ==
    .       erived::getStaticClassID()) ...

Returns
  The class ID for all objects of this class.

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

Reimplemented in icu::TimeUnitFormat.

void icu::MeasureFormat::initMeasureFormat | ( | const Locale & | locale,
|  | UMeasureFormatWidth | width,
|  | NumberFormat * | nfToAdopt,
|  | UErrorCode & | status
| ) |  |
| protected

ICU use only.

Initialize or change MeasureFormat class from subclass.

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

MeasureFormat& icu::MeasureFormat::operator= | ( | const MeasureFormat & | rhs | ) |

Assignment operator.

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

virtual UBool icu::MeasureFormat::operator== | ( | const Format & | other | ) | const
| virtual

Return true if given Format objects are semantically equal.

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

Implements icu::Format.

virtual void icu::MeasureFormat::parseObject | ( | const UnicodeString & | source,
|  | Formattable & | reslt,
|  | ParsePosition & | pos
| ) |  | const
| virtual

Parse a string to produce an object.

This implementation sets status to U_UNSUPPORTED_ERROR.

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

Implements icu::Format.

Reimplemented in icu::TimeUnitFormat.

UBool icu::MeasureFormat::setMeasureFormatLocale | ( | const Locale & | locale,
|  | UErrorCode & | status
| ) |  |
| protected

ICU use only.

Allows subclass to change locale. Note that this method also changes the NumberFormat object. Returns TRUE if locale changed; FALSE if no change was made.

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

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

- measfmt.h