Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __TMUTFMT_H__
00009 #define __TMUTFMT_H__
00010
00011 #include "unicode/utypes.h"
00012
00019 #if !UCONFIG_NO_FORMATTING
00020
00021 #include "unicode/unistr.h"
00022 #include "unicode/tmunit.h"
00023 #include "unicode/tmutamt.h"
00024 #include "unicode/measfmt.h"
00025 #include "unicode/numfmt.h"
00026 #include "unicode/plurrule.h"
00027
00032 union UHashTok;
00033
00034 U_NAMESPACE_BEGIN
00035
00036 class Hashtable;
00037
00038
00069 class U_I18N_API TimeUnitFormat: public MeasureFormat {
00070 public:
00071
00079 enum EStyle {
00080 kFull = 0,
00081 kAbbreviate = 1,
00082 kTotal = kAbbreviate + 1
00083 };
00084
00090 TimeUnitFormat(UErrorCode& status);
00091
00096 TimeUnitFormat(const Locale& locale, UErrorCode& status);
00097
00102 TimeUnitFormat(const Locale& locale, EStyle style, UErrorCode& status);
00103
00108 TimeUnitFormat(const TimeUnitFormat&);
00109
00114 virtual ~TimeUnitFormat();
00115
00122 virtual Format* clone(void) const;
00123
00128 TimeUnitFormat& operator=(const TimeUnitFormat& other);
00129
00130
00138 virtual UBool operator==(const Format& other) const;
00139
00147 UBool operator!=(const Format& other) const;
00148
00155 void setLocale(const Locale& locale, UErrorCode& status);
00156
00157
00164 void setNumberFormat(const NumberFormat& format, UErrorCode& status);
00165
00166
00167 using MeasureFormat::format;
00168
00177 virtual UnicodeString& format(const Formattable& obj,
00178 UnicodeString& toAppendTo,
00179 FieldPosition& pos,
00180 UErrorCode& status) const;
00181
00187 virtual void parseObject(const UnicodeString& source,
00188 Formattable& result,
00189 ParsePosition& pos) const;
00190
00202 static UClassID U_EXPORT2 getStaticClassID(void);
00203
00215 virtual UClassID getDynamicClassID(void) const;
00216
00217 private:
00218 NumberFormat* fNumberFormat;
00219 Locale fLocale;
00220 Hashtable* fTimeUnitToCountToPatterns[TimeUnit::UTIMEUNIT_FIELD_COUNT];
00221 PluralRules* fPluralRules;
00222 EStyle fStyle;
00223
00224 void create(const Locale& locale, EStyle style, UErrorCode& status);
00225
00226
00227
00228 void setup(UErrorCode& status);
00229
00230
00231 void initDataMembers(UErrorCode& status);
00232
00233
00234 void readFromCurrentLocale(EStyle style, const char* key, UErrorCode& status);
00235
00236
00237
00238 void checkConsistency(EStyle style, const char* key, UErrorCode& status);
00239
00240
00241 void searchInLocaleChain(EStyle style, const char* key, const char* localeName,
00242 TimeUnit::UTimeUnitFields field, const char*,
00243 const char*, Hashtable*, UErrorCode&);
00244
00245
00246 Hashtable* initHash(UErrorCode& status);
00247
00248
00249 void deleteHash(Hashtable* htable);
00250
00251
00252 void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
00253
00254
00255 static const char* getTimeUnitName(TimeUnit::UTimeUnitFields field, UErrorCode& status);
00256 };
00257
00258
00259
00260 inline UBool
00261 TimeUnitFormat::operator!=(const Format& other) const {
00262 return !operator==(other);
00263 }
00264
00265
00266
00267 U_NAMESPACE_END
00268
00269 #endif
00270
00271 #endif // __TMUTFMT_H__
00272