• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ********************************************************************************
5 *   Copyright (C) 1997-2016, International Business Machines
6 *   Corporation and others.  All Rights Reserved.
7 ********************************************************************************
8 *
9 * File DTFMTSYM.H
10 *
11 * Modification History:
12 *
13 *   Date        Name        Description
14 *   02/19/97    aliu        Converted from java.
15 *    07/21/98    stephen        Added getZoneIndex()
16 *                            Changed to match C++ conventions
17 ********************************************************************************
18 */
19 
20 #ifndef DTFMTSYM_H
21 #define DTFMTSYM_H
22 
23 #include "unicode/utypes.h"
24 
25 #if U_SHOW_CPLUSPLUS_API
26 
27 #if !UCONFIG_NO_FORMATTING
28 
29 #include "unicode/calendar.h"
30 #include "unicode/strenum.h"
31 #include "unicode/uobject.h"
32 #include "unicode/locid.h"
33 #include "unicode/udat.h"
34 #include "unicode/ures.h"
35 
36 /**
37  * \file
38  * \brief C++ API: Symbols for formatting dates.
39  */
40 
41 U_NAMESPACE_BEGIN
42 
43 /* forward declaration */
44 class SimpleDateFormat;
45 class Hashtable;
46 
47 /**
48  * DateFormatSymbols is a public class for encapsulating localizable date-time
49  * formatting data -- including timezone data. DateFormatSymbols is used by
50  * DateFormat and SimpleDateFormat.
51  * <P>
52  * Rather than first creating a DateFormatSymbols to get a date-time formatter
53  * by using a SimpleDateFormat constructor, clients are encouraged to create a
54  * date-time formatter using the getTimeInstance(), getDateInstance(), or
55  * getDateTimeInstance() method in DateFormat. Each of these methods can return a
56  * date/time formatter initialized with a default format pattern along with the
57  * date-time formatting data for a given or default locale. After a formatter is
58  * created, clients may modify the format pattern using the setPattern function
59  * as so desired. For more information on using these formatter factory
60  * functions, see DateFormat.
61  * <P>
62  * If clients decide to create a date-time formatter with a particular format
63  * pattern and locale, they can do so with new SimpleDateFormat(aPattern,
64  * new DateFormatSymbols(aLocale)).  This will load the appropriate date-time
65  * formatting data from the locale.
66  * <P>
67  * DateFormatSymbols objects are clonable. When clients obtain a
68  * DateFormatSymbols object, they can feel free to modify the date-time
69  * formatting data as necessary. For instance, clients can
70  * replace the localized date-time format pattern characters with the ones that
71  * they feel easy to remember. Or they can change the representative cities
72  * originally picked by default to using their favorite ones.
73  * <P>
74  * DateFormatSymbols are not expected to be subclassed. Data for a calendar is
75  * loaded out of resource bundles.  The 'type' parameter indicates the type of
76  * calendar, for example, "gregorian" or "japanese".  If the type is not gregorian
77  * (or NULL, or an empty string) then the type is appended to the resource name,
78  * for example,  'Eras_japanese' instead of 'Eras'.   If the resource 'Eras_japanese' did
79  * not exist (even in root), then this class will fall back to just 'Eras', that is,
80  * Gregorian data.  Therefore, the calendar implementor MUST ensure that the root
81  * locale at least contains any resources that are to be particularized for the
82  * calendar type.
83  */
84 class U_I18N_API DateFormatSymbols U_FINAL : public UObject  {
85 public:
86     /**
87      * Construct a DateFormatSymbols object by loading format data from
88      * resources for the default locale, in the default calendar (Gregorian).
89      * <P>
90      * NOTE: This constructor will never fail; if it cannot get resource
91      * data for the default locale, it will return a last-resort object
92      * based on hard-coded strings.
93      *
94      * @param status    Status code.  Failure
95      *                  results if the resources for the default cannot be
96      *                  found or cannot be loaded
97      * @stable ICU 2.0
98      */
99     DateFormatSymbols(UErrorCode& status);
100 
101     /**
102      * Construct a DateFormatSymbols object by loading format data from
103      * resources for the given locale, in the default calendar (Gregorian).
104      *
105      * @param locale    Locale to load format data from.
106      * @param status    Status code.  Failure
107      *                  results if the resources for the locale cannot be
108      *                  found or cannot be loaded
109      * @stable ICU 2.0
110      */
111     DateFormatSymbols(const Locale& locale,
112                       UErrorCode& status);
113 
114 #ifndef U_HIDE_INTERNAL_API
115     /**
116      * Construct a DateFormatSymbols object by loading format data from
117      * resources for the default locale, in the default calendar (Gregorian).
118      * <P>
119      * NOTE: This constructor will never fail; if it cannot get resource
120      * data for the default locale, it will return a last-resort object
121      * based on hard-coded strings.
122      *
123      * @param type      Type of calendar (as returned by Calendar::getType).
124      *                  Will be used to access the correct set of strings.
125      *                  (NULL or empty string defaults to "gregorian".)
126      * @param status    Status code.  Failure
127      *                  results if the resources for the default cannot be
128      *                  found or cannot be loaded
129      * @internal
130      */
131     DateFormatSymbols(const char *type, UErrorCode& status);
132 
133     /**
134      * Construct a DateFormatSymbols object by loading format data from
135      * resources for the given locale, in the default calendar (Gregorian).
136      *
137      * @param locale    Locale to load format data from.
138      * @param type      Type of calendar (as returned by Calendar::getType).
139      *                  Will be used to access the correct set of strings.
140      *                  (NULL or empty string defaults to "gregorian".)
141      * @param status    Status code.  Failure
142      *                  results if the resources for the locale cannot be
143      *                  found or cannot be loaded
144      * @internal
145      */
146     DateFormatSymbols(const Locale& locale,
147                       const char *type,
148                       UErrorCode& status);
149 #endif  /* U_HIDE_INTERNAL_API */
150 
151     /**
152      * Copy constructor.
153      * @stable ICU 2.0
154      */
155     DateFormatSymbols(const DateFormatSymbols&);
156 
157     /**
158      * Assignment operator.
159      * @stable ICU 2.0
160      */
161     DateFormatSymbols& operator=(const DateFormatSymbols&);
162 
163     /**
164      * Destructor. This is nonvirtual because this class is not designed to be
165      * subclassed.
166      * @stable ICU 2.0
167      */
168     virtual ~DateFormatSymbols();
169 
170     /**
171      * Return true if another object is semantically equal to this one.
172      *
173      * @param other    the DateFormatSymbols object to be compared with.
174      * @return         true if other is semantically equal to this.
175      * @stable ICU 2.0
176      */
177     bool operator==(const DateFormatSymbols& other) const;
178 
179     /**
180      * Return true if another object is semantically unequal to this one.
181      *
182      * @param other    the DateFormatSymbols object to be compared with.
183      * @return         true if other is semantically unequal to this.
184      * @stable ICU 2.0
185      */
186     bool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
187 
188     /**
189      * Gets abbreviated era strings. For example: "AD" and "BC".
190      *
191      * @param count    Filled in with length of the array.
192      * @return         the era strings.
193      * @stable ICU 2.0
194      */
195     const UnicodeString* getEras(int32_t& count) const;
196 
197     /**
198      * Sets abbreviated era strings. For example: "AD" and "BC".
199      * @param eras  Array of era strings (DateFormatSymbols retains ownership.)
200      * @param count Filled in with length of the array.
201      * @stable ICU 2.0
202      */
203     void setEras(const UnicodeString* eras, int32_t count);
204 
205     /**
206      * Gets era name strings. For example: "Anno Domini" and "Before Christ".
207      *
208      * @param count    Filled in with length of the array.
209      * @return         the era name strings.
210      * @stable ICU 3.4
211      */
212     const UnicodeString* getEraNames(int32_t& count) const;
213 
214     /**
215      * Sets era name strings. For example: "Anno Domini" and "Before Christ".
216      * @param eraNames  Array of era name strings (DateFormatSymbols retains ownership.)
217      * @param count Filled in with length of the array.
218      * @stable ICU 3.6
219      */
220     void setEraNames(const UnicodeString* eraNames, int32_t count);
221 
222     /**
223      * Gets narrow era strings. For example: "A" and "B".
224      *
225      * @param count    Filled in with length of the array.
226      * @return         the narrow era strings.
227      * @stable ICU 4.2
228      */
229     const UnicodeString* getNarrowEras(int32_t& count) const;
230 
231     /**
232      * Sets narrow era strings. For example: "A" and "B".
233      * @param narrowEras  Array of narrow era strings (DateFormatSymbols retains ownership.)
234      * @param count Filled in with length of the array.
235      * @stable ICU 4.2
236      */
237     void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
238 
239     /**
240      * Gets month strings. For example: "January", "February", etc.
241      * @param count Filled in with length of the array.
242      * @return the month strings. (DateFormatSymbols retains ownership.)
243      * @stable ICU 2.0
244      */
245     const UnicodeString* getMonths(int32_t& count) const;
246 
247     /**
248      * Sets month strings. For example: "January", "February", etc.
249      *
250      * @param months    the new month strings. (not adopted; caller retains ownership)
251      * @param count     Filled in with length of the array.
252      * @stable ICU 2.0
253      */
254     void setMonths(const UnicodeString* months, int32_t count);
255 
256     /**
257      * Gets short month strings. For example: "Jan", "Feb", etc.
258      *
259      * @param count Filled in with length of the array.
260      * @return the short month strings. (DateFormatSymbols retains ownership.)
261      * @stable ICU 2.0
262      */
263     const UnicodeString* getShortMonths(int32_t& count) const;
264 
265     /**
266      * Sets short month strings. For example: "Jan", "Feb", etc.
267      * @param count        Filled in with length of the array.
268      * @param shortMonths  the new short month strings. (not adopted; caller retains ownership)
269      * @stable ICU 2.0
270      */
271     void setShortMonths(const UnicodeString* shortMonths, int32_t count);
272 
273     /**
274      * Selector for date formatting context
275      * @stable ICU 3.6
276      */
277     enum DtContextType {
278         FORMAT,
279         STANDALONE,
280 #ifndef U_HIDE_DEPRECATED_API
281         /**
282          * One more than the highest normal DtContextType value.
283          * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
284          */
285         DT_CONTEXT_COUNT
286 #endif  // U_HIDE_DEPRECATED_API
287     };
288 
289     /**
290      * Selector for date formatting width
291      * @stable ICU 3.6
292      */
293     enum DtWidthType {
294         ABBREVIATED,
295         WIDE,
296         NARROW,
297         /**
298          * Short width is currently only supported for weekday names.
299          * @stable ICU 51
300          */
301         SHORT,
302 #ifndef U_HIDE_DEPRECATED_API
303         /**
304          * One more than the highest normal DtWidthType value.
305          * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
306          */
307         DT_WIDTH_COUNT = 4
308 #endif  // U_HIDE_DEPRECATED_API
309     };
310 
311     /**
312      * Gets month strings by width and context. For example: "January", "February", etc.
313      * @param count Filled in with length of the array.
314      * @param context The formatting context, either FORMAT or STANDALONE
315      * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
316      * @return the month strings. (DateFormatSymbols retains ownership.)
317      * @stable ICU 3.4
318      */
319     const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
320 
321     /**
322      * Sets month strings by width and context. For example: "January", "February", etc.
323      *
324      * @param months  The new month strings. (not adopted; caller retains ownership)
325      * @param count   Filled in with length of the array.
326      * @param context The formatting context, either FORMAT or STANDALONE
327      * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
328      * @stable ICU 3.6
329      */
330     void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
331 
332     /**
333      * Gets wide weekday strings. For example: "Sunday", "Monday", etc.
334      * @param count        Filled in with length of the array.
335      * @return the weekday strings. (DateFormatSymbols retains ownership.)
336      * @stable ICU 2.0
337      */
338     const UnicodeString* getWeekdays(int32_t& count) const;
339 
340 
341     /**
342      * Sets wide weekday strings. For example: "Sunday", "Monday", etc.
343      * @param weekdays     the new weekday strings. (not adopted; caller retains ownership)
344      * @param count        Filled in with length of the array.
345      * @stable ICU 2.0
346      */
347     void setWeekdays(const UnicodeString* weekdays, int32_t count);
348 
349     /**
350      * Gets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
351      * misleading; it does not get the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
352      * @param count        Filled in with length of the array.
353      * @return             the abbreviated weekday strings. (DateFormatSymbols retains ownership.)
354      * @stable ICU 2.0
355      */
356     const UnicodeString* getShortWeekdays(int32_t& count) const;
357 
358     /**
359      * Sets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
360      * misleading; it does not set the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
361      * @param abbrevWeekdays  the new abbreviated weekday strings. (not adopted; caller retains ownership)
362      * @param count           Filled in with length of the array.
363      * @stable ICU 2.0
364      */
365     void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
366 
367     /**
368      * Gets weekday strings by width and context. For example: "Sunday", "Monday", etc.
369      * @param count   Filled in with length of the array.
370      * @param context The formatting context, either FORMAT or STANDALONE
371      * @param width   The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
372      * @return the month strings. (DateFormatSymbols retains ownership.)
373      * @stable ICU 3.4
374      */
375     const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
376 
377     /**
378      * Sets weekday strings by width and context. For example: "Sunday", "Monday", etc.
379      * @param weekdays  The new weekday strings. (not adopted; caller retains ownership)
380      * @param count     Filled in with length of the array.
381      * @param context   The formatting context, either FORMAT or STANDALONE
382      * @param width     The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
383      * @stable ICU 3.6
384      */
385     void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
386 
387     /**
388      * Gets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
389      * @param count Filled in with length of the array.
390      * @param context The formatting context, either FORMAT or STANDALONE
391      * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
392      * @return the quarter strings. (DateFormatSymbols retains ownership.)
393      * @stable ICU 3.6
394      */
395     const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
396 
397     /**
398      * Sets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
399      *
400      * @param quarters  The new quarter strings. (not adopted; caller retains ownership)
401      * @param count   Filled in with length of the array.
402      * @param context The formatting context, either FORMAT or STANDALONE
403      * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
404      * @stable ICU 3.6
405      */
406     void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
407 
408     /**
409      * Gets AM/PM strings. For example: "AM" and "PM".
410      * @param count        Filled in with length of the array.
411      * @return             the weekday strings. (DateFormatSymbols retains ownership.)
412      * @stable ICU 2.0
413      */
414     const UnicodeString* getAmPmStrings(int32_t& count) const;
415 
416     /**
417      * Sets ampm strings. For example: "AM" and "PM".
418      * @param ampms        the new ampm strings. (not adopted; caller retains ownership)
419      * @param count        Filled in with length of the array.
420      * @stable ICU 2.0
421      */
422     void setAmPmStrings(const UnicodeString* ampms, int32_t count);
423 
424 #ifndef U_HIDE_INTERNAL_API
425     /**
426      * This default time separator is used for formatting when the locale
427      * doesn't specify any time separator, and always recognized when parsing.
428      * @internal
429      */
430     static const char16_t DEFAULT_TIME_SEPARATOR = 0x003a;  // ':'
431 
432     /**
433      * This alternate time separator is always recognized when parsing.
434      * @internal
435      */
436     static const char16_t ALTERNATE_TIME_SEPARATOR = 0x002e;  // '.'
437 
438     /**
439      * Gets the time separator string. For example: ":".
440      * @param result Output param which will receive the time separator string.
441      * @return       A reference to 'result'.
442      * @internal
443      */
444     UnicodeString& getTimeSeparatorString(UnicodeString& result) const;
445 
446     /**
447      * Sets the time separator string. For example: ":".
448      * @param newTimeSeparator the new time separator string.
449      * @internal
450      */
451     void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
452 #endif  /* U_HIDE_INTERNAL_API */
453 
454     /**
455      * Gets cyclic year name strings if the calendar has them, by width and context.
456      * For example: "jia-zi", "yi-chou", etc.
457      * @param count     Filled in with length of the array.
458      * @param context   The usage context: FORMAT, STANDALONE.
459      * @param width     The requested name width: WIDE, ABBREVIATED, NARROW.
460      * @return          The year name strings (DateFormatSymbols retains ownership),
461      *                  or null if they are not available for this calendar.
462      * @stable ICU 54
463      */
464     const UnicodeString* getYearNames(int32_t& count,
465                             DtContextType context, DtWidthType width) const;
466 
467     /**
468      * Sets cyclic year name strings by width and context. For example: "jia-zi", "yi-chou", etc.
469      *
470      * @param yearNames The new cyclic year name strings (not adopted; caller retains ownership).
471      * @param count     The length of the array.
472      * @param context   The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
473      * @param width     The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
474      * @stable ICU 54
475      */
476     void setYearNames(const UnicodeString* yearNames, int32_t count,
477                             DtContextType context, DtWidthType width);
478 
479     /**
480      * Gets calendar zodiac name strings if the calendar has them, by width and context.
481      * For example: "Rat", "Ox", "Tiger", etc.
482      * @param count     Filled in with length of the array.
483      * @param context   The usage context: FORMAT, STANDALONE.
484      * @param width     The requested name width: WIDE, ABBREVIATED, NARROW.
485      * @return          The zodiac name strings (DateFormatSymbols retains ownership),
486      *                  or null if they are not available for this calendar.
487      * @stable ICU 54
488      */
489     const UnicodeString* getZodiacNames(int32_t& count,
490                             DtContextType context, DtWidthType width) const;
491 
492     /**
493      * Sets calendar zodiac name strings by width and context. For example: "Rat", "Ox", "Tiger", etc.
494      *
495      * @param zodiacNames The new zodiac name strings (not adopted; caller retains ownership).
496      * @param count     The length of the array.
497      * @param context   The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
498      * @param width     The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
499      * @stable ICU 54
500      */
501     void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
502                             DtContextType context, DtWidthType width);
503 
504 #ifndef U_HIDE_INTERNAL_API
505     /**
506      * Somewhat temporary constants for leap month pattern types, adequate for supporting
507      * just leap month patterns as needed for Chinese lunar calendar.
508      * Eventually we will add full support for different month pattern types (needed for
509      * other calendars such as Hindu) at which point this approach will be replaced by a
510      * more complete approach.
511      * @internal
512      */
513     enum EMonthPatternType
514     {
515         kLeapMonthPatternFormatWide,
516         kLeapMonthPatternFormatAbbrev,
517         kLeapMonthPatternFormatNarrow,
518         kLeapMonthPatternStandaloneWide,
519         kLeapMonthPatternStandaloneAbbrev,
520         kLeapMonthPatternStandaloneNarrow,
521         kLeapMonthPatternNumeric,
522         kMonthPatternsCount
523     };
524 
525     /**
526      * Somewhat temporary function for getting complete set of leap month patterns for all
527      * contexts & widths, indexed by EMonthPatternType values. Returns NULL if calendar
528      * does not have leap month patterns. Note, there is currently no setter for this.
529      * Eventually we will add full support for different month pattern types (needed for
530      * other calendars such as Hindu) at which point this approach will be replaced by a
531      * more complete approach.
532      * @param count        Filled in with length of the array (may be 0).
533      * @return             The leap month patterns (DateFormatSymbols retains ownership).
534      *                     May be NULL if there are no leap month patterns for this calendar.
535      * @internal
536      */
537     const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
538 
539 #endif  /* U_HIDE_INTERNAL_API */
540 
541 #ifndef U_HIDE_DEPRECATED_API
542     /**
543      * Gets timezone strings. These strings are stored in a 2-dimensional array.
544      * @param rowCount      Output param to receive number of rows.
545      * @param columnCount   Output param to receive number of columns.
546      * @return              The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.)
547      * @deprecated ICU 3.6
548      */
549     const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
550 #endif  /* U_HIDE_DEPRECATED_API */
551 
552     /**
553      * Sets timezone strings. These strings are stored in a 2-dimensional array.
554      * <p><b>Note:</b> SimpleDateFormat no longer use the zone strings stored in
555      * a DateFormatSymbols. Therefore, the time zone strings set by this method
556      * have no effects in an instance of SimpleDateFormat for formatting time
557      * zones.
558      * @param strings       The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership)
559      * @param rowCount      The number of rows (count of first index).
560      * @param columnCount   The number of columns (count of second index).
561      * @stable ICU 2.0
562      */
563     void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
564 
565     /**
566      * Get the non-localized date-time pattern characters.
567      * @return    the non-localized date-time pattern characters
568      * @stable ICU 2.0
569      */
570     static const char16_t * U_EXPORT2 getPatternUChars(void);
571 
572     /**
573      * Gets localized date-time pattern characters. For example: 'u', 't', etc.
574      * <p>
575      * Note: ICU no longer provides localized date-time pattern characters for a locale
576      * starting ICU 3.8.  This method returns the non-localized date-time pattern
577      * characters unless user defined localized data is set by setLocalPatternChars.
578      * @param result    Output param which will receive the localized date-time pattern characters.
579      * @return          A reference to 'result'.
580      * @stable ICU 2.0
581      */
582     UnicodeString& getLocalPatternChars(UnicodeString& result) const;
583 
584     /**
585      * Sets localized date-time pattern characters. For example: 'u', 't', etc.
586      * @param newLocalPatternChars the new localized date-time
587      * pattern characters.
588      * @stable ICU 2.0
589      */
590     void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
591 
592     /**
593      * Returns the locale for this object. Two flavors are available:
594      * valid and actual locale.
595      * @stable ICU 2.8
596      */
597     Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
598 
599     /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
600        they are needed for .h file declarations. */
601     /**
602      * Constants for capitalization context usage types.
603      * @internal
604      */
605     enum ECapitalizationContextUsageType
606     {
607 #ifndef U_HIDE_INTERNAL_API
608         kCapContextUsageOther = 0,
609         kCapContextUsageMonthFormat,     /* except narrow */
610         kCapContextUsageMonthStandalone, /* except narrow */
611         kCapContextUsageMonthNarrow,
612         kCapContextUsageDayFormat,     /* except narrow */
613         kCapContextUsageDayStandalone, /* except narrow */
614         kCapContextUsageDayNarrow,
615         kCapContextUsageEraWide,
616         kCapContextUsageEraAbbrev,
617         kCapContextUsageEraNarrow,
618         kCapContextUsageZoneLong,
619         kCapContextUsageZoneShort,
620         kCapContextUsageMetazoneLong,
621         kCapContextUsageMetazoneShort,
622 #endif /* U_HIDE_INTERNAL_API */
623         kCapContextUsageTypeCount = 14
624     };
625 
626     /**
627      * ICU "poor man's RTTI", returns a UClassID for the actual class.
628      *
629      * @stable ICU 2.2
630      */
631     virtual UClassID getDynamicClassID() const override;
632 
633     /**
634      * ICU "poor man's RTTI", returns a UClassID for this class.
635      *
636      * @stable ICU 2.2
637      */
638     static UClassID U_EXPORT2 getStaticClassID();
639 
640 private:
641 
642     friend class SimpleDateFormat;
643     friend class DateFormatSymbolsSingleSetter; // see udat.cpp
644 
645     /**
646      * Abbreviated era strings. For example: "AD" and "BC".
647      */
648     UnicodeString*  fEras;
649     int32_t         fErasCount;
650 
651     /**
652      * Era name strings. For example: "Anno Domini" and "Before Christ".
653      */
654     UnicodeString*  fEraNames;
655     int32_t         fEraNamesCount;
656 
657     /**
658      * Narrow era strings. For example: "A" and "B".
659      */
660     UnicodeString*  fNarrowEras;
661     int32_t         fNarrowErasCount;
662 
663     /**
664      * Month strings. For example: "January", "February", etc.
665      */
666     UnicodeString*  fMonths;
667     int32_t         fMonthsCount;
668 
669     /**
670      * Short month strings. For example: "Jan", "Feb", etc.
671      */
672     UnicodeString*  fShortMonths;
673     int32_t         fShortMonthsCount;
674 
675     /**
676      * Narrow month strings. For example: "J", "F", etc.
677      */
678     UnicodeString*  fNarrowMonths;
679     int32_t         fNarrowMonthsCount;
680 
681     /**
682      * Standalone Month strings. For example: "January", "February", etc.
683      */
684     UnicodeString*  fStandaloneMonths;
685     int32_t         fStandaloneMonthsCount;
686 
687     /**
688      * Standalone Short month strings. For example: "Jan", "Feb", etc.
689      */
690     UnicodeString*  fStandaloneShortMonths;
691     int32_t         fStandaloneShortMonthsCount;
692 
693     /**
694      * Standalone Narrow month strings. For example: "J", "F", etc.
695      */
696     UnicodeString*  fStandaloneNarrowMonths;
697     int32_t         fStandaloneNarrowMonthsCount;
698 
699     /**
700      * CLDR-style format wide weekday strings. For example: "Sunday", "Monday", etc.
701      */
702     UnicodeString*  fWeekdays;
703     int32_t         fWeekdaysCount;
704 
705     /**
706      * CLDR-style format abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
707      */
708     UnicodeString*  fShortWeekdays;
709     int32_t         fShortWeekdaysCount;
710 
711     /**
712      * CLDR-style format short weekday strings. For example: "Su", "Mo", etc.
713      */
714     UnicodeString*  fShorterWeekdays;
715     int32_t         fShorterWeekdaysCount;
716 
717     /**
718      * CLDR-style format narrow weekday strings. For example: "S", "M", etc.
719      */
720     UnicodeString*  fNarrowWeekdays;
721     int32_t         fNarrowWeekdaysCount;
722 
723     /**
724      * CLDR-style standalone wide weekday strings. For example: "Sunday", "Monday", etc.
725      */
726     UnicodeString*  fStandaloneWeekdays;
727     int32_t         fStandaloneWeekdaysCount;
728 
729     /**
730      * CLDR-style standalone abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
731      */
732     UnicodeString*  fStandaloneShortWeekdays;
733     int32_t         fStandaloneShortWeekdaysCount;
734 
735     /**
736      * CLDR-style standalone short weekday strings. For example: "Su", "Mo", etc.
737      */
738     UnicodeString*  fStandaloneShorterWeekdays;
739     int32_t         fStandaloneShorterWeekdaysCount;
740 
741     /**
742      * Standalone Narrow weekday strings. For example: "Sun", "Mon", etc.
743      */
744     UnicodeString*  fStandaloneNarrowWeekdays;
745     int32_t         fStandaloneNarrowWeekdaysCount;
746 
747     /**
748      * Ampm strings. For example: "AM" and "PM".
749      */
750     UnicodeString*  fAmPms;
751     int32_t         fAmPmsCount;
752 
753     /**
754      * Narrow Ampm strings. For example: "a" and "p".
755      */
756     UnicodeString*  fNarrowAmPms;
757     int32_t         fNarrowAmPmsCount;
758 
759     /**
760      * Time separator string. For example: ":".
761      */
762     UnicodeString   fTimeSeparator;
763 
764     /**
765      * Quarter strings. For example: "1st quarter", "2nd quarter", etc.
766      */
767     UnicodeString  *fQuarters;
768     int32_t         fQuartersCount;
769 
770     /**
771      * Short quarters. For example: "Q1", "Q2", etc.
772      */
773     UnicodeString  *fShortQuarters;
774     int32_t         fShortQuartersCount;
775 
776     /**
777      * Narrow quarters. For example: "1", "2", etc.
778      * (In many, but not all, locales, this is the same as "Q", but there are locales for which this isn't true.)
779      */
780     UnicodeString  *fNarrowQuarters;
781     int32_t         fNarrowQuartersCount;
782 
783     /**
784      * Standalone quarter strings. For example: "1st quarter", "2nd quarter", etc.
785      */
786     UnicodeString  *fStandaloneQuarters;
787     int32_t         fStandaloneQuartersCount;
788 
789     /**
790      * Standalone short quarter strings. For example: "Q1", "Q2", etc.
791      */
792     UnicodeString  *fStandaloneShortQuarters;
793     int32_t         fStandaloneShortQuartersCount;
794 
795     /**
796      * Standalone narrow quarter strings. For example: "1", "2", etc.
797      * (In many, but not all, locales, this is the same as "q", but there are locales for which this isn't true.)
798      */
799     UnicodeString  *fStandaloneNarrowQuarters;
800     int32_t         fStandaloneNarrowQuartersCount;
801 
802     /**
803      * All leap month patterns, for example "{0}bis".
804      */
805     UnicodeString  *fLeapMonthPatterns;
806     int32_t         fLeapMonthPatternsCount;
807 
808     /**
809      * Cyclic year names, for example: "jia-zi", "yi-chou", ... "gui-hai";
810      * currently we only have data for format/abbreviated.
811      * For the others, just get from format/abbreviated, ignore set.
812      */
813     UnicodeString  *fShortYearNames;
814     int32_t         fShortYearNamesCount;
815 
816     /**
817      * Cyclic zodiac names, for example "Rat", "Ox", "Tiger", etc.;
818      * currently we only have data for format/abbreviated.
819      * For the others, just get from format/abbreviated, ignore set.
820      */
821     UnicodeString  *fShortZodiacNames;
822     int32_t         fShortZodiacNamesCount;
823 
824     /**
825      * Localized names of time zones in this locale.  This is a
826      * two-dimensional array of strings of size n by m,
827      * where m is at least 5 and up to 7.  Each of the n rows is an
828      * entry containing the localized names for a single TimeZone.
829      *
830      * Each such row contains (with i ranging from 0..n-1):
831      *
832      * zoneStrings[i][0] - time zone ID
833      *  example: America/Los_Angeles
834      * zoneStrings[i][1] - long name of zone in standard time
835      *  example: Pacific Standard Time
836      * zoneStrings[i][2] - short name of zone in standard time
837      *  example: PST
838      * zoneStrings[i][3] - long name of zone in daylight savings time
839      *  example: Pacific Daylight Time
840      * zoneStrings[i][4] - short name of zone in daylight savings time
841      *  example: PDT
842      * zoneStrings[i][5] - location name of zone
843      *  example: United States (Los Angeles)
844      * zoneStrings[i][6] - long generic name of zone
845      *  example: Pacific Time
846      * zoneStrings[i][7] - short generic of zone
847      *  example: PT
848      *
849      * The zone ID is not localized; it corresponds to the ID
850      * value associated with a system time zone object.  All other entries
851      * are localized names.  If a zone does not implement daylight savings
852      * time, the daylight savings time names are ignored.
853      *
854      * Note:CLDR 1.5 introduced metazone and its historical mappings.
855      * This simple two-dimensional array is no longer sufficient to represent
856      * localized names and its historic changes.  Since ICU 3.8.1, localized
857      * zone names extracted from ICU locale data is stored in a ZoneStringFormat
858      * instance.  But we still need to support the old way of customizing
859      * localized zone names, so we keep this field for the purpose.
860      */
861     UnicodeString   **fZoneStrings;         // Zone string array set by setZoneStrings
862     UnicodeString   **fLocaleZoneStrings;   // Zone string array created by the locale
863     int32_t         fZoneStringsRowCount;
864     int32_t         fZoneStringsColCount;
865 
866     Locale                  fZSFLocale;         // Locale used for getting ZoneStringFormat
867 
868     /**
869      * Localized date-time pattern characters. For example: use 'u' as 'y'.
870      */
871     UnicodeString   fLocalPatternChars;
872 
873     /**
874      * Capitalization transforms. For each usage type, the first array element indicates
875      * whether to titlecase for uiListOrMenu context, the second indicates whether to
876      * titlecase for stand-alone context.
877      */
878      UBool fCapitalization[kCapContextUsageTypeCount][2];
879 
880     /**
881      * Abbreviated (== short) day period strings.
882      */
883     UnicodeString  *fAbbreviatedDayPeriods;
884     int32_t         fAbbreviatedDayPeriodsCount;
885 
886     /**
887      * Wide day period strings.
888      */
889     UnicodeString  *fWideDayPeriods;
890     int32_t         fWideDayPeriodsCount;
891 
892     /**
893      * Narrow day period strings.
894      */
895     UnicodeString  *fNarrowDayPeriods;
896     int32_t         fNarrowDayPeriodsCount;
897 
898     /**
899      * Stand-alone abbreviated (== short) day period strings.
900      */
901     UnicodeString  *fStandaloneAbbreviatedDayPeriods;
902     int32_t         fStandaloneAbbreviatedDayPeriodsCount;
903 
904     /**
905      * Stand-alone wide day period strings.
906      */
907     UnicodeString  *fStandaloneWideDayPeriods;
908     int32_t         fStandaloneWideDayPeriodsCount;
909 
910     /**
911      * Stand-alone narrow day period strings.
912      */
913     UnicodeString  *fStandaloneNarrowDayPeriods;
914     int32_t         fStandaloneNarrowDayPeriodsCount;
915 
916 private:
917     /** valid/actual locale information
918      *  these are always ICU locales, so the length should not be a problem
919      */
920     char validLocale[ULOC_FULLNAME_CAPACITY];
921     char actualLocale[ULOC_FULLNAME_CAPACITY];
922 
923     DateFormatSymbols() = delete; // default constructor not implemented
924 
925     /**
926      * Called by the constructors to actually load data from the resources
927      *
928      * @param locale               The locale to get symbols for.
929      * @param type                 Calendar Type (as from Calendar::getType())
930      * @param status               Input/output parameter, set to success or
931      *                             failure code upon return.
932      * @param useLastResortData    determine if use last resort data
933      */
934     void initializeData(const Locale& locale, const char *type,
935                         UErrorCode& status, UBool useLastResortData = false);
936 
937     /**
938      * Copy or alias an array in another object, as appropriate.
939      *
940      * @param dstArray    the copy destination array.
941      * @param dstCount    fill in with the length of 'dstArray'.
942      * @param srcArray    the source array to be copied.
943      * @param srcCount    the length of items to be copied from the 'srcArray'.
944      */
945     static void assignArray(UnicodeString*& dstArray,
946                             int32_t& dstCount,
947                             const UnicodeString* srcArray,
948                             int32_t srcCount);
949 
950     /**
951      * Return true if the given arrays' contents are equal, or if the arrays are
952      * identical (pointers are equal).
953      *
954      * @param array1   one array to be compared with.
955      * @param array2   another array to be compared with.
956      * @param count    the length of items to be copied.
957      * @return         true if the given arrays' contents are equal, or if the arrays are
958      *                 identical (pointers are equal).
959      */
960     static UBool arrayCompare(const UnicodeString* array1,
961                              const UnicodeString* array2,
962                              int32_t count);
963 
964     /**
965      * Create a copy, in fZoneStrings, of the given zone strings array. The
966      * member variables fZoneStringsRowCount and fZoneStringsColCount should be
967      * set already by the caller.
968      */
969     void createZoneStrings(const UnicodeString *const * otherStrings);
970 
971     /**
972      * Delete all the storage owned by this object.
973      */
974     void dispose(void);
975 
976     /**
977      * Copy all of the other's data to this.
978      * @param other the object to be copied.
979      */
980     void copyData(const DateFormatSymbols& other);
981 
982     /**
983      * Create zone strings array by locale if not yet available
984      */
985     void initZoneStringsArray(void);
986 
987     /**
988      * Delete just the zone strings.
989      */
990     void disposeZoneStrings(void);
991 
992     /**
993      * Returns the date format field index of the pattern character c,
994      * or UDAT_FIELD_COUNT if c is not a pattern character.
995      */
996     static UDateFormatField U_EXPORT2 getPatternCharIndex(char16_t c);
997 
998     /**
999      * Returns true if f (with its pattern character repeated count times) is a numeric field.
1000      */
1001     static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
1002 
1003     /**
1004      * Returns true if c (repeated count times) is the pattern character for a numeric field.
1005      */
1006     static UBool U_EXPORT2 isNumericPatternChar(char16_t c, int32_t count);
1007 public:
1008 #ifndef U_HIDE_INTERNAL_API
1009     /**
1010      * Gets a DateFormatSymbols by locale.
1011      * Unlike the constructors which always use gregorian calendar, this
1012      * method uses the calendar in the locale. If the locale contains no
1013      * explicit calendar, this method uses the default calendar for that
1014      * locale.
1015      * @param locale the locale.
1016      * @param status error returned here.
1017      * @return the new DateFormatSymbols which the caller owns.
1018      * @internal For ICU use only.
1019      */
1020     static DateFormatSymbols * U_EXPORT2 createForLocale(
1021             const Locale &locale, UErrorCode &status);
1022 #endif  /* U_HIDE_INTERNAL_API */
1023 };
1024 
1025 U_NAMESPACE_END
1026 
1027 #endif /* #if !UCONFIG_NO_FORMATTING */
1028 
1029 #endif /* U_SHOW_CPLUSPLUS_API */
1030 
1031 #endif // _DTFMTSYM
1032 //eof
1033