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 U_SHOW_CPLUSPLUS_API
00022
00023 #if !UCONFIG_NO_FORMATTING
00024
00025 #include "unicode/unistr.h"
00026 #include "unicode/tmunit.h"
00027 #include "unicode/tmutamt.h"
00028 #include "unicode/measfmt.h"
00029 #include "unicode/numfmt.h"
00030 #include "unicode/plurrule.h"
00031
00032 #ifndef U_HIDE_DEPRECATED_API
00033
00041 enum UTimeUnitFormatStyle {
00043 UTMUTFMT_FULL_STYLE,
00045 UTMUTFMT_ABBREVIATED_STYLE,
00047 UTMUTFMT_FORMAT_STYLE_COUNT
00048 };
00049 typedef enum UTimeUnitFormatStyle UTimeUnitFormatStyle;
00052 U_NAMESPACE_BEGIN
00053
00054 class Hashtable;
00055 class UVector;
00056
00057 struct TimeUnitFormatReadSink;
00058
00089 class U_I18N_API TimeUnitFormat: public MeasureFormat {
00090 public:
00091
00097 TimeUnitFormat(UErrorCode& status);
00098
00103 TimeUnitFormat(const Locale& locale, UErrorCode& status);
00104
00109 TimeUnitFormat(const Locale& locale, UTimeUnitFormatStyle style, UErrorCode& status);
00110
00115 TimeUnitFormat(const TimeUnitFormat&);
00116
00121 virtual ~TimeUnitFormat();
00122
00129 virtual TimeUnitFormat* clone() const;
00130
00135 TimeUnitFormat& operator=(const TimeUnitFormat& other);
00136
00144 UBool operator!=(const Format& other) const;
00145
00152 void setLocale(const Locale& locale, UErrorCode& status);
00153
00154
00161 void setNumberFormat(const NumberFormat& format, UErrorCode& status);
00162
00168 virtual void parseObject(const UnicodeString& source,
00169 Formattable& result,
00170 ParsePosition& pos) const;
00171
00183 static UClassID U_EXPORT2 getStaticClassID(void);
00184
00196 virtual UClassID getDynamicClassID(void) const;
00197
00198 private:
00199 Hashtable* fTimeUnitToCountToPatterns[TimeUnit::UTIMEUNIT_FIELD_COUNT];
00200 UTimeUnitFormatStyle fStyle;
00201
00202 void create(UTimeUnitFormatStyle style, UErrorCode& status);
00203
00204
00205
00206 void setup(UErrorCode& status);
00207
00208
00209 void initDataMembers(UErrorCode& status);
00210
00211
00212 void readFromCurrentLocale(UTimeUnitFormatStyle style, const char* key, const UVector& pluralCounts,
00213 UErrorCode& status);
00214
00215
00216
00217 void checkConsistency(UTimeUnitFormatStyle style, const char* key, UErrorCode& status);
00218
00219
00220 void searchInLocaleChain(UTimeUnitFormatStyle style, const char* key, const char* localeName,
00221 TimeUnit::UTimeUnitFields field, const UnicodeString&,
00222 const char*, Hashtable*, UErrorCode&);
00223
00224
00225 Hashtable* initHash(UErrorCode& status);
00226
00227
00228 void deleteHash(Hashtable* htable);
00229
00230
00231 void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
00232
00233
00234 static const char* getTimeUnitName(TimeUnit::UTimeUnitFields field, UErrorCode& status);
00235
00236 friend struct TimeUnitFormatReadSink;
00237 };
00238
00239 inline UBool
00240 TimeUnitFormat::operator!=(const Format& other) const {
00241 return !operator==(other);
00242 }
00243
00244 U_NAMESPACE_END
00245
00246 #endif
00247 #endif
00248
00249 #endif
00250
00251 #endif // __TMUTFMT_H__
00252