Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: source/i18n/unicode/tmutfmt.h

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/i18n/unicode/tmunit.h ('k') | source/i18n/unicode/translit.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ******************************************************************************* 2 *******************************************************************************
3 * Copyright (C) 2008-2013, Google, International Business Machines Corporation 3 * Copyright (C) 2008-2014, Google, International Business Machines Corporation
4 * and others. All Rights Reserved. 4 * and others. All Rights Reserved.
5 ******************************************************************************* 5 *******************************************************************************
6 */ 6 */
7 7
8 #ifndef __TMUTFMT_H__ 8 #ifndef __TMUTFMT_H__
9 #define __TMUTFMT_H__ 9 #define __TMUTFMT_H__
10 10
11 #include "unicode/utypes.h" 11 #include "unicode/utypes.h"
12 12
13 /** 13 /**
14 * \file 14 * \file
15 * \brief C++ API: Format and parse duration in single time unit 15 * \brief C++ API: Format and parse duration in single time unit
16 */ 16 */
17 17
18 18
19 #if !UCONFIG_NO_FORMATTING 19 #if !UCONFIG_NO_FORMATTING
20 #ifndef U_HIDE_DEPRECATED_API
20 21
21 #include "unicode/unistr.h" 22 #include "unicode/unistr.h"
22 #include "unicode/tmunit.h" 23 #include "unicode/tmunit.h"
23 #include "unicode/tmutamt.h" 24 #include "unicode/tmutamt.h"
24 #include "unicode/measfmt.h" 25 #include "unicode/measfmt.h"
25 #include "unicode/numfmt.h" 26 #include "unicode/numfmt.h"
26 #include "unicode/plurrule.h" 27 #include "unicode/plurrule.h"
27 28
29
28 /** 30 /**
29 * Constants for various styles. 31 * Constants for various styles.
30 * There are 2 styles: full name and abbreviated name. 32 * There are 2 styles: full name and abbreviated name.
31 * For example, for English, the full name for hour duration is "3 hours", 33 * For example, for English, the full name for hour duration is "3 hours",
32 * and the abbreviated name is "3 hrs". 34 * and the abbreviated name is "3 hrs".
33 * @stable ICU 4.8 35 * @deprecated ICU 53 Use MeasureFormat and UMeasureFormatWidth instead.
34 */ 36 */
35 enum UTimeUnitFormatStyle { 37 enum UTimeUnitFormatStyle {
36 /** @stable ICU 4.8 */ 38 /** @deprecated ICU 53 */
37 UTMUTFMT_FULL_STYLE, 39 UTMUTFMT_FULL_STYLE,
38 /** @stable ICU 4.8 */ 40 /** @deprecated ICU 53 */
39 UTMUTFMT_ABBREVIATED_STYLE, 41 UTMUTFMT_ABBREVIATED_STYLE,
40 /** @stable ICU 4.8 */ 42 /** @deprecated ICU 53 */
41 UTMUTFMT_FORMAT_STYLE_COUNT 43 UTMUTFMT_FORMAT_STYLE_COUNT
42 }; 44 };
43 typedef enum UTimeUnitFormatStyle UTimeUnitFormatStyle; /**< @stable ICU 4.8 */ 45 typedef enum UTimeUnitFormatStyle UTimeUnitFormatStyle; /**< @deprecated ICU 53 */
46
44 47
45 U_NAMESPACE_BEGIN 48 U_NAMESPACE_BEGIN
46 49
47 class Hashtable; 50 class Hashtable;
48 class UVector; 51 class UVector;
49 52
50 /** 53 /**
51 * Format or parse a TimeUnitAmount, using plural rules for the units where avai lable. 54 * Format or parse a TimeUnitAmount, using plural rules for the units where avai lable.
52 * 55 *
53 * <P> 56 * <P>
(...skipping 14 matching lines...) Expand all
68 * ((Format*)format)->parseObject(formatted, result, status); 71 * ((Format*)format)->parseObject(formatted, result, status);
69 * if (U_SUCCESS(status)) { 72 * if (U_SUCCESS(status)) {
70 * assert (result == formattable); 73 * assert (result == formattable);
71 * } 74 * }
72 * } 75 * }
73 * </pre> 76 * </pre>
74 * 77 *
75 * <P> 78 * <P>
76 * @see TimeUnitAmount 79 * @see TimeUnitAmount
77 * @see TimeUnitFormat 80 * @see TimeUnitFormat
78 * @stable ICU 4.2 81 * @deprecated ICU 53 Use the MeasureFormat class instead.
79 */ 82 */
80 class U_I18N_API TimeUnitFormat: public MeasureFormat { 83 class U_I18N_API TimeUnitFormat: public MeasureFormat {
81 public: 84 public:
82 85
83 /** 86 /**
84 * Create TimeUnitFormat with default locale, and full name style. 87 * Create TimeUnitFormat with default locale, and full name style.
85 * Use setLocale and/or setFormat to modify. 88 * Use setLocale and/or setFormat to modify.
86 * @stable ICU 4.2 89 * @deprecated ICU 53
87 */ 90 */
88 TimeUnitFormat(UErrorCode& status); 91 TimeUnitFormat(UErrorCode& status);
89 92
90 /** 93 /**
91 * Create TimeUnitFormat given locale, and full name style. 94 * Create TimeUnitFormat given locale, and full name style.
92 * @stable ICU 4.2 95 * @deprecated ICU 53
93 */ 96 */
94 TimeUnitFormat(const Locale& locale, UErrorCode& status); 97 TimeUnitFormat(const Locale& locale, UErrorCode& status);
95 98
96 /** 99 /**
97 * Create TimeUnitFormat given locale and style. 100 * Create TimeUnitFormat given locale and style.
98 * @stable ICU 4.8 101 * @deprecated ICU 53
99 */ 102 */
100 TimeUnitFormat(const Locale& locale, UTimeUnitFormatStyle style, UErrorCode& status); 103 TimeUnitFormat(const Locale& locale, UTimeUnitFormatStyle style, UErrorCode& status);
101 104
102 /** 105 /**
103 * Copy constructor. 106 * Copy constructor.
104 * @stable ICU 4.2 107 * @deprecated ICU 53
105 */ 108 */
106 TimeUnitFormat(const TimeUnitFormat&); 109 TimeUnitFormat(const TimeUnitFormat&);
107 110
108 /** 111 /**
109 * deconstructor 112 * deconstructor
110 * @stable ICU 4.2 113 * @deprecated ICU 53
111 */ 114 */
112 virtual ~TimeUnitFormat(); 115 virtual ~TimeUnitFormat();
113 116
114 /** 117 /**
115 * Clone this Format object polymorphically. The caller owns the result and 118 * Clone this Format object polymorphically. The caller owns the result and
116 * should delete it when done. 119 * should delete it when done.
117 * @return A copy of the object. 120 * @return A copy of the object.
118 * @stable ICU 4.2 121 * @deprecated ICU 53
119 */ 122 */
120 virtual Format* clone(void) const; 123 virtual Format* clone(void) const;
121 124
122 /** 125 /**
123 * Assignment operator 126 * Assignment operator
124 * @stable ICU 4.2 127 * @deprecated ICU 53
125 */ 128 */
126 TimeUnitFormat& operator=(const TimeUnitFormat& other); 129 TimeUnitFormat& operator=(const TimeUnitFormat& other);
127 130
128
129 /**
130 * Return true if the given Format objects are semantically equal. Objects
131 * of different subclasses are considered unequal.
132 * @param other the object to be compared with.
133 * @return true if the given Format objects are semantically equal.
134 * @stable ICU 4.2
135 */
136 virtual UBool operator==(const Format& other) const;
137
138 /** 131 /**
139 * Return true if the given Format objects are not semantically equal. 132 * Return true if the given Format objects are not semantically equal.
140 * Objects of different subclasses are considered unequal. 133 * Objects of different subclasses are considered unequal.
141 * @param other the object to be compared with. 134 * @param other the object to be compared with.
142 * @return true if the given Format objects are not semantically equal. 135 * @return true if the given Format objects are not semantically equal.
143 * @stable ICU 4.2 136 * @deprecated ICU 53
144 */ 137 */
145 UBool operator!=(const Format& other) const; 138 UBool operator!=(const Format& other) const;
146 139
147 /** 140 /**
148 * Set the locale used for formatting or parsing. 141 * Set the locale used for formatting or parsing.
149 * @param locale the locale to be set 142 * @param locale the locale to be set
150 * @param status output param set to success/failure code on exit 143 * @param status output param set to success/failure code on exit
151 * @stable ICU 4.2 144 * @deprecated ICU 53
152 */ 145 */
153 void setLocale(const Locale& locale, UErrorCode& status); 146 void setLocale(const Locale& locale, UErrorCode& status);
154 147
155 148
156 /** 149 /**
157 * Set the number format used for formatting or parsing. 150 * Set the number format used for formatting or parsing.
158 * @param format the number formatter to be set 151 * @param format the number formatter to be set
159 * @param status output param set to success/failure code on exit 152 * @param status output param set to success/failure code on exit
160 * @stable ICU 4.2 153 * @deprecated ICU 53
161 */ 154 */
162 void setNumberFormat(const NumberFormat& format, UErrorCode& status); 155 void setNumberFormat(const NumberFormat& format, UErrorCode& status);
163 156
164
165 using MeasureFormat::format;
166
167 /**
168 * Format a TimeUnitAmount.
169 * If the formattable object is not a time unit amount object,
170 * or the number in time unit amount is not a double type or long type
171 * numeric, it returns a failing status: U_ILLEGAL_ARGUMENT_ERROR.
172 * @see Format#format(const Formattable&, UnicodeString&, FieldPosition&, U ErrorCode&) const
173 * @stable ICU 4.2
174 */
175 virtual UnicodeString& format(const Formattable& obj,
176 UnicodeString& toAppendTo,
177 FieldPosition& pos,
178 UErrorCode& status) const;
179
180 /** 157 /**
181 * Parse a TimeUnitAmount. 158 * Parse a TimeUnitAmount.
182 * @see Format#parseObject(const UnicodeString&, Formattable&, ParsePosition &) const; 159 * @see Format#parseObject(const UnicodeString&, Formattable&, ParsePosition &) const;
183 * @stable ICU 4.2 160 * @deprecated ICU 53
184 */ 161 */
185 virtual void parseObject(const UnicodeString& source, 162 virtual void parseObject(const UnicodeString& source,
186 Formattable& result, 163 Formattable& result,
187 ParsePosition& pos) const; 164 ParsePosition& pos) const;
188 165
189 /** 166 /**
190 * Return the class ID for this class. This is useful only for comparing to 167 * Return the class ID for this class. This is useful only for comparing to
191 * a return value from getDynamicClassID(). For example: 168 * a return value from getDynamicClassID(). For example:
192 * <pre> 169 * <pre>
193 * . Base* polymorphic_pointer = createPolymorphicObject(); 170 * . Base* polymorphic_pointer = createPolymorphicObject();
194 * . if (polymorphic_pointer->getDynamicClassID() == 171 * . if (polymorphic_pointer->getDynamicClassID() ==
195 * . erived::getStaticClassID()) ... 172 * . erived::getStaticClassID()) ...
196 * </pre> 173 * </pre>
197 * @return The class ID for all objects of this class. 174 * @return The class ID for all objects of this class.
198 * @stable ICU 4.2 175 * @deprecated ICU 53
199 */ 176 */
200 static UClassID U_EXPORT2 getStaticClassID(void); 177 static UClassID U_EXPORT2 getStaticClassID(void);
201 178
202 /** 179 /**
203 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 180 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
204 * method is to implement a simple version of RTTI, since not all C++ 181 * method is to implement a simple version of RTTI, since not all C++
205 * compilers support genuine RTTI. Polymorphic operator==() and clone() 182 * compilers support genuine RTTI. Polymorphic operator==() and clone()
206 * methods call this method. 183 * methods call this method.
207 * 184 *
208 * @return The class ID for this object. All objects of a 185 * @return The class ID for this object. All objects of a
209 * given class have the same class ID. Objects of 186 * given class have the same class ID. Objects of
210 * other classes have different class IDs. 187 * other classes have different class IDs.
211 * @stable ICU 4.2 188 * @deprecated ICU 53
212 */ 189 */
213 virtual UClassID getDynamicClassID(void) const; 190 virtual UClassID getDynamicClassID(void) const;
214 191
215 private: 192 private:
216 NumberFormat* fNumberFormat;
217 Locale fLocale;
218 Hashtable* fTimeUnitToCountToPatterns[TimeUnit::UTIMEUNIT_FIELD_COUNT]; 193 Hashtable* fTimeUnitToCountToPatterns[TimeUnit::UTIMEUNIT_FIELD_COUNT];
219 PluralRules* fPluralRules;
220 UTimeUnitFormatStyle fStyle; 194 UTimeUnitFormatStyle fStyle;
221 195
222 void create(const Locale& locale, UTimeUnitFormatStyle style, UErrorCode& st atus); 196 void create(UTimeUnitFormatStyle style, UErrorCode& status);
223 197
224 // it might actually be simpler to make them Decimal Formats later. 198 // it might actually be simpler to make them Decimal Formats later.
225 // initialize all private data members 199 // initialize all private data members
226 void setup(UErrorCode& status); 200 void setup(UErrorCode& status);
227 201
228 // initialize data member without fill in data for fTimeUnitToCountToPattern 202 // initialize data member without fill in data for fTimeUnitToCountToPattern
229 void initDataMembers(UErrorCode& status); 203 void initDataMembers(UErrorCode& status);
230 204
231 // initialize fTimeUnitToCountToPatterns from current locale's resource. 205 // initialize fTimeUnitToCountToPatterns from current locale's resource.
232 void readFromCurrentLocale(UTimeUnitFormatStyle style, const char* key, cons t UVector& pluralCounts, 206 void readFromCurrentLocale(UTimeUnitFormatStyle style, const char* key, cons t UVector& pluralCounts,
(...skipping 15 matching lines...) Expand all
248 void deleteHash(Hashtable* htable); 222 void deleteHash(Hashtable* htable);
249 223
250 // copy hash table 224 // copy hash table
251 void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status ); 225 void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status );
252 // get time unit name, such as "year", from time unit field enum, such as 226 // get time unit name, such as "year", from time unit field enum, such as
253 // UTIMEUNIT_YEAR. 227 // UTIMEUNIT_YEAR.
254 static const char* getTimeUnitName(TimeUnit::UTimeUnitFields field, UErrorCo de& status); 228 static const char* getTimeUnitName(TimeUnit::UTimeUnitFields field, UErrorCo de& status);
255 229
256 }; 230 };
257 231
258
259
260 inline UBool 232 inline UBool
261 TimeUnitFormat::operator!=(const Format& other) const { 233 TimeUnitFormat::operator!=(const Format& other) const {
262 return !operator==(other); 234 return !operator==(other);
263 } 235 }
264 236
265
266
267 U_NAMESPACE_END 237 U_NAMESPACE_END
268 238
239 #endif /* U_HIDE_DEPRECATED_API */
269 #endif /* #if !UCONFIG_NO_FORMATTING */ 240 #endif /* #if !UCONFIG_NO_FORMATTING */
270 241
271 #endif // __TMUTFMT_H__ 242 #endif // __TMUTFMT_H__
272 //eof 243 //eof
OLDNEW
« no previous file with comments | « source/i18n/unicode/tmunit.h ('k') | source/i18n/unicode/translit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698