#include <measfmt.h>
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 & | formatMeasurePerUnit (const Measure &measure, const MeasureUnit &perUnit, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const |
| Formats a single measure per unit. | |
| UnicodeString | getUnitDisplayName (const MeasureUnit &unit, UErrorCode &status) const |
| Gets the display name of the specified MeasureUnit corresponding to the current locale and format width. | |
| virtual UClassID | getDynamicClassID (void) const |
| Returns a unique class ID POLYMORPHICALLY. | |
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. | |
IMPORTANT: New users are strongly encouraged to see if numberformatter.h fits their use case. Although not deprecated, this header is provided for backwards compatibility only.
Definition at line 98 of file measfmt.h.
| icu::MeasureFormat::MeasureFormat | ( | const Locale & | locale, | |
| UMeasureFormatWidth | width, | |||
| UErrorCode & | status | |||
| ) |
Constructor.
NOTE: New users are strongly encouraged to use icu::number::NumberFormatter instead of NumberFormat.
| icu::MeasureFormat::MeasureFormat | ( | const Locale & | locale, | |
| UMeasureFormatWidth | width, | |||
| NumberFormat * | nfToAdopt, | |||
| UErrorCode & | status | |||
| ) |
Constructor.
NOTE: New users are strongly encouraged to use icu::number::NumberFormatter instead of NumberFormat.
| icu::MeasureFormat::MeasureFormat | ( | const MeasureFormat & | other | ) |
Copy constructor.
| virtual icu::MeasureFormat::~MeasureFormat | ( | ) | [virtual] |
Destructor.
| icu::MeasureFormat::MeasureFormat | ( | ) | [protected] |
Default constructor.
| void icu::MeasureFormat::adoptNumberFormat | ( | NumberFormat * | nfToAdopt, | |
| UErrorCode & | status | |||
| ) | [protected] |
ICU use only.
Let subclass change NumberFormat.
| virtual Format* icu::MeasureFormat::clone | ( | ) | const [virtual] |
Clones this object polymorphically.
Implements icu::Format.
Reimplemented in icu::TimeUnitFormat.
| static MeasureFormat* icu::MeasureFormat::createCurrencyFormat | ( | UErrorCode & | ec | ) | [static] |
Return a formatter for CurrencyAmount objects in the default locale.
NOTE: New users are strongly encouraged to use icu::number::NumberFormatter instead of NumberFormat.
| ec | input-output error code |
| static MeasureFormat* icu::MeasureFormat::createCurrencyFormat | ( | const Locale & | locale, | |
| UErrorCode & | ec | |||
| ) | [static] |
Return a formatter for CurrencyAmount objects in the given locale.
NOTE: New users are strongly encouraged to use icu::number::NumberFormatter instead of NumberFormat.
| locale | desired locale | |
| ec | input-output error code |
| virtual UnicodeString& icu::MeasureFormat::format | ( | const Formattable & | obj, | |
| UnicodeString & | appendTo, | |||
| FieldPosition & | pos, | |||
| UErrorCode & | status | |||
| ) | const [virtual] |
| UnicodeString& icu::MeasureFormat::formatMeasurePerUnit | ( | const Measure & | measure, | |
| const MeasureUnit & | perUnit, | |||
| UnicodeString & | appendTo, | |||
| FieldPosition & | pos, | |||
| UErrorCode & | status | |||
| ) | const |
Formats a single measure per unit.
An example of such a formatted string is 3.5 meters per second.
| measure | The measure object. In above example, 3.5 meters. | |
| perUnit | The per unit. In above example, it is `*MeasureUnitcreateSecond(status)`. | |
| appendTo | formatted string appended here. | |
| pos | the field position. | |
| status | the error. |
| 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.
| measures | array of measure objects. | |
| measureCount | the number of measure objects. | |
| appendTo | formatted string appended here. | |
| pos | the field position. | |
| status | the error. |
| 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.
Reimplemented from icu::UObject.
Reimplemented in icu::TimeUnitFormat.
| Locale icu::MeasureFormat::getLocale | ( | UErrorCode & | status | ) | const [protected] |
ICU use only.
| const char* icu::MeasureFormat::getLocaleID | ( | UErrorCode & | status | ) | const [protected] |
ICU use only.
| const NumberFormat& icu::MeasureFormat::getNumberFormat | ( | ) | const [protected] |
ICU use only.
| const PluralRules& icu::MeasureFormat::getPluralRules | ( | ) | const [protected] |
ICU 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()) ...
Reimplemented in icu::TimeUnitFormat.
| UnicodeString icu::MeasureFormat::getUnitDisplayName | ( | const MeasureUnit & | unit, | |
| UErrorCode & | status | |||
| ) | const |
Gets the display name of the specified MeasureUnit corresponding to the current locale and format width.
| unit | The unit for which to get a display name. | |
| status | the error. |
| void icu::MeasureFormat::initMeasureFormat | ( | const Locale & | locale, | |
| UMeasureFormatWidth | width, | |||
| NumberFormat * | nfToAdopt, | |||
| UErrorCode & | status | |||
| ) | [protected] |
ICU use only.
Initialize or change MeasureFormat class from subclass.
| MeasureFormat& icu::MeasureFormat::operator= | ( | const MeasureFormat & | rhs | ) |
Assignment operator.
Reimplemented from icu::Format.
Reimplemented in icu::TimeUnitFormat.
Return true if given Format objects are semantically equal.
Referenced by icu::TimeUnitFormat::operator!=().
| 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.
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.
1.6.1