Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/unicode/dtfmtsym.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // © 2016 and later: Unicode, Inc. and others.
0002 // License & terms of use: http://www.unicode.org/copyright.html
0003 /*
0004 ********************************************************************************
0005 *   Copyright (C) 1997-2016, International Business Machines
0006 *   Corporation and others.  All Rights Reserved.
0007 ********************************************************************************
0008 *
0009 * File DTFMTSYM.H
0010 *
0011 * Modification History:
0012 *
0013 *   Date        Name        Description
0014 *   02/19/97    aliu        Converted from java.
0015 *    07/21/98    stephen        Added getZoneIndex()
0016 *                            Changed to match C++ conventions
0017 ********************************************************************************
0018 */
0019 
0020 #ifndef DTFMTSYM_H
0021 #define DTFMTSYM_H
0022 
0023 #include "unicode/utypes.h"
0024 
0025 #if U_SHOW_CPLUSPLUS_API
0026 
0027 #if !UCONFIG_NO_FORMATTING
0028 
0029 #include "unicode/calendar.h"
0030 #include "unicode/strenum.h"
0031 #include "unicode/uobject.h"
0032 #include "unicode/locid.h"
0033 #include "unicode/udat.h"
0034 #include "unicode/ures.h"
0035 
0036 /**
0037  * \file
0038  * \brief C++ API: Symbols for formatting dates.
0039  */
0040 
0041 U_NAMESPACE_BEGIN
0042 
0043 /* forward declaration */
0044 class SimpleDateFormat;
0045 class Hashtable;
0046 
0047 /**
0048  * DateFormatSymbols is a public class for encapsulating localizable date-time
0049  * formatting data -- including timezone data. DateFormatSymbols is used by
0050  * DateFormat and SimpleDateFormat.
0051  * <P>
0052  * Rather than first creating a DateFormatSymbols to get a date-time formatter
0053  * by using a SimpleDateFormat constructor, clients are encouraged to create a
0054  * date-time formatter using the getTimeInstance(), getDateInstance(), or
0055  * getDateTimeInstance() method in DateFormat. Each of these methods can return a
0056  * date/time formatter initialized with a default format pattern along with the
0057  * date-time formatting data for a given or default locale. After a formatter is
0058  * created, clients may modify the format pattern using the setPattern function
0059  * as so desired. For more information on using these formatter factory
0060  * functions, see DateFormat.
0061  * <P>
0062  * If clients decide to create a date-time formatter with a particular format
0063  * pattern and locale, they can do so with new SimpleDateFormat(aPattern,
0064  * new DateFormatSymbols(aLocale)).  This will load the appropriate date-time
0065  * formatting data from the locale.
0066  * <P>
0067  * DateFormatSymbols objects are clonable. When clients obtain a
0068  * DateFormatSymbols object, they can feel free to modify the date-time
0069  * formatting data as necessary. For instance, clients can
0070  * replace the localized date-time format pattern characters with the ones that
0071  * they feel easy to remember. Or they can change the representative cities
0072  * originally picked by default to using their favorite ones.
0073  * <P>
0074  * DateFormatSymbols are not expected to be subclassed. Data for a calendar is
0075  * loaded out of resource bundles.  The 'type' parameter indicates the type of
0076  * calendar, for example, "gregorian" or "japanese".  If the type is not gregorian
0077  * (or nullptr, or an empty string) then the type is appended to the resource name,
0078  * for example,  'Eras_japanese' instead of 'Eras'.   If the resource 'Eras_japanese' did
0079  * not exist (even in root), then this class will fall back to just 'Eras', that is,
0080  * Gregorian data.  Therefore, the calendar implementor MUST ensure that the root
0081  * locale at least contains any resources that are to be particularized for the
0082  * calendar type.
0083  */
0084 class U_I18N_API DateFormatSymbols final : public UObject  {
0085 public:
0086     /**
0087      * Construct a DateFormatSymbols object by loading format data from
0088      * resources for the default locale, in the default calendar (Gregorian).
0089      * <P>
0090      * NOTE: This constructor will never fail; if it cannot get resource
0091      * data for the default locale, it will return a last-resort object
0092      * based on hard-coded strings.
0093      *
0094      * @param status    Status code.  Failure
0095      *                  results if the resources for the default cannot be
0096      *                  found or cannot be loaded
0097      * @stable ICU 2.0
0098      */
0099     DateFormatSymbols(UErrorCode& status);
0100 
0101     /**
0102      * Construct a DateFormatSymbols object by loading format data from
0103      * resources for the given locale, in the default calendar (Gregorian).
0104      *
0105      * @param locale    Locale to load format data from.
0106      * @param status    Status code.  Failure
0107      *                  results if the resources for the locale cannot be
0108      *                  found or cannot be loaded
0109      * @stable ICU 2.0
0110      */
0111     DateFormatSymbols(const Locale& locale,
0112                       UErrorCode& status);
0113 
0114 #ifndef U_HIDE_INTERNAL_API
0115     /**
0116      * Construct a DateFormatSymbols object by loading format data from
0117      * resources for the default locale, in the default calendar (Gregorian).
0118      * <P>
0119      * NOTE: This constructor will never fail; if it cannot get resource
0120      * data for the default locale, it will return a last-resort object
0121      * based on hard-coded strings.
0122      *
0123      * @param type      Type of calendar (as returned by Calendar::getType).
0124      *                  Will be used to access the correct set of strings.
0125      *                  (nullptr or empty string defaults to "gregorian".)
0126      * @param status    Status code.  Failure
0127      *                  results if the resources for the default cannot be
0128      *                  found or cannot be loaded
0129      * @internal
0130      */
0131     DateFormatSymbols(const char *type, UErrorCode& status);
0132 
0133     /**
0134      * Construct a DateFormatSymbols object by loading format data from
0135      * resources for the given locale, in the default calendar (Gregorian).
0136      *
0137      * @param locale    Locale to load format data from.
0138      * @param type      Type of calendar (as returned by Calendar::getType).
0139      *                  Will be used to access the correct set of strings.
0140      *                  (nullptr or empty string defaults to "gregorian".)
0141      * @param status    Status code.  Failure
0142      *                  results if the resources for the locale cannot be
0143      *                  found or cannot be loaded
0144      * @internal
0145      */
0146     DateFormatSymbols(const Locale& locale,
0147                       const char *type,
0148                       UErrorCode& status);
0149 #endif  /* U_HIDE_INTERNAL_API */
0150 
0151     /**
0152      * Copy constructor.
0153      * @stable ICU 2.0
0154      */
0155     DateFormatSymbols(const DateFormatSymbols&);
0156 
0157     /**
0158      * Assignment operator.
0159      * @stable ICU 2.0
0160      */
0161     DateFormatSymbols& operator=(const DateFormatSymbols&);
0162 
0163     /**
0164      * Destructor. This is nonvirtual because this class is not designed to be
0165      * subclassed.
0166      * @stable ICU 2.0
0167      */
0168     virtual ~DateFormatSymbols();
0169 
0170     /**
0171      * Return true if another object is semantically equal to this one.
0172      *
0173      * @param other    the DateFormatSymbols object to be compared with.
0174      * @return         true if other is semantically equal to this.
0175      * @stable ICU 2.0
0176      */
0177     bool operator==(const DateFormatSymbols& other) const;
0178 
0179     /**
0180      * Return true if another object is semantically unequal to this one.
0181      *
0182      * @param other    the DateFormatSymbols object to be compared with.
0183      * @return         true if other is semantically unequal to this.
0184      * @stable ICU 2.0
0185      */
0186     bool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
0187 
0188     /**
0189      * Gets abbreviated era strings. For example: "AD" and "BC".
0190      *
0191      * @param count    Filled in with length of the array.
0192      * @return         the era strings.
0193      * @stable ICU 2.0
0194      */
0195     const UnicodeString* getEras(int32_t& count) const;
0196 
0197     /**
0198      * Sets abbreviated era strings. For example: "AD" and "BC".
0199      * @param eras  Array of era strings (DateFormatSymbols retains ownership.)
0200      * @param count Filled in with length of the array.
0201      * @stable ICU 2.0
0202      */
0203     void setEras(const UnicodeString* eras, int32_t count);
0204 
0205     /**
0206      * Gets era name strings. For example: "Anno Domini" and "Before Christ".
0207      *
0208      * @param count    Filled in with length of the array.
0209      * @return         the era name strings.
0210      * @stable ICU 3.4
0211      */
0212     const UnicodeString* getEraNames(int32_t& count) const;
0213 
0214     /**
0215      * Sets era name strings. For example: "Anno Domini" and "Before Christ".
0216      * @param eraNames  Array of era name strings (DateFormatSymbols retains ownership.)
0217      * @param count Filled in with length of the array.
0218      * @stable ICU 3.6
0219      */
0220     void setEraNames(const UnicodeString* eraNames, int32_t count);
0221 
0222     /**
0223      * Gets narrow era strings. For example: "A" and "B".
0224      *
0225      * @param count    Filled in with length of the array.
0226      * @return         the narrow era strings.
0227      * @stable ICU 4.2
0228      */
0229     const UnicodeString* getNarrowEras(int32_t& count) const;
0230 
0231     /**
0232      * Sets narrow era strings. For example: "A" and "B".
0233      * @param narrowEras  Array of narrow era strings (DateFormatSymbols retains ownership.)
0234      * @param count Filled in with length of the array.
0235      * @stable ICU 4.2
0236      */
0237     void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
0238 
0239     /**
0240      * Gets month strings. For example: "January", "February", etc.
0241      * @param count Filled in with length of the array.
0242      * @return the month strings. (DateFormatSymbols retains ownership.)
0243      * @stable ICU 2.0
0244      */
0245     const UnicodeString* getMonths(int32_t& count) const;
0246 
0247     /**
0248      * Sets month strings. For example: "January", "February", etc.
0249      *
0250      * @param months    the new month strings. (not adopted; caller retains ownership)
0251      * @param count     Filled in with length of the array.
0252      * @stable ICU 2.0
0253      */
0254     void setMonths(const UnicodeString* months, int32_t count);
0255 
0256     /**
0257      * Gets short month strings. For example: "Jan", "Feb", etc.
0258      *
0259      * @param count Filled in with length of the array.
0260      * @return the short month strings. (DateFormatSymbols retains ownership.)
0261      * @stable ICU 2.0
0262      */
0263     const UnicodeString* getShortMonths(int32_t& count) const;
0264 
0265     /**
0266      * Sets short month strings. For example: "Jan", "Feb", etc.
0267      * @param count        Filled in with length of the array.
0268      * @param shortMonths  the new short month strings. (not adopted; caller retains ownership)
0269      * @stable ICU 2.0
0270      */
0271     void setShortMonths(const UnicodeString* shortMonths, int32_t count);
0272 
0273     /**
0274      * Selector for date formatting context
0275      * @stable ICU 3.6
0276      */
0277     enum DtContextType {
0278         FORMAT,
0279         STANDALONE,
0280 #ifndef U_HIDE_DEPRECATED_API
0281         /**
0282          * One more than the highest normal DtContextType value.
0283          * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
0284          */
0285         DT_CONTEXT_COUNT
0286 #endif  // U_HIDE_DEPRECATED_API
0287     };
0288 
0289     /**
0290      * Selector for date formatting width
0291      * @stable ICU 3.6
0292      */
0293     enum DtWidthType {
0294         ABBREVIATED,
0295         WIDE,
0296         NARROW,
0297         /**
0298          * Short width is currently only supported for weekday names.
0299          * @stable ICU 51
0300          */
0301         SHORT,
0302 #ifndef U_HIDE_DEPRECATED_API
0303         /**
0304          * One more than the highest normal DtWidthType value.
0305          * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
0306          */
0307         DT_WIDTH_COUNT = 4
0308 #endif  // U_HIDE_DEPRECATED_API
0309     };
0310 
0311     /**
0312      * Gets month strings by width and context. For example: "January", "February", etc.
0313      * @param count Filled in with length of the array.
0314      * @param context The formatting context, either FORMAT or STANDALONE
0315      * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
0316      * @return the month strings. (DateFormatSymbols retains ownership.)
0317      * @stable ICU 3.4
0318      */
0319     const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
0320 
0321     /**
0322      * Sets month strings by width and context. For example: "January", "February", etc.
0323      *
0324      * @param months  The new month strings. (not adopted; caller retains ownership)
0325      * @param count   Filled in with length of the array.
0326      * @param context The formatting context, either FORMAT or STANDALONE
0327      * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
0328      * @stable ICU 3.6
0329      */
0330     void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
0331 
0332     /**
0333      * Gets wide weekday strings. For example: "Sunday", "Monday", etc.
0334      * @param count        Filled in with length of the array.
0335      * @return the weekday strings. (DateFormatSymbols retains ownership.)
0336      * @stable ICU 2.0
0337      */
0338     const UnicodeString* getWeekdays(int32_t& count) const;
0339 
0340 
0341     /**
0342      * Sets wide weekday strings. For example: "Sunday", "Monday", etc.
0343      * @param weekdays     the new weekday strings. (not adopted; caller retains ownership)
0344      * @param count        Filled in with length of the array.
0345      * @stable ICU 2.0
0346      */
0347     void setWeekdays(const UnicodeString* weekdays, int32_t count);
0348 
0349     /**
0350      * Gets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
0351      * misleading; it does not get the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
0352      * @param count        Filled in with length of the array.
0353      * @return             the abbreviated weekday strings. (DateFormatSymbols retains ownership.)
0354      * @stable ICU 2.0
0355      */
0356     const UnicodeString* getShortWeekdays(int32_t& count) const;
0357 
0358     /**
0359      * Sets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
0360      * misleading; it does not set the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
0361      * @param abbrevWeekdays  the new abbreviated weekday strings. (not adopted; caller retains ownership)
0362      * @param count           Filled in with length of the array.
0363      * @stable ICU 2.0
0364      */
0365     void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
0366 
0367     /**
0368      * Gets weekday strings by width and context. For example: "Sunday", "Monday", etc.
0369      * @param count   Filled in with length of the array.
0370      * @param context The formatting context, either FORMAT or STANDALONE
0371      * @param width   The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
0372      * @return the month strings. (DateFormatSymbols retains ownership.)
0373      * @stable ICU 3.4
0374      */
0375     const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
0376 
0377     /**
0378      * Sets weekday strings by width and context. For example: "Sunday", "Monday", etc.
0379      * @param weekdays  The new weekday strings. (not adopted; caller retains ownership)
0380      * @param count     Filled in with length of the array.
0381      * @param context   The formatting context, either FORMAT or STANDALONE
0382      * @param width     The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
0383      * @stable ICU 3.6
0384      */
0385     void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
0386 
0387     /**
0388      * Gets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
0389      * @param count Filled in with length of the array.
0390      * @param context The formatting context, either FORMAT or STANDALONE
0391      * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
0392      * @return the quarter strings. (DateFormatSymbols retains ownership.)
0393      * @stable ICU 3.6
0394      */
0395     const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
0396 
0397     /**
0398      * Sets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
0399      *
0400      * @param quarters  The new quarter strings. (not adopted; caller retains ownership)
0401      * @param count   Filled in with length of the array.
0402      * @param context The formatting context, either FORMAT or STANDALONE
0403      * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
0404      * @stable ICU 3.6
0405      */
0406     void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
0407 
0408     /**
0409      * Gets AM/PM strings. For example: "AM" and "PM".
0410      * @param count        Filled in with length of the array.
0411      * @return             the weekday strings. (DateFormatSymbols retains ownership.)
0412      * @stable ICU 2.0
0413      */
0414     const UnicodeString* getAmPmStrings(int32_t& count) const;
0415 
0416     /**
0417      * Sets ampm strings. For example: "AM" and "PM".
0418      * @param ampms        the new ampm strings. (not adopted; caller retains ownership)
0419      * @param count        Filled in with length of the array.
0420      * @stable ICU 2.0
0421      */
0422     void setAmPmStrings(const UnicodeString* ampms, int32_t count);
0423 
0424 #ifndef U_HIDE_INTERNAL_API
0425     /**
0426      * This default time separator is used for formatting when the locale
0427      * doesn't specify any time separator, and always recognized when parsing.
0428      * @internal
0429      */
0430     static const char16_t DEFAULT_TIME_SEPARATOR = 0x003a;  // ':'
0431 
0432     /**
0433      * This alternate time separator is always recognized when parsing.
0434      * @internal
0435      */
0436     static const char16_t ALTERNATE_TIME_SEPARATOR = 0x002e;  // '.'
0437 
0438     /**
0439      * Gets the time separator string. For example: ":".
0440      * @param result Output param which will receive the time separator string.
0441      * @return       A reference to 'result'.
0442      * @internal
0443      */
0444     UnicodeString& getTimeSeparatorString(UnicodeString& result) const;
0445 
0446     /**
0447      * Sets the time separator string. For example: ":".
0448      * @param newTimeSeparator the new time separator string.
0449      * @internal
0450      */
0451     void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
0452 #endif  /* U_HIDE_INTERNAL_API */
0453 
0454     /**
0455      * Gets cyclic year name strings if the calendar has them, by width and context.
0456      * For example: "jia-zi", "yi-chou", etc.
0457      * @param count     Filled in with length of the array.
0458      * @param context   The usage context: FORMAT, STANDALONE.
0459      * @param width     The requested name width: WIDE, ABBREVIATED, NARROW.
0460      * @return          The year name strings (DateFormatSymbols retains ownership),
0461      *                  or null if they are not available for this calendar.
0462      * @stable ICU 54
0463      */
0464     const UnicodeString* getYearNames(int32_t& count,
0465                             DtContextType context, DtWidthType width) const;
0466 
0467     /**
0468      * Sets cyclic year name strings by width and context. For example: "jia-zi", "yi-chou", etc.
0469      *
0470      * @param yearNames The new cyclic year name strings (not adopted; caller retains ownership).
0471      * @param count     The length of the array.
0472      * @param context   The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
0473      * @param width     The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
0474      * @stable ICU 54
0475      */
0476     void setYearNames(const UnicodeString* yearNames, int32_t count,
0477                             DtContextType context, DtWidthType width);
0478 
0479     /**
0480      * Gets calendar zodiac name strings if the calendar has them, by width and context.
0481      * For example: "Rat", "Ox", "Tiger", etc.
0482      * @param count     Filled in with length of the array.
0483      * @param context   The usage context: FORMAT, STANDALONE.
0484      * @param width     The requested name width: WIDE, ABBREVIATED, NARROW.
0485      * @return          The zodiac name strings (DateFormatSymbols retains ownership),
0486      *                  or null if they are not available for this calendar.
0487      * @stable ICU 54
0488      */
0489     const UnicodeString* getZodiacNames(int32_t& count,
0490                             DtContextType context, DtWidthType width) const;
0491 
0492     /**
0493      * Sets calendar zodiac name strings by width and context. For example: "Rat", "Ox", "Tiger", etc.
0494      *
0495      * @param zodiacNames The new zodiac name strings (not adopted; caller retains ownership).
0496      * @param count     The length of the array.
0497      * @param context   The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
0498      * @param width     The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
0499      * @stable ICU 54
0500      */
0501     void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
0502                             DtContextType context, DtWidthType width);
0503 
0504 #ifndef U_HIDE_INTERNAL_API
0505     /**
0506      * Somewhat temporary constants for leap month pattern types, adequate for supporting
0507      * just leap month patterns as needed for Chinese lunar calendar.
0508      * Eventually we will add full support for different month pattern types (needed for
0509      * other calendars such as Hindu) at which point this approach will be replaced by a
0510      * more complete approach.
0511      * @internal
0512      */
0513     enum EMonthPatternType
0514     {
0515         kLeapMonthPatternFormatWide,
0516         kLeapMonthPatternFormatAbbrev,
0517         kLeapMonthPatternFormatNarrow,
0518         kLeapMonthPatternStandaloneWide,
0519         kLeapMonthPatternStandaloneAbbrev,
0520         kLeapMonthPatternStandaloneNarrow,
0521         kLeapMonthPatternNumeric,
0522         kMonthPatternsCount
0523     };
0524 
0525     /**
0526      * Somewhat temporary function for getting complete set of leap month patterns for all
0527      * contexts & widths, indexed by EMonthPatternType values. Returns nullptr if calendar
0528      * does not have leap month patterns. Note, there is currently no setter for this.
0529      * Eventually we will add full support for different month pattern types (needed for
0530      * other calendars such as Hindu) at which point this approach will be replaced by a
0531      * more complete approach.
0532      * @param count        Filled in with length of the array (may be 0).
0533      * @return             The leap month patterns (DateFormatSymbols retains ownership).
0534      *                     May be nullptr if there are no leap month patterns for this calendar.
0535      * @internal
0536      */
0537     const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
0538 
0539 #endif  /* U_HIDE_INTERNAL_API */
0540 
0541 #ifndef U_HIDE_DEPRECATED_API
0542     /**
0543      * Gets timezone strings. These strings are stored in a 2-dimensional array.
0544      * @param rowCount      Output param to receive number of rows.
0545      * @param columnCount   Output param to receive number of columns.
0546      * @return              The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.)
0547      * @deprecated ICU 3.6
0548      */
0549     const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
0550 #endif  /* U_HIDE_DEPRECATED_API */
0551 
0552     /**
0553      * Sets timezone strings. These strings are stored in a 2-dimensional array.
0554      * <p><b>Note:</b> SimpleDateFormat no longer use the zone strings stored in
0555      * a DateFormatSymbols. Therefore, the time zone strings set by this method
0556      * have no effects in an instance of SimpleDateFormat for formatting time
0557      * zones.
0558      * @param strings       The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership)
0559      * @param rowCount      The number of rows (count of first index).
0560      * @param columnCount   The number of columns (count of second index).
0561      * @stable ICU 2.0
0562      */
0563     void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
0564 
0565     /**
0566      * Get the non-localized date-time pattern characters.
0567      * @return    the non-localized date-time pattern characters
0568      * @stable ICU 2.0
0569      */
0570     static const char16_t * U_EXPORT2 getPatternUChars(void);
0571 
0572     /**
0573      * Gets localized date-time pattern characters. For example: 'u', 't', etc.
0574      * <p>
0575      * Note: ICU no longer provides localized date-time pattern characters for a locale
0576      * starting ICU 3.8.  This method returns the non-localized date-time pattern
0577      * characters unless user defined localized data is set by setLocalPatternChars.
0578      * @param result    Output param which will receive the localized date-time pattern characters.
0579      * @return          A reference to 'result'.
0580      * @stable ICU 2.0
0581      */
0582     UnicodeString& getLocalPatternChars(UnicodeString& result) const;
0583 
0584     /**
0585      * Sets localized date-time pattern characters. For example: 'u', 't', etc.
0586      * @param newLocalPatternChars the new localized date-time
0587      * pattern characters.
0588      * @stable ICU 2.0
0589      */
0590     void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
0591 
0592     /**
0593      * Returns the locale for this object. Two flavors are available:
0594      * valid and actual locale.
0595      * @stable ICU 2.8
0596      */
0597     Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
0598 
0599     /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
0600        they are needed for .h file declarations. */ 
0601     /**
0602      * Constants for capitalization context usage types.
0603      * @internal
0604      */
0605     enum ECapitalizationContextUsageType
0606     {
0607 #ifndef U_HIDE_INTERNAL_API
0608         kCapContextUsageOther = 0,
0609         kCapContextUsageMonthFormat,     /* except narrow */
0610         kCapContextUsageMonthStandalone, /* except narrow */
0611         kCapContextUsageMonthNarrow,
0612         kCapContextUsageDayFormat,     /* except narrow */
0613         kCapContextUsageDayStandalone, /* except narrow */
0614         kCapContextUsageDayNarrow,
0615         kCapContextUsageEraWide,
0616         kCapContextUsageEraAbbrev,
0617         kCapContextUsageEraNarrow,
0618         kCapContextUsageZoneLong,
0619         kCapContextUsageZoneShort,
0620         kCapContextUsageMetazoneLong,
0621         kCapContextUsageMetazoneShort,
0622 #endif /* U_HIDE_INTERNAL_API */
0623         kCapContextUsageTypeCount = 14
0624     };
0625 
0626     /**
0627      * ICU "poor man's RTTI", returns a UClassID for the actual class.
0628      *
0629      * @stable ICU 2.2
0630      */
0631     virtual UClassID getDynamicClassID() const override;
0632 
0633     /**
0634      * ICU "poor man's RTTI", returns a UClassID for this class.
0635      *
0636      * @stable ICU 2.2
0637      */
0638     static UClassID U_EXPORT2 getStaticClassID();
0639 
0640 private:
0641 
0642     friend class SimpleDateFormat;
0643     friend class DateFormatSymbolsSingleSetter; // see udat.cpp
0644 
0645     /**
0646      * Abbreviated era strings. For example: "AD" and "BC".
0647      */
0648     UnicodeString*  fEras;
0649     int32_t         fErasCount;
0650 
0651     /**
0652      * Era name strings. For example: "Anno Domini" and "Before Christ".
0653      */
0654     UnicodeString*  fEraNames;
0655     int32_t         fEraNamesCount;
0656 
0657     /**
0658      * Narrow era strings. For example: "A" and "B".
0659      */
0660     UnicodeString*  fNarrowEras;
0661     int32_t         fNarrowErasCount;
0662 
0663     /**
0664      * Month strings. For example: "January", "February", etc.
0665      */
0666     UnicodeString*  fMonths;
0667     int32_t         fMonthsCount;
0668 
0669     /**
0670      * Short month strings. For example: "Jan", "Feb", etc.
0671      */
0672     UnicodeString*  fShortMonths;
0673     int32_t         fShortMonthsCount;
0674 
0675     /**
0676      * Narrow month strings. For example: "J", "F", etc.
0677      */
0678     UnicodeString*  fNarrowMonths;
0679     int32_t         fNarrowMonthsCount;
0680 
0681     /**
0682      * Standalone Month strings. For example: "January", "February", etc.
0683      */
0684     UnicodeString*  fStandaloneMonths;
0685     int32_t         fStandaloneMonthsCount;
0686 
0687     /**
0688      * Standalone Short month strings. For example: "Jan", "Feb", etc.
0689      */
0690     UnicodeString*  fStandaloneShortMonths;
0691     int32_t         fStandaloneShortMonthsCount;
0692 
0693     /**
0694      * Standalone Narrow month strings. For example: "J", "F", etc.
0695      */
0696     UnicodeString*  fStandaloneNarrowMonths;
0697     int32_t         fStandaloneNarrowMonthsCount;
0698 
0699     /**
0700      * CLDR-style format wide weekday strings. For example: "Sunday", "Monday", etc.
0701      */
0702     UnicodeString*  fWeekdays;
0703     int32_t         fWeekdaysCount;
0704 
0705     /**
0706      * CLDR-style format abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
0707      */
0708     UnicodeString*  fShortWeekdays;
0709     int32_t         fShortWeekdaysCount;
0710 
0711     /**
0712      * CLDR-style format short weekday strings. For example: "Su", "Mo", etc.
0713      */
0714     UnicodeString*  fShorterWeekdays;
0715     int32_t         fShorterWeekdaysCount;
0716 
0717     /**
0718      * CLDR-style format narrow weekday strings. For example: "S", "M", etc.
0719      */
0720     UnicodeString*  fNarrowWeekdays;
0721     int32_t         fNarrowWeekdaysCount;
0722 
0723     /**
0724      * CLDR-style standalone wide weekday strings. For example: "Sunday", "Monday", etc.
0725      */
0726     UnicodeString*  fStandaloneWeekdays;
0727     int32_t         fStandaloneWeekdaysCount;
0728 
0729     /**
0730      * CLDR-style standalone abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
0731      */
0732     UnicodeString*  fStandaloneShortWeekdays;
0733     int32_t         fStandaloneShortWeekdaysCount;
0734 
0735     /**
0736      * CLDR-style standalone short weekday strings. For example: "Su", "Mo", etc.
0737      */
0738     UnicodeString*  fStandaloneShorterWeekdays;
0739     int32_t         fStandaloneShorterWeekdaysCount;
0740 
0741     /**
0742      * Standalone Narrow weekday strings. For example: "Sun", "Mon", etc.
0743      */
0744     UnicodeString*  fStandaloneNarrowWeekdays;
0745     int32_t         fStandaloneNarrowWeekdaysCount;
0746 
0747     /**
0748      * Ampm strings. For example: "AM" and "PM".
0749      */
0750     UnicodeString*  fAmPms;
0751     int32_t         fAmPmsCount;
0752 
0753     /**
0754      * Narrow Ampm strings. For example: "a" and "p".
0755      */
0756     UnicodeString*  fNarrowAmPms;
0757     int32_t         fNarrowAmPmsCount;
0758 
0759     /**
0760      * Time separator string. For example: ":".
0761      */
0762     UnicodeString   fTimeSeparator;
0763 
0764     /**
0765      * Quarter strings. For example: "1st quarter", "2nd quarter", etc.
0766      */
0767     UnicodeString  *fQuarters;
0768     int32_t         fQuartersCount;
0769 
0770     /**
0771      * Short quarters. For example: "Q1", "Q2", etc.
0772      */
0773     UnicodeString  *fShortQuarters;
0774     int32_t         fShortQuartersCount;
0775 
0776     /**
0777      * Narrow quarters. For example: "1", "2", etc.
0778      * (In many, but not all, locales, this is the same as "Q", but there are locales for which this isn't true.)
0779      */
0780     UnicodeString  *fNarrowQuarters;
0781     int32_t         fNarrowQuartersCount;
0782     
0783     /**
0784      * Standalone quarter strings. For example: "1st quarter", "2nd quarter", etc.
0785      */
0786     UnicodeString  *fStandaloneQuarters;
0787     int32_t         fStandaloneQuartersCount;
0788 
0789     /**
0790      * Standalone short quarter strings. For example: "Q1", "Q2", etc.
0791      */
0792     UnicodeString  *fStandaloneShortQuarters;
0793     int32_t         fStandaloneShortQuartersCount;
0794 
0795     /**
0796      * Standalone narrow quarter strings. For example: "1", "2", etc.
0797      * (In many, but not all, locales, this is the same as "q", but there are locales for which this isn't true.)
0798      */
0799     UnicodeString  *fStandaloneNarrowQuarters;
0800     int32_t         fStandaloneNarrowQuartersCount;
0801     
0802     /**
0803      * All leap month patterns, for example "{0}bis".
0804      */
0805     UnicodeString  *fLeapMonthPatterns;
0806     int32_t         fLeapMonthPatternsCount;
0807 
0808     /**
0809      * Cyclic year names, for example: "jia-zi", "yi-chou", ... "gui-hai";
0810      * currently we only have data for format/abbreviated.
0811      * For the others, just get from format/abbreviated, ignore set.
0812      */
0813     UnicodeString  *fShortYearNames;
0814     int32_t         fShortYearNamesCount;
0815 
0816     /**
0817      * Cyclic zodiac names, for example "Rat", "Ox", "Tiger", etc.;
0818      * currently we only have data for format/abbreviated.
0819      * For the others, just get from format/abbreviated, ignore set.
0820      */
0821     UnicodeString  *fShortZodiacNames;
0822     int32_t         fShortZodiacNamesCount;
0823 
0824     /**
0825      * Localized names of time zones in this locale.  This is a
0826      * two-dimensional array of strings of size n by m,
0827      * where m is at least 5 and up to 7.  Each of the n rows is an
0828      * entry containing the localized names for a single TimeZone.
0829      *
0830      * Each such row contains (with i ranging from 0..n-1):
0831      * 
0832      * zoneStrings[i][0] - time zone ID
0833      *  example: America/Los_Angeles
0834      * zoneStrings[i][1] - long name of zone in standard time
0835      *  example: Pacific Standard Time
0836      * zoneStrings[i][2] - short name of zone in standard time
0837      *  example: PST
0838      * zoneStrings[i][3] - long name of zone in daylight savings time
0839      *  example: Pacific Daylight Time
0840      * zoneStrings[i][4] - short name of zone in daylight savings time
0841      *  example: PDT
0842      * zoneStrings[i][5] - location name of zone
0843      *  example: United States (Los Angeles)
0844      * zoneStrings[i][6] - long generic name of zone
0845      *  example: Pacific Time
0846      * zoneStrings[i][7] - short generic of zone
0847      *  example: PT
0848      *
0849      * The zone ID is not localized; it corresponds to the ID
0850      * value associated with a system time zone object.  All other entries
0851      * are localized names.  If a zone does not implement daylight savings
0852      * time, the daylight savings time names are ignored.
0853      *
0854      * Note:CLDR 1.5 introduced metazone and its historical mappings.
0855      * This simple two-dimensional array is no longer sufficient to represent
0856      * localized names and its historic changes.  Since ICU 3.8.1, localized
0857      * zone names extracted from ICU locale data is stored in a ZoneStringFormat
0858      * instance.  But we still need to support the old way of customizing
0859      * localized zone names, so we keep this field for the purpose.
0860      */
0861     UnicodeString   **fZoneStrings;         // Zone string array set by setZoneStrings
0862     UnicodeString   **fLocaleZoneStrings;   // Zone string array created by the locale
0863     int32_t         fZoneStringsRowCount;
0864     int32_t         fZoneStringsColCount;
0865 
0866     Locale                  fZSFLocale;         // Locale used for getting ZoneStringFormat
0867 
0868     /**
0869      * Localized date-time pattern characters. For example: use 'u' as 'y'.
0870      */
0871     UnicodeString   fLocalPatternChars;
0872 
0873     /**
0874      * Capitalization transforms. For each usage type, the first array element indicates
0875      * whether to titlecase for uiListOrMenu context, the second indicates whether to
0876      * titlecase for stand-alone context.
0877      */
0878      UBool fCapitalization[kCapContextUsageTypeCount][2];
0879 
0880     /**
0881      * Abbreviated (== short) day period strings.
0882      */
0883     UnicodeString  *fAbbreviatedDayPeriods;
0884     int32_t         fAbbreviatedDayPeriodsCount;
0885 
0886     /**
0887      * Wide day period strings.
0888      */
0889     UnicodeString  *fWideDayPeriods;
0890     int32_t         fWideDayPeriodsCount;
0891 
0892     /**
0893      * Narrow day period strings.
0894      */
0895     UnicodeString  *fNarrowDayPeriods;
0896     int32_t         fNarrowDayPeriodsCount;
0897 
0898     /**
0899      * Stand-alone abbreviated (== short) day period strings.
0900      */
0901     UnicodeString  *fStandaloneAbbreviatedDayPeriods;
0902     int32_t         fStandaloneAbbreviatedDayPeriodsCount;
0903 
0904     /**
0905      * Stand-alone wide day period strings.
0906      */
0907     UnicodeString  *fStandaloneWideDayPeriods;
0908     int32_t         fStandaloneWideDayPeriodsCount;
0909 
0910     /**
0911      * Stand-alone narrow day period strings.
0912      */
0913     UnicodeString  *fStandaloneNarrowDayPeriods;
0914     int32_t         fStandaloneNarrowDayPeriodsCount;
0915 
0916 private:
0917     /** valid/actual locale information 
0918      *  these are always ICU locales, so the length should not be a problem
0919      */
0920     char validLocale[ULOC_FULLNAME_CAPACITY];
0921     char actualLocale[ULOC_FULLNAME_CAPACITY];
0922 
0923     DateFormatSymbols() = delete; // default constructor not implemented
0924 
0925     /**
0926      * Called by the constructors to actually load data from the resources
0927      *
0928      * @param locale               The locale to get symbols for.
0929      * @param type                 Calendar Type (as from Calendar::getType())
0930      * @param status               Input/output parameter, set to success or
0931      *                             failure code upon return.
0932      * @param useLastResortData    determine if use last resort data
0933      */
0934     void initializeData(const Locale& locale, const char *type,
0935                         UErrorCode& status, UBool useLastResortData = false);
0936 
0937     /**
0938      * Copy or alias an array in another object, as appropriate.
0939      *
0940      * @param dstArray    the copy destination array.
0941      * @param dstCount    fill in with the length of 'dstArray'.
0942      * @param srcArray    the source array to be copied.
0943      * @param srcCount    the length of items to be copied from the 'srcArray'.
0944      */
0945     static void assignArray(UnicodeString*& dstArray,
0946                             int32_t& dstCount,
0947                             const UnicodeString* srcArray,
0948                             int32_t srcCount);
0949 
0950     /**
0951      * Return true if the given arrays' contents are equal, or if the arrays are
0952      * identical (pointers are equal).
0953      *
0954      * @param array1   one array to be compared with.
0955      * @param array2   another array to be compared with.
0956      * @param count    the length of items to be copied.
0957      * @return         true if the given arrays' contents are equal, or if the arrays are
0958      *                 identical (pointers are equal).
0959      */
0960     static UBool arrayCompare(const UnicodeString* array1,
0961                              const UnicodeString* array2,
0962                              int32_t count);
0963 
0964     /**
0965      * Create a copy, in fZoneStrings, of the given zone strings array. The
0966      * member variables fZoneStringsRowCount and fZoneStringsColCount should be
0967      * set already by the caller.
0968      */
0969     void createZoneStrings(const UnicodeString *const * otherStrings);
0970 
0971     /**
0972      * Delete all the storage owned by this object.
0973      */
0974     void dispose(void);
0975 
0976     /**
0977      * Copy all of the other's data to this.
0978      * @param other the object to be copied.
0979      */
0980     void copyData(const DateFormatSymbols& other);
0981 
0982     /**
0983      * Create zone strings array by locale if not yet available
0984      */
0985     void initZoneStringsArray(void);
0986 
0987     /**
0988      * Delete just the zone strings.
0989      */
0990     void disposeZoneStrings(void);
0991 
0992     /**
0993      * Returns the date format field index of the pattern character c,
0994      * or UDAT_FIELD_COUNT if c is not a pattern character.
0995      */
0996     static UDateFormatField U_EXPORT2 getPatternCharIndex(char16_t c);
0997 
0998     /**
0999      * 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