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