00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __TMUTFMT_H__
00011 #define __TMUTFMT_H__
00012
00013 #include "unicode/utypes.h"
00014
00021 #if !UCONFIG_NO_FORMATTING
00022 #ifndef U_HIDE_DEPRECATED_API
00023
00024 #include "unicode/unistr.h"
00025 #include "unicode/tmunit.h"
00026 #include "unicode/tmutamt.h"
00027 #include "unicode/measfmt.h"
00028 #include "unicode/numfmt.h"
00029 #include "unicode/plurrule.h"
00030
00031
00039 enum UTimeUnitFormatStyle {
00041 UTMUTFMT_FULL_STYLE,
00043 UTMUTFMT_ABBREVIATED_STYLE,
00045 UTMUTFMT_FORMAT_STYLE_COUNT
00046 };
00047 typedef enum UTimeUnitFormatStyle UTimeUnitFormatStyle;
00050 U_NAMESPACE_BEGIN
00051
00052 class Hashtable;
00053 class UVector;
00054
00055 struct TimeUnitFormatReadSink;
00056
00087 class U_I18N_API TimeUnitFormat: public MeasureFormat {
00088 public:
00089
00095 TimeUnitFormat(UErrorCode& status);
00096
00101 TimeUnitFormat(const Locale& locale, UErrorCode& status);
00102
00107 TimeUnitFormat(const Locale& locale, UTimeUnitFormatStyle style, UErrorCode& status);
00108
00113 TimeUnitFormat(const TimeUnitFormat&);
00114
00119 virtual ~TimeUnitFormat();
00120
00127 virtual Format* clone(void) const;
00128
00133 TimeUnitFormat& operator=(const TimeUnitFormat& other);
00134
00142 UBool operator!=(const Format& other) const;
00143
00150 void setLocale(const Locale& locale, UErrorCode& status);
00151
00152
00159 void setNumberFormat(const NumberFormat& format, UErrorCode& status);
00160
00166 virtual void parseObject(const UnicodeString& source,
00167 Formattable& result,
00168 ParsePosition& pos) const;
00169
00181 static UClassID U_EXPORT2 getStaticClassID(void);
00182
00194 virtual UClassID getDynamicClassID(void) const;
00195
00196 private:
00197 Hashtable* fTimeUnitToCountToPatterns[TimeUnit::UTIMEUNIT_FIELD_COUNT];
00198 UTimeUnitFormatStyle fStyle;
00199
00200 void create(UTimeUnitFormatStyle style, UErrorCode& status);
00201
00202
00203
00204 void setup(UErrorCode& status);
00205
00206
00207 void initDataMembers(UErrorCode& status);
00208
00209
00210 void readFromCurrentLocale(UTimeUnitFormatStyle style, const char* key, const UVector& pluralCounts,
00211 UErrorCode& status);
00212
00213
00214
00215 void checkConsistency(UTimeUnitFormatStyle style, const char* key, UErrorCode& status);
00216
00217
00218 void searchInLocaleChain(UTimeUnitFormatStyle style, const char* key, const char* localeName,
00219 TimeUnit::UTimeUnitFields field, const UnicodeString&,
00220 const char*, Hashtable*, UErrorCode&);
00221
00222
00223 Hashtable* initHash(UErrorCode& status);
00224
00225
00226 void deleteHash(Hashtable* htable);
00227
00228
00229 void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
00230
00231
00232 static const char* getTimeUnitName(TimeUnit::UTimeUnitFields field, UErrorCode& status);
00233
00234 friend struct TimeUnitFormatReadSink;
00235 };
00236
00237 inline UBool
00238 TimeUnitFormat::operator!=(const Format& other) const {
00239 return !operator==(other);
00240 }
00241
00242 U_NAMESPACE_END
00243
00244 #endif
00245 #endif
00246
00247 #endif // __TMUTFMT_H__
00248