]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
46f4442e A |
3 | /* |
4 | ******************************************************************************* | |
2ca993e8 | 5 | * Copyright (C) 2007-2016, International Business Machines Corporation and |
46f4442e A |
6 | * others. All Rights Reserved. |
7 | ******************************************************************************* | |
8 | * | |
9 | * File DTPTNGEN.H | |
10 | * | |
11 | ******************************************************************************* | |
12 | */ | |
13 | ||
14 | #ifndef __DTPTNGEN_H__ | |
15 | #define __DTPTNGEN_H__ | |
16 | ||
340931cb A |
17 | #include "unicode/utypes.h" |
18 | ||
19 | #if U_SHOW_CPLUSPLUS_API | |
20 | ||
46f4442e A |
21 | #include "unicode/datefmt.h" |
22 | #include "unicode/locid.h" | |
23 | #include "unicode/udat.h" | |
24 | #include "unicode/udatpg.h" | |
0f5d89e8 | 25 | #include "unicode/unistr.h" |
46f4442e A |
26 | |
27 | U_NAMESPACE_BEGIN | |
28 | ||
29 | /** | |
30 | * \file | |
31 | * \brief C++ API: Date/Time Pattern Generator | |
32 | */ | |
33 | ||
34 | ||
f3c0d7a5 | 35 | class CharString; |
46f4442e A |
36 | class Hashtable; |
37 | class FormatParser; | |
38 | class DateTimeMatcher; | |
39 | class DistanceInfo; | |
40 | class PatternMap; | |
41 | class PtnSkeleton; | |
b331163b | 42 | class SharedDateTimePatternGenerator; |
46f4442e A |
43 | |
44 | /** | |
2ca993e8 A |
45 | * This class provides flexible generation of date format patterns, like "yy-MM-dd". |
46 | * The user can build up the generator by adding successive patterns. Once that | |
46f4442e | 47 | * is done, a query can be made using a "skeleton", which is a pattern which just |
2ca993e8 | 48 | * includes the desired fields and lengths. The generator will return the "best fit" |
46f4442e A |
49 | * pattern corresponding to that skeleton. |
50 | * <p>The main method people will use is getBestPattern(String skeleton), | |
2ca993e8 | 51 | * since normally this class is pre-built with data from a particular locale. |
46f4442e | 52 | * However, generators can be built directly from other data as well. |
2ca993e8 | 53 | * <p><i>Issue: may be useful to also have a function that returns the list of |
46f4442e A |
54 | * fields in a pattern, in order, since we have that internally. |
55 | * That would be useful for getting the UI order of field elements.</i> | |
56 | * @stable ICU 3.8 | |
57 | **/ | |
58 | class U_I18N_API DateTimePatternGenerator : public UObject { | |
59 | public: | |
60 | /** | |
61 | * Construct a flexible generator according to default locale. | |
62 | * @param status Output param set to success/failure code on exit, | |
63 | * which must not indicate a failure before the function call. | |
64 | * @stable ICU 3.8 | |
65 | */ | |
66 | static DateTimePatternGenerator* U_EXPORT2 createInstance(UErrorCode& status); | |
67 | ||
68 | /** | |
69 | * Construct a flexible generator according to data for a given locale. | |
70 | * @param uLocale | |
71 | * @param status Output param set to success/failure code on exit, | |
72 | * which must not indicate a failure before the function call. | |
73 | * @stable ICU 3.8 | |
74 | */ | |
3d1f044b | 75 | static DateTimePatternGenerator* U_EXPORT2 createInstance(const Locale& uLocale, UErrorCode& status, UBool skipICUData = FALSE); |
46f4442e | 76 | |
b331163b A |
77 | #ifndef U_HIDE_INTERNAL_API |
78 | ||
79 | /** | |
80 | * For ICU use only | |
81 | * | |
82 | * @internal | |
83 | */ | |
84 | static DateTimePatternGenerator* U_EXPORT2 internalMakeInstance(const Locale& uLocale, UErrorCode& status); | |
85 | ||
86 | #endif /* U_HIDE_INTERNAL_API */ | |
87 | ||
46f4442e A |
88 | /** |
89 | * Create an empty generator, to be constructed with addPattern(...) etc. | |
90 | * @param status Output param set to success/failure code on exit, | |
91 | * which must not indicate a failure before the function call. | |
92 | * @stable ICU 3.8 | |
93 | */ | |
94 | static DateTimePatternGenerator* U_EXPORT2 createEmptyInstance(UErrorCode& status); | |
2ca993e8 | 95 | |
46f4442e A |
96 | /** |
97 | * Destructor. | |
98 | * @stable ICU 3.8 | |
99 | */ | |
100 | virtual ~DateTimePatternGenerator(); | |
101 | ||
102 | /** | |
2ca993e8 | 103 | * Clone DateTimePatternGenerator object. Clients are responsible for |
46f4442e A |
104 | * deleting the DateTimePatternGenerator object cloned. |
105 | * @stable ICU 3.8 | |
106 | */ | |
107 | DateTimePatternGenerator* clone() const; | |
108 | ||
109 | /** | |
110 | * Return true if another object is semantically equal to this one. | |
111 | * | |
112 | * @param other the DateTimePatternGenerator object to be compared with. | |
113 | * @return true if other is semantically equal to this. | |
114 | * @stable ICU 3.8 | |
115 | */ | |
116 | UBool operator==(const DateTimePatternGenerator& other) const; | |
2ca993e8 | 117 | |
46f4442e A |
118 | /** |
119 | * Return true if another object is semantically unequal to this one. | |
120 | * | |
121 | * @param other the DateTimePatternGenerator object to be compared with. | |
122 | * @return true if other is semantically unequal to this. | |
123 | * @stable ICU 3.8 | |
124 | */ | |
125 | UBool operator!=(const DateTimePatternGenerator& other) const; | |
126 | ||
2ca993e8 A |
127 | /** |
128 | * Utility to return a unique skeleton from a given pattern. For example, | |
129 | * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". | |
130 | * | |
131 | * @param pattern Input pattern, such as "dd/MMM" | |
132 | * @param status Output param set to success/failure code on exit, | |
133 | * which must not indicate a failure before the function call. | |
134 | * @return skeleton such as "MMMdd" | |
f3c0d7a5 | 135 | * @stable ICU 56 |
2ca993e8 A |
136 | */ |
137 | static UnicodeString staticGetSkeleton(const UnicodeString& pattern, UErrorCode& status); | |
2ca993e8 | 138 | |
46f4442e A |
139 | /** |
140 | * Utility to return a unique skeleton from a given pattern. For example, | |
141 | * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". | |
2ca993e8 A |
142 | * getSkeleton() works exactly like staticGetSkeleton(). |
143 | * Use staticGetSkeleton() instead of getSkeleton(). | |
46f4442e A |
144 | * |
145 | * @param pattern Input pattern, such as "dd/MMM" | |
146 | * @param status Output param set to success/failure code on exit, | |
147 | * which must not indicate a failure before the function call. | |
148 | * @return skeleton such as "MMMdd" | |
149 | * @stable ICU 3.8 | |
150 | */ | |
2ca993e8 A |
151 | UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status); /* { |
152 | The function is commented out because it is a stable API calling a draft API. | |
153 | After staticGetSkeleton becomes stable, staticGetSkeleton can be used and | |
154 | these comments and the definition of getSkeleton in dtptngen.cpp should be removed. | |
155 | return staticGetSkeleton(pattern, status); | |
156 | }*/ | |
157 | ||
2ca993e8 A |
158 | /** |
159 | * Utility to return a unique base skeleton from a given pattern. This is | |
160 | * the same as the skeleton, except that differences in length are minimized | |
161 | * so as to only preserve the difference between string and numeric form. So | |
162 | * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" | |
163 | * (notice the single d). | |
164 | * | |
165 | * @param pattern Input pattern, such as "dd/MMM" | |
166 | * @param status Output param set to success/failure code on exit, | |
167 | * which must not indicate a failure before the function call. | |
168 | * @return base skeleton, such as "MMMd" | |
f3c0d7a5 | 169 | * @stable ICU 56 |
2ca993e8 A |
170 | */ |
171 | static UnicodeString staticGetBaseSkeleton(const UnicodeString& pattern, UErrorCode& status); | |
46f4442e A |
172 | |
173 | /** | |
174 | * Utility to return a unique base skeleton from a given pattern. This is | |
175 | * the same as the skeleton, except that differences in length are minimized | |
176 | * so as to only preserve the difference between string and numeric form. So | |
177 | * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" | |
178 | * (notice the single d). | |
2ca993e8 A |
179 | * getBaseSkeleton() works exactly like staticGetBaseSkeleton(). |
180 | * Use staticGetBaseSkeleton() instead of getBaseSkeleton(). | |
46f4442e A |
181 | * |
182 | * @param pattern Input pattern, such as "dd/MMM" | |
183 | * @param status Output param set to success/failure code on exit, | |
184 | * which must not indicate a failure before the function call. | |
2ca993e8 | 185 | * @return base skeleton, such as "MMMd" |
46f4442e A |
186 | * @stable ICU 3.8 |
187 | */ | |
2ca993e8 A |
188 | UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status); /* { |
189 | The function is commented out because it is a stable API calling a draft API. | |
190 | After staticGetBaseSkeleton becomes stable, staticGetBaseSkeleton can be used and | |
191 | these comments and the definition of getBaseSkeleton in dtptngen.cpp should be removed. | |
192 | return staticGetBaseSkeleton(pattern, status); | |
193 | }*/ | |
46f4442e A |
194 | |
195 | /** | |
196 | * Adds a pattern to the generator. If the pattern has the same skeleton as | |
197 | * an existing pattern, and the override parameter is set, then the previous | |
198 | * value is overriden. Otherwise, the previous value is retained. In either | |
2ca993e8 | 199 | * case, the conflicting status is set and previous vale is stored in |
46f4442e A |
200 | * conflicting pattern. |
201 | * <p> | |
202 | * Note that single-field patterns (like "MMM") are automatically added, and | |
203 | * don't need to be added explicitly! | |
204 | * | |
205 | * @param pattern Input pattern, such as "dd/MMM" | |
2ca993e8 | 206 | * @param override When existing values are to be overridden use true, |
46f4442e A |
207 | * otherwise use false. |
208 | * @param conflictingPattern Previous pattern with the same skeleton. | |
209 | * @param status Output param set to success/failure code on exit, | |
210 | * which must not indicate a failure before the function call. | |
2ca993e8 | 211 | * @return conflicting status. The value could be UDATPG_NO_CONFLICT, |
46f4442e A |
212 | * UDATPG_BASE_CONFLICT or UDATPG_CONFLICT. |
213 | * @stable ICU 3.8 | |
0f5d89e8 A |
214 | * <p> |
215 | * <h4>Sample code</h4> | |
216 | * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1 | |
217 | * \snippet samples/dtptngsample/dtptngsample.cpp addPatternExample | |
218 | * <p> | |
46f4442e | 219 | */ |
2ca993e8 A |
220 | UDateTimePatternConflict addPattern(const UnicodeString& pattern, |
221 | UBool override, | |
46f4442e A |
222 | UnicodeString& conflictingPattern, |
223 | UErrorCode& status); | |
224 | ||
225 | /** | |
226 | * An AppendItem format is a pattern used to append a field if there is no | |
227 | * good match. For example, suppose that the input skeleton is "GyyyyMMMd", | |
228 | * and there is no matching pattern internally, but there is a pattern | |
229 | * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the | |
230 | * G. The way these two are conjoined is by using the AppendItemFormat for G | |
231 | * (era). So if that value is, say "{0}, {1}" then the final resulting | |
232 | * pattern is "d-MM-yyyy, G". | |
233 | * <p> | |
234 | * There are actually three available variables: {0} is the pattern so far, | |
235 | * {1} is the element we are adding, and {2} is the name of the element. | |
236 | * <p> | |
237 | * This reflects the way that the CLDR data is organized. | |
238 | * | |
239 | * @param field such as UDATPG_ERA_FIELD. | |
240 | * @param value pattern, such as "{0}, {1}" | |
241 | * @stable ICU 3.8 | |
242 | */ | |
243 | void setAppendItemFormat(UDateTimePatternField field, const UnicodeString& value); | |
244 | ||
245 | /** | |
246 | * Getter corresponding to setAppendItemFormat. Values below 0 or at or | |
247 | * above UDATPG_FIELD_COUNT are illegal arguments. | |
248 | * | |
249 | * @param field such as UDATPG_ERA_FIELD. | |
250 | * @return append pattern for field | |
251 | * @stable ICU 3.8 | |
252 | */ | |
253 | const UnicodeString& getAppendItemFormat(UDateTimePatternField field) const; | |
254 | ||
255 | /** | |
256 | * Sets the names of field, eg "era" in English for ERA. These are only | |
257 | * used if the corresponding AppendItemFormat is used, and if it contains a | |
258 | * {2} variable. | |
259 | * <p> | |
260 | * This reflects the way that the CLDR data is organized. | |
261 | * | |
262 | * @param field such as UDATPG_ERA_FIELD. | |
263 | * @param value name of the field | |
264 | * @stable ICU 3.8 | |
265 | */ | |
266 | void setAppendItemName(UDateTimePatternField field, const UnicodeString& value); | |
267 | ||
268 | /** | |
269 | * Getter corresponding to setAppendItemNames. Values below 0 or at or above | |
0f5d89e8 A |
270 | * UDATPG_FIELD_COUNT are illegal arguments. Note: The more general method |
271 | * for getting date/time field display names is getFieldDisplayName. | |
46f4442e A |
272 | * |
273 | * @param field such as UDATPG_ERA_FIELD. | |
274 | * @return name for field | |
0f5d89e8 | 275 | * @see getFieldDisplayName |
46f4442e A |
276 | * @stable ICU 3.8 |
277 | */ | |
278 | const UnicodeString& getAppendItemName(UDateTimePatternField field) const; | |
279 | ||
0f5d89e8 A |
280 | /** |
281 | * The general interface to get a display name for a particular date/time field, | |
282 | * in one of several possible display widths. | |
283 | * | |
284 | * @param field The desired UDateTimePatternField, such as UDATPG_ERA_FIELD. | |
285 | * @param width The desired UDateTimePGDisplayWidth, such as UDATPG_ABBREVIATED. | |
340931cb | 286 | * @return The display name for field |
3d1f044b | 287 | * @stable ICU 61 |
0f5d89e8 A |
288 | */ |
289 | UnicodeString getFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width) const; | |
0f5d89e8 | 290 | |
46f4442e | 291 | /** |
b331163b A |
292 | * The DateTimeFormat is a message format pattern used to compose date and |
293 | * time patterns. The default pattern in the root locale is "{1} {0}", where | |
294 | * {1} will be replaced by the date pattern and {0} will be replaced by the | |
295 | * time pattern; however, other locales may specify patterns such as | |
296 | * "{1}, {0}" or "{1} 'at' {0}", etc. | |
46f4442e A |
297 | * <p> |
298 | * This is used when the input skeleton contains both date and time fields, | |
299 | * but there is not a close match among the added patterns. For example, | |
300 | * suppose that this object was created by adding "dd-MMM" and "hh:mm", and | |
b331163b | 301 | * its datetimeFormat is the default "{1} {0}". Then if the input skeleton |
46f4442e A |
302 | * is "MMMdhmm", there is not an exact match, so the input skeleton is |
303 | * broken up into two components "MMMd" and "hmm". There are close matches | |
304 | * for those two skeletons, so the result is put together with this pattern, | |
305 | * resulting in "d-MMM h:mm". | |
306 | * | |
307 | * @param dateTimeFormat | |
b331163b A |
308 | * message format pattern, here {1} will be replaced by the date |
309 | * pattern and {0} will be replaced by the time pattern. | |
46f4442e A |
310 | * @stable ICU 3.8 |
311 | */ | |
312 | void setDateTimeFormat(const UnicodeString& dateTimeFormat); | |
313 | ||
314 | /** | |
315 | * Getter corresponding to setDateTimeFormat. | |
316 | * @return DateTimeFormat. | |
317 | * @stable ICU 3.8 | |
318 | */ | |
319 | const UnicodeString& getDateTimeFormat() const; | |
320 | ||
321 | /** | |
322 | * Return the best pattern matching the input skeleton. It is guaranteed to | |
323 | * have all of the fields in the skeleton. | |
324 | * | |
325 | * @param skeleton | |
326 | * The skeleton is a pattern containing only the variable fields. | |
327 | * For example, "MMMdd" and "mmhh" are skeletons. | |
328 | * @param status Output param set to success/failure code on exit, | |
329 | * which must not indicate a failure before the function call. | |
330 | * @return bestPattern | |
331 | * The best pattern found from the given skeleton. | |
332 | * @stable ICU 3.8 | |
0f5d89e8 A |
333 | * <p> |
334 | * <h4>Sample code</h4> | |
335 | * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1 | |
336 | * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample | |
337 | * <p> | |
46f4442e A |
338 | */ |
339 | UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status); | |
340 | ||
341 | ||
729e4ab9 A |
342 | /** |
343 | * Return the best pattern matching the input skeleton. It is guaranteed to | |
344 | * have all of the fields in the skeleton. | |
345 | * | |
346 | * @param skeleton | |
347 | * The skeleton is a pattern containing only the variable fields. | |
348 | * For example, "MMMdd" and "mmhh" are skeletons. | |
349 | * @param options | |
350 | * Options for forcing the length of specified fields in the | |
351 | * returned pattern to match those in the skeleton (when this | |
352 | * would not happen otherwise). For default behavior, use | |
353 | * UDATPG_MATCH_NO_OPTIONS. | |
354 | * @param status | |
355 | * Output param set to success/failure code on exit, | |
356 | * which must not indicate a failure before the function call. | |
357 | * @return bestPattern | |
358 | * The best pattern found from the given skeleton. | |
359 | * @stable ICU 4.4 | |
360 | */ | |
361 | UnicodeString getBestPattern(const UnicodeString& skeleton, | |
362 | UDateTimePatternMatchOptions options, | |
363 | UErrorCode& status); | |
364 | ||
365 | ||
46f4442e A |
366 | /** |
367 | * Adjusts the field types (width and subtype) of a pattern to match what is | |
368 | * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a | |
369 | * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be | |
370 | * "dd-MMMM hh:mm". This is used internally to get the best match for the | |
371 | * input skeleton, but can also be used externally. | |
372 | * | |
373 | * @param pattern Input pattern | |
374 | * @param skeleton | |
375 | * The skeleton is a pattern containing only the variable fields. | |
376 | * For example, "MMMdd" and "mmhh" are skeletons. | |
377 | * @param status Output param set to success/failure code on exit, | |
378 | * which must not indicate a failure before the function call. | |
379 | * @return pattern adjusted to match the skeleton fields widths and subtypes. | |
380 | * @stable ICU 3.8 | |
0f5d89e8 A |
381 | * <p> |
382 | * <h4>Sample code</h4> | |
383 | * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1 | |
384 | * \snippet samples/dtptngsample/dtptngsample.cpp replaceFieldTypesExample | |
385 | * <p> | |
46f4442e | 386 | */ |
2ca993e8 A |
387 | UnicodeString replaceFieldTypes(const UnicodeString& pattern, |
388 | const UnicodeString& skeleton, | |
46f4442e A |
389 | UErrorCode& status); |
390 | ||
729e4ab9 A |
391 | /** |
392 | * Adjusts the field types (width and subtype) of a pattern to match what is | |
393 | * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a | |
394 | * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be | |
395 | * "dd-MMMM hh:mm". This is used internally to get the best match for the | |
396 | * input skeleton, but can also be used externally. | |
397 | * | |
398 | * @param pattern Input pattern | |
399 | * @param skeleton | |
400 | * The skeleton is a pattern containing only the variable fields. | |
401 | * For example, "MMMdd" and "mmhh" are skeletons. | |
402 | * @param options | |
403 | * Options controlling whether the length of specified fields in the | |
404 | * pattern are adjusted to match those in the skeleton (when this | |
405 | * would not happen otherwise). For default behavior, use | |
406 | * UDATPG_MATCH_NO_OPTIONS. | |
407 | * @param status | |
408 | * Output param set to success/failure code on exit, | |
409 | * which must not indicate a failure before the function call. | |
410 | * @return pattern adjusted to match the skeleton fields widths and subtypes. | |
411 | * @stable ICU 4.4 | |
412 | */ | |
2ca993e8 A |
413 | UnicodeString replaceFieldTypes(const UnicodeString& pattern, |
414 | const UnicodeString& skeleton, | |
729e4ab9 A |
415 | UDateTimePatternMatchOptions options, |
416 | UErrorCode& status); | |
417 | ||
46f4442e A |
418 | /** |
419 | * Return a list of all the skeletons (in canonical form) from this class. | |
420 | * | |
421 | * Call getPatternForSkeleton() to get the corresponding pattern. | |
422 | * | |
423 | * @param status Output param set to success/failure code on exit, | |
424 | * which must not indicate a failure before the function call. | |
425 | * @return StringEnumeration with the skeletons. | |
426 | * The caller must delete the object. | |
427 | * @stable ICU 3.8 | |
428 | */ | |
429 | StringEnumeration* getSkeletons(UErrorCode& status) const; | |
430 | ||
431 | /** | |
432 | * Get the pattern corresponding to a given skeleton. | |
2ca993e8 | 433 | * @param skeleton |
46f4442e A |
434 | * @return pattern corresponding to a given skeleton. |
435 | * @stable ICU 3.8 | |
436 | */ | |
437 | const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const; | |
2ca993e8 | 438 | |
46f4442e A |
439 | /** |
440 | * Return a list of all the base skeletons (in canonical form) from this class. | |
441 | * | |
442 | * @param status Output param set to success/failure code on exit, | |
443 | * which must not indicate a failure before the function call. | |
444 | * @return a StringEnumeration with the base skeletons. | |
445 | * The caller must delete the object. | |
446 | * @stable ICU 3.8 | |
447 | */ | |
448 | StringEnumeration* getBaseSkeletons(UErrorCode& status) const; | |
4388f060 A |
449 | |
450 | #ifndef U_HIDE_INTERNAL_API | |
46f4442e | 451 | /** |
2ca993e8 A |
452 | * Return a list of redundant patterns are those which if removed, make no |
453 | * difference in the resulting getBestPattern values. This method returns a | |
454 | * list of them, to help check the consistency of the patterns used to build | |
46f4442e | 455 | * this generator. |
2ca993e8 | 456 | * |
46f4442e A |
457 | * @param status Output param set to success/failure code on exit, |
458 | * which must not indicate a failure before the function call. | |
459 | * @return a StringEnumeration with the redundant pattern. | |
460 | * The caller must delete the object. | |
461 | * @internal ICU 3.8 | |
462 | */ | |
463 | StringEnumeration* getRedundants(UErrorCode& status); | |
4388f060 A |
464 | #endif /* U_HIDE_INTERNAL_API */ |
465 | ||
46f4442e A |
466 | /** |
467 | * The decimal value is used in formatting fractions of seconds. If the | |
468 | * skeleton contains fractional seconds, then this is used with the | |
469 | * fractional seconds. For example, suppose that the input pattern is | |
470 | * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and | |
471 | * the decimal string is ",". Then the resulting pattern is modified to be | |
472 | * "H:mm:ss,SSSS" | |
473 | * | |
2ca993e8 | 474 | * @param decimal |
46f4442e A |
475 | * @stable ICU 3.8 |
476 | */ | |
477 | void setDecimal(const UnicodeString& decimal); | |
478 | ||
479 | /** | |
480 | * Getter corresponding to setDecimal. | |
481 | * @return UnicodeString corresponding to the decimal point | |
482 | * @stable ICU 3.8 | |
483 | */ | |
484 | const UnicodeString& getDecimal() const; | |
485 | ||
486 | /** | |
487 | * ICU "poor man's RTTI", returns a UClassID for the actual class. | |
488 | * | |
489 | * @stable ICU 3.8 | |
490 | */ | |
491 | virtual UClassID getDynamicClassID() const; | |
492 | ||
493 | /** | |
494 | * ICU "poor man's RTTI", returns a UClassID for this class. | |
495 | * | |
496 | * @stable ICU 3.8 | |
497 | */ | |
498 | static UClassID U_EXPORT2 getStaticClassID(void); | |
499 | ||
500 | private: | |
501 | /** | |
502 | * Constructor. | |
46f4442e A |
503 | */ |
504 | DateTimePatternGenerator(UErrorCode & status); | |
505 | ||
506 | /** | |
507 | * Constructor. | |
46f4442e | 508 | */ |
3d1f044b | 509 | DateTimePatternGenerator(const Locale& locale, UErrorCode & status, UBool skipICUData = FALSE); |
46f4442e A |
510 | |
511 | /** | |
512 | * Copy constructor. | |
513 | * @param other DateTimePatternGenerator to copy | |
46f4442e A |
514 | */ |
515 | DateTimePatternGenerator(const DateTimePatternGenerator& other); | |
516 | ||
517 | /** | |
518 | * Default assignment operator. | |
519 | * @param other DateTimePatternGenerator to copy | |
46f4442e A |
520 | */ |
521 | DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other); | |
522 | ||
0f5d89e8 A |
523 | // TODO(ticket:13619): re-enable when UDATPG_NARROW no longer in draft mode. |
524 | // static const int32_t UDATPG_WIDTH_COUNT = UDATPG_NARROW + 1; | |
525 | ||
46f4442e A |
526 | Locale pLocale; // pattern locale |
527 | FormatParser *fp; | |
528 | DateTimeMatcher* dtMatcher; | |
529 | DistanceInfo *distanceInfo; | |
530 | PatternMap *patternMap; | |
531 | UnicodeString appendItemFormats[UDATPG_FIELD_COUNT]; | |
0f5d89e8 A |
532 | // TODO(ticket:13619): [3] -> UDATPG_WIDTH_COUNT |
533 | UnicodeString fieldDisplayNames[UDATPG_FIELD_COUNT][3]; | |
46f4442e A |
534 | UnicodeString dateTimeFormat; |
535 | UnicodeString decimal; | |
536 | DateTimeMatcher *skipMatcher; | |
537 | Hashtable *fAvailableFormatKeyHash; | |
46f4442e | 538 | UnicodeString emptyString; |
f3c0d7a5 | 539 | char16_t fDefaultHourFormatChar; |
2ca993e8 A |
540 | |
541 | int32_t fAllowedHourFormats[7]; // Actually an array of AllowedHourFormat enum type, ending with UNKNOWN. | |
542 | ||
3d1f044b A |
543 | // Internal error code used for recording/reporting errors that occur during methods that do not |
544 | // have a UErrorCode parameter. For example: the Copy Constructor, or the ::clone() method. | |
545 | // When this is set to an error the object is in an invalid state. | |
546 | UErrorCode internalErrorCode; | |
547 | ||
57a6839d A |
548 | /* internal flags masks for adjustFieldTypes etc. */ |
549 | enum { | |
550 | kDTPGNoFlags = 0, | |
551 | kDTPGFixFractionalSeconds = 1, | |
0f5d89e8 A |
552 | kDTPGSkeletonUsesCapJ = 2 |
553 | // with #13183, no longer need flags for b, B | |
57a6839d | 554 | }; |
46f4442e | 555 | |
3d1f044b | 556 | void initData(const Locale &locale, UErrorCode &status, UBool skipICUData = FALSE); |
f3c0d7a5 | 557 | void addCanonicalItems(UErrorCode &status); |
46f4442e A |
558 | void addICUPatterns(const Locale& locale, UErrorCode& status); |
559 | void hackTimes(const UnicodeString& hackPattern, UErrorCode& status); | |
f3c0d7a5 A |
560 | void getCalendarTypeToUse(const Locale& locale, CharString& destination, UErrorCode& err); |
561 | void consumeShortTimePattern(const UnicodeString& shortTimePattern, UErrorCode& status); | |
729e4ab9 | 562 | void addCLDRData(const Locale& locale, UErrorCode& status); |
46f4442e A |
563 | UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status); |
564 | void initHashtable(UErrorCode& status); | |
565 | void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status); | |
566 | void setDecimalSymbols(const Locale& locale, UErrorCode& status); | |
567 | UDateTimePatternField getAppendFormatNumber(const char* field) const; | |
340931cb | 568 | // Note for the next 3: UDateTimePGDisplayWidth is now stable ICU 61 |
0f5d89e8 A |
569 | UDateTimePatternField getFieldAndWidthIndices(const char* key, UDateTimePGDisplayWidth* widthP) const; |
570 | void setFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width, const UnicodeString& value); | |
571 | UnicodeString& getMutableFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width); | |
46f4442e | 572 | void getAppendName(UDateTimePatternField field, UnicodeString& value); |
0f5d89e8 | 573 | UnicodeString mapSkeletonMetacharacters(const UnicodeString& patternForm, int32_t* flags, UDateTimePatternMatchOptions options, UErrorCode& status); |
46f4442e | 574 | int32_t getCanonicalIndex(const UnicodeString& field); |
3d1f044b | 575 | const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, UErrorCode& status, const PtnSkeleton** specifiedSkeletonPtr = 0); |
57a6839d | 576 | UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS); |
3d1f044b A |
577 | UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UErrorCode& status, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS); |
578 | int32_t getTopBitNumber(int32_t foundMask) const; | |
46f4442e A |
579 | void setAvailableFormat(const UnicodeString &key, UErrorCode& status); |
580 | UBool isAvailableFormatSet(const UnicodeString &key) const; | |
581 | void copyHashtable(Hashtable *other, UErrorCode &status); | |
582 | UBool isCanonicalItem(const UnicodeString& item) const; | |
f3c0d7a5 | 583 | static void U_CALLCONV loadAllowedHourFormatsData(UErrorCode &status); |
2ca993e8 | 584 | void getAllowedHourFormats(const Locale &locale, UErrorCode &status); |
f3c0d7a5 A |
585 | |
586 | struct AppendItemFormatsSink; | |
587 | struct AppendItemNamesSink; | |
588 | struct AvailableFormatsSink; | |
46f4442e A |
589 | } ;// end class DateTimePatternGenerator |
590 | ||
591 | U_NAMESPACE_END | |
340931cb A |
592 | |
593 | #endif /* U_SHOW_CPLUSPLUS_API */ | |
46f4442e A |
594 | |
595 | #endif |