ICU 56.1: tmutfmt.h Source File

ICU 56.1 56.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

tmutfmt.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 * Copyright (C) 2008-2014, Google, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 *******************************************************************************
6 */
7
8 #ifndef __TMUTFMT_H__
9 #define __TMUTFMT_H__
10
11 #include "unicode/utypes.h"
12
19 #if !UCONFIG_NO_FORMATTING
20 #ifndef U_HIDE_DEPRECATED_API
21
22 #include "unicode/unistr.h"
23 #include "unicode/tmunit.h"
24 #include "unicode/tmutamt.h"
25 #include "unicode/measfmt.h"
26 #include "unicode/numfmt.h"
27 #include "unicode/plurrule.h"
28
29
37 enum UTimeUnitFormatStyle {
39 UTMUTFMT_FULL_STYLE,
41 UTMUTFMT_ABBREVIATED_STYLE,
43 UTMUTFMT_FORMAT_STYLE_COUNT
44 };
45 typedef enum UTimeUnitFormatStyle UTimeUnitFormatStyle;
48 U_NAMESPACE_BEGIN
49
50 class Hashtable;
51 class UVector;
52
83 class U_I18N_API TimeUnitFormat: public MeasureFormat {
84 public:
85
91 TimeUnitFormat(UErrorCode& status);
92
97 TimeUnitFormat(const Locale& locale, UErrorCode& status);
98
103 TimeUnitFormat(const Locale& locale, UTimeUnitFormatStyle style, UErrorCode& status);
104
109 TimeUnitFormat(const TimeUnitFormat&);
110
115 virtual ~TimeUnitFormat();
116
123 virtual Format* clone(void) const;
124
129 TimeUnitFormat& operator=(const TimeUnitFormat& other);
130
138 UBool operator!=(const Format& other) const;
139
146 void setLocale(const Locale& locale, UErrorCode& status);
147
148
155 void setNumberFormat(const NumberFormat& format, UErrorCode& status);
156
162 virtual void parseObject(const UnicodeString& source,
163 Formattable& result,
164 ParsePosition& pos) const;
165
177 static UClassID U_EXPORT2 getStaticClassID(void);
178
190 virtual UClassID getDynamicClassID(void) const;
191
192 private:
193 Hashtable* fTimeUnitToCountToPatterns[TimeUnit::UTIMEUNIT_FIELD_COUNT];
194 UTimeUnitFormatStyle fStyle;
195
196 void create(UTimeUnitFormatStyle style, UErrorCode& status);
197
198 // it might actually be simpler to make them Decimal Formats later.
199 // initialize all private data members
200 void setup(UErrorCode& status);
201
202 // initialize data member without fill in data for fTimeUnitToCountToPattern
203 void initDataMembers(UErrorCode& status);
204
205 // initialize fTimeUnitToCountToPatterns from current locale's resource.
206 void readFromCurrentLocale(UTimeUnitFormatStyle style, const char* key, const UVector& pluralCounts,
207 UErrorCode& status);
208
209 // check completeness of fTimeUnitToCountToPatterns against all time units,
210 // and all plural rules, fill in fallback as necessary.
211 void checkConsistency(UTimeUnitFormatStyle style, const char* key, UErrorCode& status);
212
213 // fill in fTimeUnitToCountToPatterns from locale fall-back chain
214 void searchInLocaleChain(UTimeUnitFormatStyle style, const char* key, const char* localeName,
215 TimeUnit::UTimeUnitFields field, const UnicodeString&,
216 const char*, Hashtable*, UErrorCode&);
217
218 // initialize hash table
219 Hashtable* initHash(UErrorCode& status);
220
221 // delete hash table
222 void deleteHash(Hashtable* htable);
223
224 // copy hash table
225 void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
226 // get time unit name, such as "year", from time unit field enum, such as
227 // UTIMEUNIT_YEAR.
228 static const char* getTimeUnitName(TimeUnit::UTimeUnitFields field, UErrorCode& status);
229
230 };
231
232 inline UBool
233 TimeUnitFormat::operator!=(const Format& other) const {
234 return !operator==(other);
235 }
236
237 U_NAMESPACE_END
238
239 #endif /* U_HIDE_DEPRECATED_API */
240 #endif /* #if !UCONFIG_NO_FORMATTING */
241
242 #endif // __TMUTFMT_H__
243 //eof
icu::TimeUnitFormat
Format or parse a TimeUnitAmount, using plural rules for the units where available.
Definition: tmutfmt.h:83
icu::Format
Base class for all formats.
Definition: format.h:94
icu::TimeUnit::UTimeUnitFields
UTimeUnitFields
Constants for all the time units we supported.
Definition: tmunit.h:36
icu::MeasureFormat::getStaticClassID
static UClassID getStaticClassID(void)
Return the class ID for this class.
icu::MeasureFormat::getDynamicClassID
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
icu::MeasureFormat
A formatter for measure objects.
Definition: measfmt.h:93
icu::NumberFormat
Abstract base class for all number formats.
Definition: numfmt.h:172
unistr.h
C++ API: Unicode String.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
icu::MeasureFormat::operator=
MeasureFormat & operator=(const MeasureFormat &rhs)
Assignment operator.
plurrule.h
C++ API: PluralRules object.
tmunit.h
C++ API: time unit object.
UTMUTFMT_ABBREVIATED_STYLE
Definition: tmutfmt.h:41
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:358
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
UTimeUnitFormatStyle
UTimeUnitFormatStyle
Constants for various styles.
Definition: tmutfmt.h:37
UTMUTFMT_FULL_STYLE
Definition: tmutfmt.h:39
icu::operator!=
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
measfmt.h
C++ API: Formatter for measure objects.
icu::MeasureFormat::clone
virtual Format * clone() const
Clones this object polymorphically.
tmutamt.h
C++ API: time unit amount object.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
icu::ParsePosition
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:47
icu::MeasureFormat::parseObject
virtual void parseObject(const UnicodeString &source, Formattable &reslt, ParsePosition &pos) const
Parse a string to produce an object.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::Format::operator!=
UBool operator!=(const Format &other) const
Return true if the given Format objects are not semantically equal.
Definition: format.h:119
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:293
icu::Formattable
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:66
numfmt.h
C++ API: Abstract base class for all number formats.
UTMUTFMT_FORMAT_STYLE_COUNT
Definition: tmutfmt.h:43
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185