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