/** * Constants for various styles. * There are 2 styles: full name and abbreviated name. * For example, for English, the full name for hour duration is "3 hours", * and the abbreviated name is "3 hrs". * @deprecated ICU 53 Use MeasureFormat and UMeasureFormatWidth instead.
*/ enum UTimeUnitFormatStyle { /** @deprecated ICU 53 */
UTMUTFMT_FULL_STYLE, /** @deprecated ICU 53 */
UTMUTFMT_ABBREVIATED_STYLE, /** @deprecated ICU 53 */
UTMUTFMT_FORMAT_STYLE_COUNT
}; typedefenum UTimeUnitFormatStyle UTimeUnitFormatStyle; /**< @deprecated ICU 53 */
U_NAMESPACE_BEGIN
class Hashtable; class UVector;
struct TimeUnitFormatReadSink;
/** * Format or parse a TimeUnitAmount, using plural rules for the units where available. * * <P> * Code Sample: * <pre> * // 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); * } * } * </pre> * * <P> * @see TimeUnitAmount * @see TimeUnitFormat * @deprecated ICU 53 Use the MeasureFormat class instead.
*/ class U_I18N_API TimeUnitFormat: public MeasureFormat { public:
/** * Create TimeUnitFormat with default locale, and full name style. * Use setLocale and/or setFormat to modify. * @deprecated ICU 53
*/
TimeUnitFormat(UErrorCode& status);
/** * Create TimeUnitFormat given locale, and full name style. * @deprecated ICU 53
*/
TimeUnitFormat(const Locale& locale, UErrorCode& status);
/** * Create TimeUnitFormat given locale and style. * @deprecated ICU 53
*/
TimeUnitFormat(const Locale& locale, UTimeUnitFormatStyle style, UErrorCode& status);
/** * Clone this Format object polymorphically. The caller owns the result and * should delete it when done. * @return A copy of the object. * @deprecated ICU 53
*/ virtual TimeUnitFormat* clone() const override;
/** * Set the locale used for formatting or parsing. * @param locale the locale to be set * @param status output param set to success/failure code on exit * @deprecated ICU 53
*/ void setLocale(const Locale& locale, UErrorCode& status);
/** * Set the number format used for formatting or parsing. * @param format the number formatter to be set * @param status output param set to success/failure code on exit * @deprecated ICU 53
*/ void setNumberFormat(const NumberFormat& format, UErrorCode& status);
/** * Return the class ID for this class. This is useful only for comparing to * a return value from getDynamicClassID(). For example: * <pre> * . Base* polymorphic_pointer = createPolymorphicObject(); * . if (polymorphic_pointer->getDynamicClassID() == * . erived::getStaticClassID()) ... * </pre> * @return The class ID for all objects of this class. * @deprecated ICU 53
*/ static UClassID U_EXPORT2 getStaticClassID();
/** * 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. * * @return 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. * @deprecated ICU 53
*/ virtual UClassID getDynamicClassID() const override;
// it might actually be simpler to make them Decimal Formats later. // initialize all private data members void setup(UErrorCode& status);
// initialize data member without fill in data for fTimeUnitToCountToPattern void initDataMembers(UErrorCode& status);
// initialize fTimeUnitToCountToPatterns from current locale's resource. void readFromCurrentLocale(UTimeUnitFormatStyle style, constchar* key, const UVector& pluralCounts,
UErrorCode& status);
// check completeness of fTimeUnitToCountToPatterns against all time units, // and all plural rules, fill in fallback as necessary. void checkConsistency(UTimeUnitFormatStyle style, constchar* key, UErrorCode& status);
// fill in fTimeUnitToCountToPatterns from locale fall-back chain void searchInLocaleChain(UTimeUnitFormatStyle style, constchar* key, constchar* localeName,
TimeUnit::UTimeUnitFields field, const UnicodeString&, constchar*, Hashtable*, UErrorCode&);
// copy hash table void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status); // get time unit name, such as "year", from time unit field enum, such as // UTIMEUNIT_YEAR. staticconstchar* getTimeUnitName(TimeUnit::UTimeUnitFields field, UErrorCode& status);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.