|
ICU 60.2
60.2
|
Format or parse a TimeUnitAmount, using plural rules for the units where available. More...
#include <tmutfmt.h>
Public Member Functions | |
| TimeUnitFormat (UErrorCode &status) | |
| Create TimeUnitFormat with default locale, and full name style. More... | |
| TimeUnitFormat (const Locale &locale, UErrorCode &status) | |
| Create TimeUnitFormat given locale, and full name style. More... | |
| TimeUnitFormat (const Locale &locale, UTimeUnitFormatStyle style, UErrorCode &status) | |
| Create TimeUnitFormat given locale and style. More... | |
| TimeUnitFormat (const TimeUnitFormat &) | |
| Copy constructor. More... | |
| virtual | ~TimeUnitFormat () |
| deconstructor More... | |
| virtual Format * | clone (void) const |
| Clone this Format object polymorphically. More... | |
| TimeUnitFormat & | operator= (const TimeUnitFormat &other) |
| Assignment operator. More... | |
| UBool | operator!= (const Format &other) const |
| Return true if the given Format objects are not semantically equal. More... | |
| void | setLocale (const Locale &locale, UErrorCode &status) |
| Set the locale used for formatting or parsing. More... | |
| void | setNumberFormat (const NumberFormat &format, UErrorCode &status) |
| Set the number format used for formatting or parsing. More... | |
| virtual void | parseObject (const UnicodeString &source, Formattable &result, ParsePosition &pos) const |
| Parse a TimeUnitAmount. More... | |
| virtual UClassID | getDynamicClassID (void) const |
| Returns a unique class ID POLYMORPHICALLY. More... | |
Public Member Functions inherited from icu::MeasureFormat | |
| MeasureFormat (const Locale &locale, UMeasureFormatWidth width, UErrorCode &status) | |
| Constructor. More... | |
| MeasureFormat (const Locale &locale, UMeasureFormatWidth width, NumberFormat *nfToAdopt, UErrorCode &status) | |
| Constructor. More... | |
| MeasureFormat (const MeasureFormat &other) | |
| Copy constructor. More... | |
| MeasureFormat & | operator= (const MeasureFormat &rhs) |
| Assignment operator. More... | |
| virtual | ~MeasureFormat () |
| Destructor. More... | |
| virtual UBool | operator== (const Format &other) const |
| Return true if given Format objects are semantically equal. More... | |
| virtual UnicodeString & | format (const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const |
| Formats object to produce a string. More... | |
| UnicodeString & | formatMeasures (const Measure *measures, int32_t measureCount, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const |
| Formats measure objects to produce a string. More... | |
| UnicodeString & | formatMeasurePerUnit (const Measure &measure, const MeasureUnit &perUnit, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const |
| Formats a single measure per unit. More... | |
| UnicodeString | getUnitDisplayName (const MeasureUnit &unit, UErrorCode &status) const |
| Gets the display name of the specified MeasureUnit corresponding to the current locale and format width. More... | |
Public Member Functions inherited from icu::Format | |
| virtual | ~Format () |
| Destructor. More... | |
| UBool | operator!= (const Format &other) const |
| Return true if the given Format objects are not semantically equal. More... | |
| UnicodeString & | format (const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const |
| Formats an object to produce a string. More... | |
| virtual UnicodeString & | format (const Formattable &obj, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const |
| Format an object to produce a string. More... | |
| void | parseObject (const UnicodeString &source, Formattable &result, UErrorCode &status) const |
| Parses a string to produce an object. More... | |
| Locale | getLocale (ULocDataLocaleType type, UErrorCode &status) const |
| Get the locale for this format object. More... | |
| const char * | getLocaleID (ULocDataLocaleType type, UErrorCode &status) const |
| Get the locale for this format object. More... | |
Public Member Functions inherited from icu::UObject | |
| virtual | ~UObject () |
| Destructor. More... | |
Static Public Member Functions | |
| static UClassID | getStaticClassID (void) |
| Return the class ID for this class. More... | |
Static Public Member Functions inherited from icu::MeasureFormat | |
| static MeasureFormat * | createCurrencyFormat (const Locale &locale, UErrorCode &ec) |
| Return a formatter for CurrencyAmount objects in the given locale. More... | |
| static MeasureFormat * | createCurrencyFormat (UErrorCode &ec) |
| Return a formatter for CurrencyAmount objects in the default locale. More... | |
| static UClassID | getStaticClassID (void) |
| Return the class ID for this class. More... | |
Friends | |
| struct | TimeUnitFormatReadSink |
Additional Inherited Members | |
Protected Member Functions inherited from icu::MeasureFormat | |
| MeasureFormat () | |
| Default constructor. More... | |
| void | initMeasureFormat (const Locale &locale, UMeasureFormatWidth width, NumberFormat *nfToAdopt, UErrorCode &status) |
| ICU use only. More... | |
| UBool | setMeasureFormatLocale (const Locale &locale, UErrorCode &status) |
| ICU use only. More... | |
| void | adoptNumberFormat (NumberFormat *nfToAdopt, UErrorCode &status) |
| ICU use only. More... | |
| const NumberFormat & | getNumberFormat () const |
| ICU use only. More... | |
| const PluralRules & | getPluralRules () const |
| ICU use only. More... | |
| Locale | getLocale (UErrorCode &status) const |
| ICU use only. More... | |
| const char * | getLocaleID (UErrorCode &status) const |
| ICU use only. More... | |
Protected Member Functions inherited from icu::Format | |
| void | setLocaleIDs (const char *valid, const char *actual) |
| Format () | |
| Default constructor for subclass use only. More... | |
| Format (const Format &) | |
| Format & | operator= (const Format &) |
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. More... | |
Format or parse a TimeUnitAmount, using plural rules for the units where available.
Code Sample:
// create time unit amount instance - a combination of Number and time unit UErrorCode status = U_ZERO_ERROR; TimeUnitAmount* source = new TimeUnitAmount(2, TimeUnit::UTIMEUNIT_YEAR, status); // create time unit format instance TimeUnitFormat* format = new TimeUnitFormat(Locale("en"), status); // format a time unit amount UnicodeString formatted; Formattable formattable; if (U_SUCCESS(status)) { formattable.adoptObject(source); formatted = ((Format*)format)->format(formattable, formatted, status); Formattable result; ((Format*)format)->parseObject(formatted, result, status); if (U_SUCCESS(status)) { assert (result == formattable); } }
| icu::TimeUnitFormat::TimeUnitFormat | ( | UErrorCode & | status | ) |
Create TimeUnitFormat with default locale, and full name style.
Use setLocale and/or setFormat to modify.
| icu::TimeUnitFormat::TimeUnitFormat | ( | const Locale & | locale, |
| UErrorCode & | status | ||
| ) |
Create TimeUnitFormat given locale, and full name style.
| icu::TimeUnitFormat::TimeUnitFormat | ( | const Locale & | locale, |
| UTimeUnitFormatStyle | style, | ||
| UErrorCode & | status | ||
| ) |
Create TimeUnitFormat given locale and style.
| icu::TimeUnitFormat::TimeUnitFormat | ( | const TimeUnitFormat & | ) |
Copy constructor.
|
virtual |
deconstructor
|
virtual |
Clone this Format object polymorphically.
The caller owns the result and should delete it when done.
Reimplemented from icu::MeasureFormat.
|
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::MeasureFormat.
|
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()) ...
Return true if the given Format objects are not semantically equal.
Objects of different subclasses are considered unequal.
| other | the object to be compared with. |
Definition at line 238 of file tmutfmt.h.
References icu::MeasureFormat::operator==(), and U_NAMESPACE_END.
| TimeUnitFormat& icu::TimeUnitFormat::operator= | ( | const TimeUnitFormat & | other | ) |
Assignment operator.
|
virtual |
| void icu::TimeUnitFormat::setLocale | ( | const Locale & | locale, |
| UErrorCode & | status | ||
| ) |
Set the locale used for formatting or parsing.
| locale | the locale to be set |
| status | output param set to success/failure code on exit |
| void icu::TimeUnitFormat::setNumberFormat | ( | const NumberFormat & | format, |
| UErrorCode & | status | ||
| ) |
Set the number format used for formatting or parsing.
| format | the number formatter to be set |
| status | output param set to success/failure code on exit |
1.8.11