ICU 52.1
52.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
i18n
unicode
tmutfmt.h
Go to the documentation of this file.
1
/*
2
*******************************************************************************
3
* Copyright (C) 2008-2013, 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
class
UVector;
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,
const
UVector& pluralCounts,
233
UErrorCode
& status);
234
235
// check completeness of fTimeUnitToCountToPatterns against all time units,
236
// and all plural rules, fill in fallback as necessary.
237
void
checkConsistency(
UTimeUnitFormatStyle
style,
const
char
* key,
UErrorCode
& status);
238
239
// fill in fTimeUnitToCountToPatterns from locale fall-back chain
240
void
searchInLocaleChain(
UTimeUnitFormatStyle
style,
const
char
* key,
const
char
* localeName,
241
TimeUnit::UTimeUnitFields
field,
const
UnicodeString
&,
242
const
char
*, Hashtable*,
UErrorCode
&);
243
244
// initialize hash table
245
Hashtable* initHash(
UErrorCode
& status);
246
247
// delete hash table
248
void
deleteHash(Hashtable* htable);
249
250
// copy hash table
251
void
copyHash(
const
Hashtable* source, Hashtable* target,
UErrorCode
& status);
252
// get time unit name, such as "year", from time unit field enum, such as
253
// UTIMEUNIT_YEAR.
254
static
const
char
* getTimeUnitName(
TimeUnit::UTimeUnitFields
field,
UErrorCode
& status);
255
256
};
257
258
259
260
inline
UBool
261
TimeUnitFormat::operator!=
(
const
Format
& other)
const
{
262
return
!
operator==
(other);
263
}
264
265
266
267
U_NAMESPACE_END
268
269
#endif
/* #if !UCONFIG_NO_FORMATTING */
270
271
#endif // __TMUTFMT_H__
272
//eof
Generated on Fri Oct 4 2013 14:10:21 for ICU 52.1 by
1.8.1.2