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 #ifndef U_HIDE_DEPRECATED_API
00021
00022 #include "unicode/unistr.h"
00023 #include "unicode/tmunit.h"
00024 #include "unicode/tmutamt.h"
00025 #include "unicode/measfmt.h"
00026 #include "unicode/numfmt.h"
00027 #include "unicode/plurrule.h"
00028
00029
00037 enum UTimeUnitFormatStyle {
00039 UTMUTFMT_FULL_STYLE,
00041 UTMUTFMT_ABBREVIATED_STYLE,
00043 UTMUTFMT_FORMAT_STYLE_COUNT
00044 };
00045 typedef enum UTimeUnitFormatStyle UTimeUnitFormatStyle;
00048 U_NAMESPACE_BEGIN
00049
00050 class Hashtable;
00051 class UVector;
00052
00083 class U_I18N_API TimeUnitFormat: public MeasureFormat {
00084 public:
00085
00091 TimeUnitFormat(UErrorCode& status);
00092
00097 TimeUnitFormat(const Locale& locale, UErrorCode& status);
00098
00103 TimeUnitFormat(const Locale& locale, UTimeUnitFormatStyle style, UErrorCode& status);
00104
00109 TimeUnitFormat(const TimeUnitFormat&);
00110
00115 virtual ~TimeUnitFormat();
00116
00123 virtual Format* clone(void) const;
00124
00129 TimeUnitFormat& operator=(const TimeUnitFormat& other);
00130
00138 UBool operator!=(const Format& other) const;
00139
00146 void setLocale(const Locale& locale, UErrorCode& status);
00147
00148
00155 void setNumberFormat(const NumberFormat& format, UErrorCode& status);
00156
00162 virtual void parseObject(const UnicodeString& source,
00163 Formattable& result,
00164 ParsePosition& pos) const;
00165
00177 static UClassID U_EXPORT2 getStaticClassID(void);
00178
00190 virtual UClassID getDynamicClassID(void) const;
00191
00192 private:
00193 Hashtable* fTimeUnitToCountToPatterns[TimeUnit::UTIMEUNIT_FIELD_COUNT];
00194 UTimeUnitFormatStyle fStyle;
00195
00196 void create(UTimeUnitFormatStyle style, UErrorCode& status);
00197
00198
00199
00200 void setup(UErrorCode& status);
00201
00202
00203 void initDataMembers(UErrorCode& status);
00204
00205
00206 void readFromCurrentLocale(UTimeUnitFormatStyle style, const char* key, const UVector& pluralCounts,
00207 UErrorCode& status);
00208
00209
00210
00211 void checkConsistency(UTimeUnitFormatStyle style, const char* key, UErrorCode& status);
00212
00213
00214 void searchInLocaleChain(UTimeUnitFormatStyle style, const char* key, const char* localeName,
00215 TimeUnit::UTimeUnitFields field, const UnicodeString&,
00216 const char*, Hashtable*, UErrorCode&);
00217
00218
00219 Hashtable* initHash(UErrorCode& status);
00220
00221
00222 void deleteHash(Hashtable* htable);
00223
00224
00225 void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
00226
00227
00228 static const char* getTimeUnitName(TimeUnit::UTimeUnitFields field, UErrorCode& status);
00229
00230 };
00231
00232 inline UBool
00233 TimeUnitFormat::operator!=(const Format& other) const {
00234 return !operator==(other);
00235 }
00236
00237 U_NAMESPACE_END
00238
00239 #endif
00240 #endif
00241
00242 #endif // __TMUTFMT_H__
00243