ICU 4.8.1.1
4.8.1.1
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
i18n
unicode
tmutfmt.h
Go to the documentation of this file.
1
/*
2
*******************************************************************************
3
* Copyright (C) 2008-2011, 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
21
#include "
unicode/unistr.h
"
22
#include "
unicode/tmunit.h
"
23
#include "
unicode/tmutamt.h
"
24
#include "
unicode/measfmt.h
"
25
#include "
unicode/numfmt.h
"
26
#include "
unicode/plurrule.h
"
27
35
enum
UTimeUnitFormatStyle
{
37
UTMUTFMT_FULL_STYLE
,
39
UTMUTFMT_ABBREVIATED_STYLE
,
41
UTMUTFMT_FORMAT_STYLE_COUNT
42
};
43
typedef
enum
UTimeUnitFormatStyle
UTimeUnitFormatStyle
;
45
U_NAMESPACE_BEGIN
46
47
class
Hashtable;
48
49
80
class
U_I18N_API
TimeUnitFormat
:
public
MeasureFormat
{
81
public
:
82
88
TimeUnitFormat
(
UErrorCode
& status);
89
94
TimeUnitFormat
(
const
Locale
& locale,
UErrorCode
& status);
95
100
TimeUnitFormat
(
const
Locale
& locale,
UTimeUnitFormatStyle
style,
UErrorCode
& status);
101
106
TimeUnitFormat
(
const
TimeUnitFormat
&);
107
112
virtual
~
TimeUnitFormat
();
113
120
virtual
Format
*
clone
(
void
)
const
;
121
126
TimeUnitFormat
&
operator=
(
const
TimeUnitFormat
& other);
127
128
136
virtual
UBool
operator==
(
const
Format
& other)
const
;
137
145
UBool
operator!=
(
const
Format
& other)
const
;
146
153
void
setLocale(
const
Locale
& locale,
UErrorCode
& status);
154
155
162
void
setNumberFormat(
const
NumberFormat
& format,
UErrorCode
& status);
163
164
165
using
MeasureFormat::format
;
166
175
virtual
UnicodeString
&
format
(
const
Formattable
& obj,
176
UnicodeString
& toAppendTo,
177
FieldPosition
& pos,
178
UErrorCode
& status)
const
;
179
185
virtual
void
parseObject
(
const
UnicodeString
& source,
186
Formattable
& result,
187
ParsePosition
& pos)
const
;
188
200
static
UClassID
U_EXPORT2
getStaticClassID(
void
);
201
213
virtual
UClassID
getDynamicClassID
(
void
)
const
;
214
215
private
:
216
NumberFormat
* fNumberFormat;
217
Locale
fLocale;
218
Hashtable* fTimeUnitToCountToPatterns[TimeUnit::UTIMEUNIT_FIELD_COUNT];
219
PluralRules
* fPluralRules;
220
UTimeUnitFormatStyle
fStyle;
221
222
void
create(
const
Locale
& locale,
UTimeUnitFormatStyle
style,
UErrorCode
& status);
223
224
// it might actually be simpler to make them Decimal Formats later.
225
// initialize all private data members
226
void
setup(
UErrorCode
& status);
227
228
// initialize data member without fill in data for fTimeUnitToCountToPattern
229
void
initDataMembers(
UErrorCode
& status);
230
231
// initialize fTimeUnitToCountToPatterns from current locale's resource.
232
void
readFromCurrentLocale(
UTimeUnitFormatStyle
style,
const
char
* key,
UErrorCode
& status);
233
234
// check completeness of fTimeUnitToCountToPatterns against all time units,
235
// and all plural rules, fill in fallback as necessary.
236
void
checkConsistency(
UTimeUnitFormatStyle
style,
const
char
* key,
UErrorCode
& status);
237
238
// fill in fTimeUnitToCountToPatterns from locale fall-back chain
239
void
searchInLocaleChain(
UTimeUnitFormatStyle
style,
const
char
* key,
const
char
* localeName,
240
TimeUnit::UTimeUnitFields
field,
const
UnicodeString
&,
241
const
char
*, Hashtable*,
UErrorCode
&);
242
243
// initialize hash table
244
Hashtable* initHash(
UErrorCode
& status);
245
246
// delete hash table
247
void
deleteHash(Hashtable* htable);
248
249
// copy hash table
250
void
copyHash(
const
Hashtable* source, Hashtable* target,
UErrorCode
& status);
251
// get time unit name, such as "year", from time unit field enum, such as
252
// UTIMEUNIT_YEAR.
253
static
const
char
* getTimeUnitName(
TimeUnit::UTimeUnitFields
field,
UErrorCode
& status);
254
};
255
256
257
258
inline
UBool
259
TimeUnitFormat::operator!=
(
const
Format
& other)
const
{
260
return
!
operator==
(other);
261
}
262
263
264
265
U_NAMESPACE_END
266
267
#endif
/* #if !UCONFIG_NO_FORMATTING */
268
269
#endif // __TMUTFMT_H__
270
//eof
Generated by
1.8.1.1