xref: /aosp_15_r20/external/icu/libicu/cts_headers/unicode/dtptngen.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
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/utypes.h"
18 
19 #if U_SHOW_CPLUSPLUS_API
20 
21 #include "unicode/datefmt.h"
22 #include "unicode/locid.h"
23 #include "unicode/udat.h"
24 #include "unicode/udatpg.h"
25 #include "unicode/unistr.h"
26 
27 U_NAMESPACE_BEGIN
28 
29 /**
30  * \file
31  * \brief C++ API: Date/Time Pattern Generator
32  */
33 
34 
35 class CharString;
36 class Hashtable;
37 class FormatParser;
38 class DateTimeMatcher;
39 class DistanceInfo;
40 class PatternMap;
41 class PtnSkeleton;
42 class SharedDateTimePatternGenerator;
43 
44 /**
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
47  * is done, a query can be made using a "skeleton", which is a pattern which just
48  * includes the desired fields and lengths. The generator will return the "best fit"
49  * pattern corresponding to that skeleton.
50  * <p>The main method people will use is getBestPattern(String skeleton),
51  * since normally this class is pre-built with data from a particular locale.
52  * However, generators can be built directly from other data as well.
53  * <p><i>Issue: may be useful to also have a function that returns the list of
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      */
75     static DateTimePatternGenerator* U_EXPORT2 createInstance(const Locale& uLocale, UErrorCode& status);
76 
77 #ifndef U_HIDE_INTERNAL_API
78 
79     /**
80      * For ICU use only. Skips loading the standard date/time patterns (which is done via DateFormat).
81      *
82      * @internal
83      */
84     static DateTimePatternGenerator* U_EXPORT2 createInstanceNoStdPat(const Locale& uLocale, UErrorCode& status);
85 
86 #endif /* U_HIDE_INTERNAL_API */
87 
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);
95 
96     /**
97      * Destructor.
98      * @stable ICU 3.8
99      */
100     virtual ~DateTimePatternGenerator();
101 
102     /**
103      * Clone DateTimePatternGenerator object. Clients are responsible for
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     bool operator==(const DateTimePatternGenerator& other) const;
117 
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     bool operator!=(const DateTimePatternGenerator& other) const;
126 
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"
135      * @stable ICU 56
136      */
137     static UnicodeString staticGetSkeleton(const UnicodeString& pattern, UErrorCode& status);
138 
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".
142      * getSkeleton() works exactly like staticGetSkeleton().
143      * Use staticGetSkeleton() instead of getSkeleton().
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      */
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 
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"
169      * @stable ICU 56
170      */
171     static UnicodeString staticGetBaseSkeleton(const UnicodeString& pattern, UErrorCode& status);
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).
179      * getBaseSkeleton() works exactly like staticGetBaseSkeleton().
180      * Use staticGetBaseSkeleton() instead of getBaseSkeleton().
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.
185      * @return base skeleton, such as "MMMd"
186      * @stable ICU 3.8
187      */
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     }*/
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 overridden. Otherwise, the previous value is retained. In either
199      * case, the conflicting status is set and previous vale is stored in
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"
206      * @param override  When existing values are to be overridden use true,
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.
211      * @return conflicting status.  The value could be UDATPG_NO_CONFLICT,
212      *                             UDATPG_BASE_CONFLICT or UDATPG_CONFLICT.
213      * @stable ICU 3.8
214      */
215     UDateTimePatternConflict addPattern(const UnicodeString& pattern,
216                                         UBool override,
217                                         UnicodeString& conflictingPattern,
218                                         UErrorCode& status);
219 
220     /**
221      * An AppendItem format is a pattern used to append a field if there is no
222      * good match. For example, suppose that the input skeleton is "GyyyyMMMd",
223      * and there is no matching pattern internally, but there is a pattern
224      * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the
225      * G. The way these two are conjoined is by using the AppendItemFormat for G
226      * (era). So if that value is, say "{0}, {1}" then the final resulting
227      * pattern is "d-MM-yyyy, G".
228      * <p>
229      * There are actually three available variables: {0} is the pattern so far,
230      * {1} is the element we are adding, and {2} is the name of the element.
231      * <p>
232      * This reflects the way that the CLDR data is organized.
233      *
234      * @param field  such as UDATPG_ERA_FIELD.
235      * @param value  pattern, such as "{0}, {1}"
236      * @stable ICU 3.8
237      */
238     void setAppendItemFormat(UDateTimePatternField field, const UnicodeString& value);
239 
240     /**
241      * Getter corresponding to setAppendItemFormat. Values below 0 or at or
242      * above UDATPG_FIELD_COUNT are illegal arguments.
243      *
244      * @param  field  such as UDATPG_ERA_FIELD.
245      * @return append pattern for field
246      * @stable ICU 3.8
247      */
248     const UnicodeString& getAppendItemFormat(UDateTimePatternField field) const;
249 
250     /**
251      * Sets the names of field, eg "era" in English for ERA. These are only
252      * used if the corresponding AppendItemFormat is used, and if it contains a
253      * {2} variable.
254      * <p>
255      * This reflects the way that the CLDR data is organized.
256      *
257      * @param field   such as UDATPG_ERA_FIELD.
258      * @param value   name of the field
259      * @stable ICU 3.8
260      */
261     void setAppendItemName(UDateTimePatternField field, const UnicodeString& value);
262 
263     /**
264      * Getter corresponding to setAppendItemNames. Values below 0 or at or above
265      * UDATPG_FIELD_COUNT are illegal arguments. Note: The more general method
266      * for getting date/time field display names is getFieldDisplayName.
267      *
268      * @param field  such as UDATPG_ERA_FIELD.
269      * @return name for field
270      * @see getFieldDisplayName
271      * @stable ICU 3.8
272      */
273     const UnicodeString& getAppendItemName(UDateTimePatternField field) const;
274 
275     /**
276      * The general interface to get a display name for a particular date/time field,
277      * in one of several possible display widths.
278      *
279      * @param field  The desired UDateTimePatternField, such as UDATPG_ERA_FIELD.
280      * @param width  The desired UDateTimePGDisplayWidth, such as UDATPG_ABBREVIATED.
281      * @return       The display name for field
282      * @stable ICU 61
283      */
284     UnicodeString getFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width) const;
285 
286     /**
287      * The DateTimeFormat is a message format pattern used to compose date and
288      * time patterns. The default pattern in the root locale is "{1} {0}", where
289      * {1} will be replaced by the date pattern and {0} will be replaced by the
290      * time pattern; however, other locales may specify patterns such as
291      * "{1}, {0}" or "{1} 'at' {0}", etc.
292      * <p>
293      * This is used when the input skeleton contains both date and time fields,
294      * but there is not a close match among the added patterns. For example,
295      * suppose that this object was created by adding "dd-MMM" and "hh:mm", and
296      * its datetimeFormat is the default "{1} {0}". Then if the input skeleton
297      * is "MMMdhmm", there is not an exact match, so the input skeleton is
298      * broken up into two components "MMMd" and "hmm". There are close matches
299      * for those two skeletons, so the result is put together with this pattern,
300      * resulting in "d-MMM h:mm".
301      *
302      * There are four DateTimeFormats in a DateTimePatternGenerator object,
303      * corresponding to date styles UDAT_FULL..UDAT_SHORT. This method sets
304      * all of them to the specified pattern. To set them individually, see
305      * setDateTimeFormat(UDateFormatStyle style, ...).
306      *
307      * @param dateTimeFormat
308      *            message format pattern, here {1} will be replaced by the date
309      *            pattern and {0} will be replaced by the time pattern.
310      * @stable ICU 3.8
311      */
312     void setDateTimeFormat(const UnicodeString& dateTimeFormat);
313 
314     /**
315      * Getter corresponding to setDateTimeFormat.
316      *
317      * There are four DateTimeFormats in a DateTimePatternGenerator object,
318      * corresponding to date styles UDAT_FULL..UDAT_SHORT. This method gets
319      * the style for UDAT_MEDIUM (the default). To get them individually, see
320      * getDateTimeFormat(UDateFormatStyle style).
321      *
322      * @return DateTimeFormat.
323      * @stable ICU 3.8
324      */
325     const UnicodeString& getDateTimeFormat() const;
326 
327 #if !UCONFIG_NO_FORMATTING
328     /**
329      * dateTimeFormats are message patterns used to compose combinations of date
330      * and time patterns. There are four length styles, corresponding to the
331      * inferred style of the date pattern; these are UDateFormatStyle values:
332      *  - UDAT_FULL (for date pattern with weekday and long month), else
333      *  - UDAT_LONG (for a date pattern with long month), else
334      *  - UDAT_MEDIUM (for a date pattern with abbreviated month), else
335      *  - UDAT_SHORT (for any other date pattern).
336      * For details on dateTimeFormats, see
337      * https://www.unicode.org/reports/tr35/tr35-dates.html#dateTimeFormats.
338      * The default pattern in the root locale for all styles is "{1} {0}".
339      *
340      * @param style
341      *              one of DateFormat.FULL..DateFormat.SHORT. Error if out of range.
342      * @param dateTimeFormat
343      *              the new dateTimeFormat to set for the the specified style
344      * @param status
345      *              in/out parameter; if no failure status is already set,
346      *              it will be set according to result of the function (e.g.
347      *              U_ILLEGAL_ARGUMENT_ERROR for style out of range).
348      * @stable ICU 71
349      */
350     void setDateTimeFormat(UDateFormatStyle style, const UnicodeString& dateTimeFormat,
351                             UErrorCode& status);
352 
353     /**
354      * Getter corresponding to setDateTimeFormat.
355      *
356      * @param style
357      *              one of UDAT_FULL..UDAT_SHORT. Error if out of range.
358      * @param status
359      *              in/out parameter; if no failure status is already set,
360      *              it will be set according to result of the function (e.g.
361      *              U_ILLEGAL_ARGUMENT_ERROR for style out of range).
362      * @return
363      *              the current dateTimeFormat for the the specified style, or
364      *              empty string in case of error. The UnicodeString reference,
365      *              or the contents of the string, may no longer be valid if
366      *              setDateTimeFormat is called, or the DateTimePatternGenerator
367      *              object is deleted.
368      * @stable ICU 71
369      */
370     const UnicodeString& getDateTimeFormat(UDateFormatStyle style,
371                             UErrorCode& status) const;
372 #endif /* #if !UCONFIG_NO_FORMATTING */
373 
374     /**
375      * Return the best pattern matching the input skeleton. It is guaranteed to
376      * have all of the fields in the skeleton.
377      *
378      * @param skeleton
379      *            The skeleton is a pattern containing only the variable fields.
380      *            For example, "MMMdd" and "mmhh" are skeletons.
381      * @param status  Output param set to success/failure code on exit,
382      *               which must not indicate a failure before the function call.
383      * @return bestPattern
384      *            The best pattern found from the given skeleton.
385      * @stable ICU 3.8
386      */
387      UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status);
388 
389 
390     /**
391      * Return the best pattern matching the input skeleton. It is guaranteed to
392      * have all of the fields in the skeleton.
393      *
394      * @param skeleton
395      *            The skeleton is a pattern containing only the variable fields.
396      *            For example, "MMMdd" and "mmhh" are skeletons.
397      * @param options
398      *            Options for forcing the length of specified fields in the
399      *            returned pattern to match those in the skeleton (when this
400      *            would not happen otherwise). For default behavior, use
401      *            UDATPG_MATCH_NO_OPTIONS.
402      * @param status
403      *            Output param set to success/failure code on exit,
404      *            which must not indicate a failure before the function call.
405      * @return bestPattern
406      *            The best pattern found from the given skeleton.
407      * @stable ICU 4.4
408      */
409      UnicodeString getBestPattern(const UnicodeString& skeleton,
410                                   UDateTimePatternMatchOptions options,
411                                   UErrorCode& status);
412 
413 
414     /**
415      * Adjusts the field types (width and subtype) of a pattern to match what is
416      * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a
417      * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be
418      * "dd-MMMM hh:mm". This is used internally to get the best match for the
419      * input skeleton, but can also be used externally.
420      *
421      * @param pattern Input pattern
422      * @param skeleton
423      *            The skeleton is a pattern containing only the variable fields.
424      *            For example, "MMMdd" and "mmhh" are skeletons.
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 pattern adjusted to match the skeleton fields widths and subtypes.
428      * @stable ICU 3.8
429      */
430      UnicodeString replaceFieldTypes(const UnicodeString& pattern,
431                                      const UnicodeString& skeleton,
432                                      UErrorCode& status);
433 
434     /**
435      * Adjusts the field types (width and subtype) of a pattern to match what is
436      * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a
437      * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be
438      * "dd-MMMM hh:mm". This is used internally to get the best match for the
439      * input skeleton, but can also be used externally.
440      *
441      * @param pattern Input pattern
442      * @param skeleton
443      *            The skeleton is a pattern containing only the variable fields.
444      *            For example, "MMMdd" and "mmhh" are skeletons.
445      * @param options
446      *            Options controlling whether the length of specified fields in the
447      *            pattern are adjusted to match those in the skeleton (when this
448      *            would not happen otherwise). For default behavior, use
449      *            UDATPG_MATCH_NO_OPTIONS.
450      * @param status
451      *            Output param set to success/failure code on exit,
452      *            which must not indicate a failure before the function call.
453      * @return pattern adjusted to match the skeleton fields widths and subtypes.
454      * @stable ICU 4.4
455      */
456      UnicodeString replaceFieldTypes(const UnicodeString& pattern,
457                                      const UnicodeString& skeleton,
458                                      UDateTimePatternMatchOptions options,
459                                      UErrorCode& status);
460 
461     /**
462      * Return a list of all the skeletons (in canonical form) from this class.
463      *
464      * Call getPatternForSkeleton() to get the corresponding pattern.
465      *
466      * @param status  Output param set to success/failure code on exit,
467      *               which must not indicate a failure before the function call.
468      * @return StringEnumeration with the skeletons.
469      *         The caller must delete the object.
470      * @stable ICU 3.8
471      */
472      StringEnumeration* getSkeletons(UErrorCode& status) const;
473 
474      /**
475       * Get the pattern corresponding to a given skeleton.
476       * @param skeleton
477       * @return pattern corresponding to a given skeleton.
478       * @stable ICU 3.8
479       */
480      const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const;
481 
482     /**
483      * Return a list of all the base skeletons (in canonical form) from this class.
484      *
485      * @param status  Output param set to success/failure code on exit,
486      *               which must not indicate a failure before the function call.
487      * @return a StringEnumeration with the base skeletons.
488      *         The caller must delete the object.
489      * @stable ICU 3.8
490      */
491      StringEnumeration* getBaseSkeletons(UErrorCode& status) const;
492 
493 #ifndef U_HIDE_INTERNAL_API
494      /**
495       * Return a list of redundant patterns are those which if removed, make no
496       * difference in the resulting getBestPattern values. This method returns a
497       * list of them, to help check the consistency of the patterns used to build
498       * this generator.
499       *
500       * @param status  Output param set to success/failure code on exit,
501       *               which must not indicate a failure before the function call.
502       * @return a StringEnumeration with the redundant pattern.
503       *         The caller must delete the object.
504       * @internal ICU 3.8
505       */
506      StringEnumeration* getRedundants(UErrorCode& status);
507 #endif  /* U_HIDE_INTERNAL_API */
508 
509     /**
510      * The decimal value is used in formatting fractions of seconds. If the
511      * skeleton contains fractional seconds, then this is used with the
512      * fractional seconds. For example, suppose that the input pattern is
513      * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and
514      * the decimal string is ",". Then the resulting pattern is modified to be
515      * "H:mm:ss,SSSS"
516      *
517      * @param decimal
518      * @stable ICU 3.8
519      */
520     void setDecimal(const UnicodeString& decimal);
521 
522     /**
523      * Getter corresponding to setDecimal.
524      * @return UnicodeString corresponding to the decimal point
525      * @stable ICU 3.8
526      */
527     const UnicodeString& getDecimal() const;
528 
529 #if !UCONFIG_NO_FORMATTING
530 
531     /**
532      * Get the default hour cycle for a locale. Uses the locale that the
533      * DateTimePatternGenerator was initially created with.
534      *
535      * Cannot be used on an empty DateTimePatternGenerator instance.
536      *
537      * @param status  Output param set to success/failure code on exit, which
538      *                which must not indicate a failure before the function call.
539      *                Set to U_UNSUPPORTED_ERROR if used on an empty instance.
540      * @return the default hour cycle.
541      * @stable ICU 67
542      */
543     UDateFormatHourCycle getDefaultHourCycle(UErrorCode& status) const;
544 
545 #endif /* #if !UCONFIG_NO_FORMATTING */
546 
547     /**
548      * ICU "poor man's RTTI", returns a UClassID for the actual class.
549      *
550      * @stable ICU 3.8
551      */
552     virtual UClassID getDynamicClassID() const override;
553 
554     /**
555      * ICU "poor man's RTTI", returns a UClassID for this class.
556      *
557      * @stable ICU 3.8
558      */
559     static UClassID U_EXPORT2 getStaticClassID();
560 
561 private:
562     /**
563      * Constructor.
564      */
565     DateTimePatternGenerator(UErrorCode & status);
566 
567     /**
568      * Constructor.
569      */
570     DateTimePatternGenerator(const Locale& locale, UErrorCode & status, UBool skipStdPatterns = false);
571 
572     /**
573      * Copy constructor.
574      * @param other DateTimePatternGenerator to copy
575      */
576     DateTimePatternGenerator(const DateTimePatternGenerator& other);
577 
578     /**
579      * Default assignment operator.
580      * @param other DateTimePatternGenerator to copy
581      */
582     DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other);
583 
584     static const int32_t UDATPG_WIDTH_COUNT = UDATPG_NARROW + 1;
585 
586     Locale pLocale;  // pattern locale
587     FormatParser *fp;
588     DateTimeMatcher* dtMatcher;
589     DistanceInfo *distanceInfo;
590     PatternMap *patternMap;
591     UnicodeString appendItemFormats[UDATPG_FIELD_COUNT];
592     UnicodeString fieldDisplayNames[UDATPG_FIELD_COUNT][UDATPG_WIDTH_COUNT];
593     UnicodeString dateTimeFormat[4];
594     UnicodeString decimal;
595     DateTimeMatcher *skipMatcher;
596     Hashtable *fAvailableFormatKeyHash;
597     UnicodeString emptyString;
598     char16_t fDefaultHourFormatChar;
599 
600     int32_t fAllowedHourFormats[7];  // Actually an array of AllowedHourFormat enum type, ending with UNKNOWN.
601 
602     // Internal error code used for recording/reporting errors that occur during methods that do not
603     // have a UErrorCode parameter. For example: the Copy Constructor, or the ::clone() method.
604     // When this is set to an error the object is in an invalid state.
605     UErrorCode internalErrorCode;
606 
607     /* internal flags masks for adjustFieldTypes etc. */
608     enum {
609         kDTPGNoFlags = 0,
610         kDTPGFixFractionalSeconds = 1,
611         kDTPGSkeletonUsesCapJ = 2
612         // with #13183, no longer need flags for b, B
613     };
614 
615     void initData(const Locale &locale, UErrorCode &status, UBool skipStdPatterns = false);
616     void addCanonicalItems(UErrorCode &status);
617     void addICUPatterns(const Locale& locale, UErrorCode& status);
618     void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);
619     void getCalendarTypeToUse(const Locale& locale, CharString& destination, UErrorCode& err);
620     void consumeShortTimePattern(const UnicodeString& shortTimePattern, UErrorCode& status);
621     void addCLDRData(const Locale& locale, UErrorCode& status);
622     UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status);
623     void initHashtable(UErrorCode& status);
624     void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
625     void setDecimalSymbols(const Locale& locale, UErrorCode& status);
626     UDateTimePatternField getAppendFormatNumber(const char* field) const;
627     // Note for the next 3: UDateTimePGDisplayWidth is now stable ICU 61
628     UDateTimePatternField getFieldAndWidthIndices(const char* key, UDateTimePGDisplayWidth* widthP) const;
629     void setFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width, const UnicodeString& value);
630     UnicodeString& getMutableFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width);
631     void getAppendName(UDateTimePatternField field, UnicodeString& value);
632     UnicodeString mapSkeletonMetacharacters(const UnicodeString& patternForm, int32_t* flags, UErrorCode& status);
633     const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, UErrorCode& status, const PtnSkeleton** specifiedSkeletonPtr = nullptr);
634     UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
635     UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UErrorCode& status, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
636     int32_t getTopBitNumber(int32_t foundMask) const;
637     void setAvailableFormat(const UnicodeString &key, UErrorCode& status);
638     UBool isAvailableFormatSet(const UnicodeString &key) const;
639     void copyHashtable(Hashtable *other, UErrorCode &status);
640     UBool isCanonicalItem(const UnicodeString& item) const;
641     static void U_CALLCONV loadAllowedHourFormatsData(UErrorCode &status);
642     void getAllowedHourFormats(const Locale &locale, UErrorCode &status);
643 
644     struct U_HIDDEN AppendItemFormatsSink;
645     struct U_HIDDEN AppendItemNamesSink;
646     struct U_HIDDEN AvailableFormatsSink;
647 } ;// end class DateTimePatternGenerator
648 
649 U_NAMESPACE_END
650 
651 #endif /* U_SHOW_CPLUSPLUS_API */
652 
653 #endif
654