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