michael@0: /* michael@0: ******************************************************************************** michael@0: * Copyright (C) 1997-2013, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ******************************************************************************** michael@0: * michael@0: * File DTFMTSYM.H michael@0: * michael@0: * Modification History: michael@0: * michael@0: * Date Name Description michael@0: * 02/19/97 aliu Converted from java. michael@0: * 07/21/98 stephen Added getZoneIndex() michael@0: * Changed to match C++ conventions michael@0: ******************************************************************************** michael@0: */ michael@0: michael@0: #ifndef DTFMTSYM_H michael@0: #define DTFMTSYM_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #include "unicode/calendar.h" michael@0: #include "unicode/uobject.h" michael@0: #include "unicode/locid.h" michael@0: #include "unicode/udat.h" michael@0: #include "unicode/ures.h" michael@0: michael@0: /** michael@0: * \file michael@0: * \brief C++ API: Symbols for formatting dates. michael@0: */ michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: /* forward declaration */ michael@0: class SimpleDateFormat; michael@0: class Hashtable; michael@0: michael@0: /** michael@0: * DateFormatSymbols is a public class for encapsulating localizable date-time michael@0: * formatting data -- including timezone data. DateFormatSymbols is used by michael@0: * DateFormat and SimpleDateFormat. michael@0: *
michael@0: * Rather than first creating a DateFormatSymbols to get a date-time formatter michael@0: * by using a SimpleDateFormat constructor, clients are encouraged to create a michael@0: * date-time formatter using the getTimeInstance(), getDateInstance(), or michael@0: * getDateTimeInstance() method in DateFormat. Each of these methods can return a michael@0: * date/time formatter initialized with a default format pattern along with the michael@0: * date-time formatting data for a given or default locale. After a formatter is michael@0: * created, clients may modify the format pattern using the setPattern function michael@0: * as so desired. For more information on using these formatter factory michael@0: * functions, see DateFormat. michael@0: *
michael@0: * If clients decide to create a date-time formatter with a particular format michael@0: * pattern and locale, they can do so with new SimpleDateFormat(aPattern, michael@0: * new DateFormatSymbols(aLocale)). This will load the appropriate date-time michael@0: * formatting data from the locale. michael@0: *
michael@0: * DateFormatSymbols objects are clonable. When clients obtain a michael@0: * DateFormatSymbols object, they can feel free to modify the date-time michael@0: * formatting data as necessary. For instance, clients can michael@0: * replace the localized date-time format pattern characters with the ones that michael@0: * they feel easy to remember. Or they can change the representative cities michael@0: * originally picked by default to using their favorite ones. michael@0: *
michael@0: * DateFormatSymbols are not expected to be subclassed. Data for a calendar is michael@0: * loaded out of resource bundles. The 'type' parameter indicates the type of michael@0: * calendar, for example, "gregorian" or "japanese". If the type is not gregorian michael@0: * (or NULL, or an empty string) then the type is appended to the resource name, michael@0: * for example, 'Eras_japanese' instead of 'Eras'. If the resource 'Eras_japanese' did michael@0: * not exist (even in root), then this class will fall back to just 'Eras', that is, michael@0: * Gregorian data. Therefore, the calendar implementor MUST ensure that the root michael@0: * locale at least contains any resources that are to be particularized for the michael@0: * calendar type. michael@0: */ michael@0: class U_I18N_API DateFormatSymbols : public UObject { michael@0: public: michael@0: /** michael@0: * Construct a DateFormatSymbols object by loading format data from michael@0: * resources for the default locale, in the default calendar (Gregorian). michael@0: *
michael@0: * NOTE: This constructor will never fail; if it cannot get resource michael@0: * data for the default locale, it will return a last-resort object michael@0: * based on hard-coded strings. michael@0: * michael@0: * @param status Status code. Failure michael@0: * results if the resources for the default cannot be michael@0: * found or cannot be loaded michael@0: * @stable ICU 2.0 michael@0: */ michael@0: DateFormatSymbols(UErrorCode& status); michael@0: michael@0: /** michael@0: * Construct a DateFormatSymbols object by loading format data from michael@0: * resources for the given locale, in the default calendar (Gregorian). michael@0: * michael@0: * @param locale Locale to load format data from. michael@0: * @param status Status code. Failure michael@0: * results if the resources for the locale cannot be michael@0: * found or cannot be loaded michael@0: * @stable ICU 2.0 michael@0: */ michael@0: DateFormatSymbols(const Locale& locale, michael@0: UErrorCode& status); michael@0: michael@0: #ifndef U_HIDE_INTERNAL_API michael@0: /** michael@0: * Construct a DateFormatSymbols object by loading format data from michael@0: * resources for the default locale, in the default calendar (Gregorian). michael@0: *
michael@0: * NOTE: This constructor will never fail; if it cannot get resource michael@0: * data for the default locale, it will return a last-resort object michael@0: * based on hard-coded strings. michael@0: * michael@0: * @param type Type of calendar (as returned by Calendar::getType). michael@0: * Will be used to access the correct set of strings. michael@0: * (NULL or empty string defaults to "gregorian".) michael@0: * @param status Status code. Failure michael@0: * results if the resources for the default cannot be michael@0: * found or cannot be loaded michael@0: * @internal michael@0: */ michael@0: DateFormatSymbols(const char *type, UErrorCode& status); michael@0: michael@0: /** michael@0: * Construct a DateFormatSymbols object by loading format data from michael@0: * resources for the given locale, in the default calendar (Gregorian). michael@0: * michael@0: * @param locale Locale to load format data from. michael@0: * @param type Type of calendar (as returned by Calendar::getType). michael@0: * Will be used to access the correct set of strings. michael@0: * (NULL or empty string defaults to "gregorian".) michael@0: * @param status Status code. Failure michael@0: * results if the resources for the locale cannot be michael@0: * found or cannot be loaded michael@0: * @internal michael@0: */ michael@0: DateFormatSymbols(const Locale& locale, michael@0: const char *type, michael@0: UErrorCode& status); michael@0: #endif /* U_HIDE_INTERNAL_API */ michael@0: michael@0: /** michael@0: * Copy constructor. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: DateFormatSymbols(const DateFormatSymbols&); michael@0: michael@0: /** michael@0: * Assignment operator. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: DateFormatSymbols& operator=(const DateFormatSymbols&); michael@0: michael@0: /** michael@0: * Destructor. This is nonvirtual because this class is not designed to be michael@0: * subclassed. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: virtual ~DateFormatSymbols(); michael@0: michael@0: /** michael@0: * Return true if another object is semantically equal to this one. michael@0: * michael@0: * @param other the DateFormatSymbols object to be compared with. michael@0: * @return true if other is semantically equal to this. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: UBool operator==(const DateFormatSymbols& other) const; michael@0: michael@0: /** michael@0: * Return true if another object is semantically unequal to this one. michael@0: * michael@0: * @param other the DateFormatSymbols object to be compared with. michael@0: * @return true if other is semantically unequal to this. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: UBool operator!=(const DateFormatSymbols& other) const { return !operator==(other); } michael@0: michael@0: /** michael@0: * Gets abbreviated era strings. For example: "AD" and "BC". michael@0: * michael@0: * @param count Filled in with length of the array. michael@0: * @return the era strings. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: const UnicodeString* getEras(int32_t& count) const; michael@0: michael@0: /** michael@0: * Sets abbreviated era strings. For example: "AD" and "BC". michael@0: * @param eras Array of era strings (DateFormatSymbols retains ownership.) michael@0: * @param count Filled in with length of the array. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: void setEras(const UnicodeString* eras, int32_t count); michael@0: michael@0: /** michael@0: * Gets era name strings. For example: "Anno Domini" and "Before Christ". michael@0: * michael@0: * @param count Filled in with length of the array. michael@0: * @return the era name strings. michael@0: * @stable ICU 3.4 michael@0: */ michael@0: const UnicodeString* getEraNames(int32_t& count) const; michael@0: michael@0: /** michael@0: * Sets era name strings. For example: "Anno Domini" and "Before Christ". michael@0: * @param eraNames Array of era name strings (DateFormatSymbols retains ownership.) michael@0: * @param count Filled in with length of the array. michael@0: * @stable ICU 3.6 michael@0: */ michael@0: void setEraNames(const UnicodeString* eraNames, int32_t count); michael@0: michael@0: /** michael@0: * Gets narrow era strings. For example: "A" and "B". michael@0: * michael@0: * @param count Filled in with length of the array. michael@0: * @return the narrow era strings. michael@0: * @stable ICU 4.2 michael@0: */ michael@0: const UnicodeString* getNarrowEras(int32_t& count) const; michael@0: michael@0: /** michael@0: * Sets narrow era strings. For example: "A" and "B". michael@0: * @param narrowEras Array of narrow era strings (DateFormatSymbols retains ownership.) michael@0: * @param count Filled in with length of the array. michael@0: * @stable ICU 4.2 michael@0: */ michael@0: void setNarrowEras(const UnicodeString* narrowEras, int32_t count); michael@0: michael@0: /** michael@0: * Gets month strings. For example: "January", "February", etc. michael@0: * @param count Filled in with length of the array. michael@0: * @return the month strings. (DateFormatSymbols retains ownership.) michael@0: * @stable ICU 2.0 michael@0: */ michael@0: const UnicodeString* getMonths(int32_t& count) const; michael@0: michael@0: /** michael@0: * Sets month strings. For example: "January", "February", etc. michael@0: * michael@0: * @param months the new month strings. (not adopted; caller retains ownership) michael@0: * @param count Filled in with length of the array. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: void setMonths(const UnicodeString* months, int32_t count); michael@0: michael@0: /** michael@0: * Gets short month strings. For example: "Jan", "Feb", etc. michael@0: * michael@0: * @param count Filled in with length of the array. michael@0: * @return the short month strings. (DateFormatSymbols retains ownership.) michael@0: * @stable ICU 2.0 michael@0: */ michael@0: const UnicodeString* getShortMonths(int32_t& count) const; michael@0: michael@0: /** michael@0: * Sets short month strings. For example: "Jan", "Feb", etc. michael@0: * @param count Filled in with length of the array. michael@0: * @param shortMonths the new short month strings. (not adopted; caller retains ownership) michael@0: * @stable ICU 2.0 michael@0: */ michael@0: void setShortMonths(const UnicodeString* shortMonths, int32_t count); michael@0: michael@0: /** michael@0: * Selector for date formatting context michael@0: * @stable ICU 3.6 michael@0: */ michael@0: enum DtContextType { michael@0: FORMAT, michael@0: STANDALONE, michael@0: DT_CONTEXT_COUNT michael@0: }; michael@0: michael@0: /** michael@0: * Selector for date formatting width michael@0: * @stable ICU 3.6 michael@0: */ michael@0: enum DtWidthType { michael@0: ABBREVIATED, michael@0: WIDE, michael@0: NARROW, michael@0: #ifndef U_HIDE_DRAFT_API michael@0: /** michael@0: * Short width is currently only supported for weekday names. michael@0: * @draft ICU 51 michael@0: */ michael@0: SHORT, michael@0: #endif /* U_HIDE_DRAFT_API */ michael@0: /** michael@0: */ michael@0: DT_WIDTH_COUNT = 4 michael@0: }; michael@0: michael@0: /** michael@0: * Gets month strings by width and context. For example: "January", "February", etc. michael@0: * @param count Filled in with length of the array. michael@0: * @param context The formatting context, either FORMAT or STANDALONE michael@0: * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW. michael@0: * @return the month strings. (DateFormatSymbols retains ownership.) michael@0: * @stable ICU 3.4 michael@0: */ michael@0: const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const; michael@0: michael@0: /** michael@0: * Sets month strings by width and context. For example: "January", "February", etc. michael@0: * michael@0: * @param months The new month strings. (not adopted; caller retains ownership) michael@0: * @param count Filled in with length of the array. michael@0: * @param context The formatting context, either FORMAT or STANDALONE michael@0: * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW. michael@0: * @stable ICU 3.6 michael@0: */ michael@0: void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width); michael@0: michael@0: /** michael@0: * Gets wide weekday strings. For example: "Sunday", "Monday", etc. michael@0: * @param count Filled in with length of the array. michael@0: * @return the weekday strings. (DateFormatSymbols retains ownership.) michael@0: * @stable ICU 2.0 michael@0: */ michael@0: const UnicodeString* getWeekdays(int32_t& count) const; michael@0: michael@0: michael@0: /** michael@0: * Sets wide weekday strings. For example: "Sunday", "Monday", etc. michael@0: * @param weekdays the new weekday strings. (not adopted; caller retains ownership) michael@0: * @param count Filled in with length of the array. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: void setWeekdays(const UnicodeString* weekdays, int32_t count); michael@0: michael@0: /** michael@0: * Gets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is michael@0: * misleading; it does not get the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.) michael@0: * @param count Filled in with length of the array. michael@0: * @return the abbreviated weekday strings. (DateFormatSymbols retains ownership.) michael@0: * @stable ICU 2.0 michael@0: */ michael@0: const UnicodeString* getShortWeekdays(int32_t& count) const; michael@0: michael@0: /** michael@0: * Sets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is michael@0: * misleading; it does not set the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.) michael@0: * @param abbrevWeekdays the new abbreviated weekday strings. (not adopted; caller retains ownership) michael@0: * @param count Filled in with length of the array. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count); michael@0: michael@0: /** michael@0: * Gets weekday strings by width and context. For example: "Sunday", "Monday", etc. michael@0: * @param count Filled in with length of the array. michael@0: * @param context The formatting context, either FORMAT or STANDALONE michael@0: * @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW michael@0: * @return the month strings. (DateFormatSymbols retains ownership.) michael@0: * @stable ICU 3.4 michael@0: */ michael@0: const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const; michael@0: michael@0: /** michael@0: * Sets weekday strings by width and context. For example: "Sunday", "Monday", etc. michael@0: * @param weekdays The new weekday strings. (not adopted; caller retains ownership) michael@0: * @param count Filled in with length of the array. michael@0: * @param context The formatting context, either FORMAT or STANDALONE michael@0: * @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW michael@0: * @stable ICU 3.6 michael@0: */ michael@0: void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width); michael@0: michael@0: /** michael@0: * Gets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc. michael@0: * @param count Filled in with length of the array. michael@0: * @param context The formatting context, either FORMAT or STANDALONE michael@0: * @param width The width of returned strings, either WIDE or ABBREVIATED. There michael@0: * are no NARROW quarters. michael@0: * @return the quarter strings. (DateFormatSymbols retains ownership.) michael@0: * @stable ICU 3.6 michael@0: */ michael@0: const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const; michael@0: michael@0: /** michael@0: * Sets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc. michael@0: * michael@0: * @param quarters The new quarter strings. (not adopted; caller retains ownership) michael@0: * @param count Filled in with length of the array. michael@0: * @param context The formatting context, either FORMAT or STANDALONE michael@0: * @param width The width of returned strings, either WIDE or ABBREVIATED. There michael@0: * are no NARROW quarters. michael@0: * @stable ICU 3.6 michael@0: */ michael@0: void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width); michael@0: michael@0: /** michael@0: * Gets AM/PM strings. For example: "AM" and "PM". michael@0: * @param count Filled in with length of the array. michael@0: * @return the weekday strings. (DateFormatSymbols retains ownership.) michael@0: * @stable ICU 2.0 michael@0: */ michael@0: const UnicodeString* getAmPmStrings(int32_t& count) const; michael@0: michael@0: /** michael@0: * Sets ampm strings. For example: "AM" and "PM". michael@0: * @param ampms the new ampm strings. (not adopted; caller retains ownership) michael@0: * @param count Filled in with length of the array. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: void setAmPmStrings(const UnicodeString* ampms, int32_t count); michael@0: michael@0: #ifndef U_HIDE_INTERNAL_API michael@0: /** michael@0: * Somewhat temporary constants for leap month pattern types, adequate for supporting michael@0: * just leap month patterns as needed for Chinese lunar calendar. michael@0: * Eventually we will add full support for different month pattern types (needed for michael@0: * other calendars such as Hindu) at which point this approach will be replaced by a michael@0: * more complete approach. michael@0: * @internal michael@0: */ michael@0: enum EMonthPatternType michael@0: { michael@0: kLeapMonthPatternFormatWide, michael@0: kLeapMonthPatternFormatAbbrev, michael@0: kLeapMonthPatternFormatNarrow, michael@0: kLeapMonthPatternStandaloneWide, michael@0: kLeapMonthPatternStandaloneAbbrev, michael@0: kLeapMonthPatternStandaloneNarrow, michael@0: kLeapMonthPatternNumeric, michael@0: kMonthPatternsCount michael@0: }; michael@0: michael@0: /** michael@0: * Somewhat temporary function for getting complete set of leap month patterns for all michael@0: * contexts & widths, indexed by EMonthPatternType values. Returns NULL if calendar michael@0: * does not have leap month patterns. Note, there is currently no setter for this. michael@0: * Eventually we will add full support for different month pattern types (needed for michael@0: * other calendars such as Hindu) at which point this approach will be replaced by a michael@0: * more complete approach. michael@0: * @param count Filled in with length of the array (may be 0). michael@0: * @return The leap month patterns (DateFormatSymbols retains ownership). michael@0: * May be NULL if there are no leap month patterns for this calendar. michael@0: * @internal michael@0: */ michael@0: const UnicodeString* getLeapMonthPatterns(int32_t& count) const; michael@0: michael@0: #endif /* U_HIDE_INTERNAL_API */ michael@0: michael@0: #ifndef U_HIDE_DEPRECATED_API michael@0: /** michael@0: * Gets timezone strings. These strings are stored in a 2-dimensional array. michael@0: * @param rowCount Output param to receive number of rows. michael@0: * @param columnCount Output param to receive number of columns. michael@0: * @return The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.) michael@0: * @deprecated ICU 3.6 michael@0: */ michael@0: const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const; michael@0: #endif /* U_HIDE_DEPRECATED_API */ michael@0: michael@0: /** michael@0: * Sets timezone strings. These strings are stored in a 2-dimensional array. michael@0: *
Note: SimpleDateFormat no longer use the zone strings stored in michael@0: * a DateFormatSymbols. Therefore, the time zone strings set by this mthod michael@0: * have no effects in an instance of SimpleDateFormat for formatting time michael@0: * zones. michael@0: * @param strings The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership) michael@0: * @param rowCount The number of rows (count of first index). michael@0: * @param columnCount The number of columns (count of second index). michael@0: * @stable ICU 2.0 michael@0: */ michael@0: void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount); michael@0: michael@0: /** michael@0: * Get the non-localized date-time pattern characters. michael@0: * @return the non-localized date-time pattern characters michael@0: * @stable ICU 2.0 michael@0: */ michael@0: static const UChar * U_EXPORT2 getPatternUChars(void); michael@0: michael@0: /** michael@0: * Gets localized date-time pattern characters. For example: 'u', 't', etc. michael@0: *
michael@0: * Note: ICU no longer provides localized date-time pattern characters for a locale michael@0: * starting ICU 3.8. This method returns the non-localized date-time pattern michael@0: * characters unless user defined localized data is set by setLocalPatternChars. michael@0: * @param result Output param which will receive the localized date-time pattern characters. michael@0: * @return A reference to 'result'. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: UnicodeString& getLocalPatternChars(UnicodeString& result) const; michael@0: michael@0: /** michael@0: * Sets localized date-time pattern characters. For example: 'u', 't', etc. michael@0: * @param newLocalPatternChars the new localized date-time michael@0: * pattern characters. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: void setLocalPatternChars(const UnicodeString& newLocalPatternChars); michael@0: michael@0: /** michael@0: * Returns the locale for this object. Two flavors are available: michael@0: * valid and actual locale. michael@0: * @stable ICU 2.8 michael@0: */ michael@0: Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const; michael@0: michael@0: /** michael@0: * Constants for capitalization context usage types. michael@0: * @internal michael@0: */ michael@0: enum ECapitalizationContextUsageType michael@0: { michael@0: kCapContextUsageOther, michael@0: kCapContextUsageMonthFormat, /* except narrow */ michael@0: kCapContextUsageMonthStandalone, /* except narrow */ michael@0: kCapContextUsageMonthNarrow, michael@0: kCapContextUsageDayFormat, /* except narrow */ michael@0: kCapContextUsageDayStandalone, /* except narrow */ michael@0: kCapContextUsageDayNarrow, michael@0: kCapContextUsageEraWide, michael@0: kCapContextUsageEraAbbrev, michael@0: kCapContextUsageEraNarrow, michael@0: kCapContextUsageZoneLong, michael@0: kCapContextUsageZoneShort, michael@0: kCapContextUsageMetazoneLong, michael@0: kCapContextUsageMetazoneShort, michael@0: kCapContextUsageTypeCount michael@0: }; michael@0: michael@0: /** michael@0: * ICU "poor man's RTTI", returns a UClassID for the actual class. michael@0: * michael@0: * @stable ICU 2.2 michael@0: */ michael@0: virtual UClassID getDynamicClassID() const; michael@0: michael@0: /** michael@0: * ICU "poor man's RTTI", returns a UClassID for this class. michael@0: * michael@0: * @stable ICU 2.2 michael@0: */ michael@0: static UClassID U_EXPORT2 getStaticClassID(); michael@0: michael@0: private: michael@0: michael@0: friend class SimpleDateFormat; michael@0: friend class DateFormatSymbolsSingleSetter; // see udat.cpp michael@0: michael@0: /** michael@0: * Abbreviated era strings. For example: "AD" and "BC". michael@0: */ michael@0: UnicodeString* fEras; michael@0: int32_t fErasCount; michael@0: michael@0: /** michael@0: * Era name strings. For example: "Anno Domini" and "Before Christ". michael@0: */ michael@0: UnicodeString* fEraNames; michael@0: int32_t fEraNamesCount; michael@0: michael@0: /** michael@0: * Narrow era strings. For example: "A" and "B". michael@0: */ michael@0: UnicodeString* fNarrowEras; michael@0: int32_t fNarrowErasCount; michael@0: michael@0: /** michael@0: * Month strings. For example: "January", "February", etc. michael@0: */ michael@0: UnicodeString* fMonths; michael@0: int32_t fMonthsCount; michael@0: michael@0: /** michael@0: * Short month strings. For example: "Jan", "Feb", etc. michael@0: */ michael@0: UnicodeString* fShortMonths; michael@0: int32_t fShortMonthsCount; michael@0: michael@0: /** michael@0: * Narrow month strings. For example: "J", "F", etc. michael@0: */ michael@0: UnicodeString* fNarrowMonths; michael@0: int32_t fNarrowMonthsCount; michael@0: michael@0: /** michael@0: * Standalone Month strings. For example: "January", "February", etc. michael@0: */ michael@0: UnicodeString* fStandaloneMonths; michael@0: int32_t fStandaloneMonthsCount; michael@0: michael@0: /** michael@0: * Standalone Short month strings. For example: "Jan", "Feb", etc. michael@0: */ michael@0: UnicodeString* fStandaloneShortMonths; michael@0: int32_t fStandaloneShortMonthsCount; michael@0: michael@0: /** michael@0: * Standalone Narrow month strings. For example: "J", "F", etc. michael@0: */ michael@0: UnicodeString* fStandaloneNarrowMonths; michael@0: int32_t fStandaloneNarrowMonthsCount; michael@0: michael@0: /** michael@0: * CLDR-style format wide weekday strings. For example: "Sunday", "Monday", etc. michael@0: */ michael@0: UnicodeString* fWeekdays; michael@0: int32_t fWeekdaysCount; michael@0: michael@0: /** michael@0: * CLDR-style format abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc. michael@0: */ michael@0: UnicodeString* fShortWeekdays; michael@0: int32_t fShortWeekdaysCount; michael@0: michael@0: /** michael@0: * CLDR-style format short weekday strings. For example: "Su", "Mo", etc. michael@0: */ michael@0: UnicodeString* fShorterWeekdays; michael@0: int32_t fShorterWeekdaysCount; michael@0: michael@0: /** michael@0: * CLDR-style format narrow weekday strings. For example: "S", "M", etc. michael@0: */ michael@0: UnicodeString* fNarrowWeekdays; michael@0: int32_t fNarrowWeekdaysCount; michael@0: michael@0: /** michael@0: * CLDR-style standalone wide weekday strings. For example: "Sunday", "Monday", etc. michael@0: */ michael@0: UnicodeString* fStandaloneWeekdays; michael@0: int32_t fStandaloneWeekdaysCount; michael@0: michael@0: /** michael@0: * CLDR-style standalone abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc. michael@0: */ michael@0: UnicodeString* fStandaloneShortWeekdays; michael@0: int32_t fStandaloneShortWeekdaysCount; michael@0: michael@0: /** michael@0: * CLDR-style standalone short weekday strings. For example: "Su", "Mo", etc. michael@0: */ michael@0: UnicodeString* fStandaloneShorterWeekdays; michael@0: int32_t fStandaloneShorterWeekdaysCount; michael@0: michael@0: /** michael@0: * Standalone Narrow weekday strings. For example: "Sun", "Mon", etc. michael@0: */ michael@0: UnicodeString* fStandaloneNarrowWeekdays; michael@0: int32_t fStandaloneNarrowWeekdaysCount; michael@0: michael@0: /** michael@0: * Ampm strings. For example: "AM" and "PM". michael@0: */ michael@0: UnicodeString* fAmPms; michael@0: int32_t fAmPmsCount; michael@0: michael@0: /** michael@0: * Quarter strings. For example: "1st quarter", "2nd quarter", etc. michael@0: */ michael@0: UnicodeString *fQuarters; michael@0: int32_t fQuartersCount; michael@0: michael@0: /** michael@0: * Short quarters. For example: "Q1", "Q2", etc. michael@0: */ michael@0: UnicodeString *fShortQuarters; michael@0: int32_t fShortQuartersCount; michael@0: michael@0: /** michael@0: * Standalone quarter strings. For example: "1st quarter", "2nd quarter", etc. michael@0: */ michael@0: UnicodeString *fStandaloneQuarters; michael@0: int32_t fStandaloneQuartersCount; michael@0: michael@0: /** michael@0: * Standalone short quarter strings. For example: "Q1", "Q2", etc. michael@0: */ michael@0: UnicodeString *fStandaloneShortQuarters; michael@0: int32_t fStandaloneShortQuartersCount; michael@0: michael@0: /** michael@0: * All leap month patterns, for example "{0}bis". michael@0: */ michael@0: UnicodeString *fLeapMonthPatterns; michael@0: int32_t fLeapMonthPatternsCount; michael@0: michael@0: /** michael@0: * (Format) Short cyclic year names, for example: "jia-zi", "yi-chou", ... "gui-hai" michael@0: */ michael@0: UnicodeString* fShortYearNames; michael@0: int32_t fShortYearNamesCount; michael@0: michael@0: /** michael@0: * Localized names of time zones in this locale. This is a michael@0: * two-dimensional array of strings of size n by m, michael@0: * where m is at least 5 and up to 7. Each of the n rows is an michael@0: * entry containing the localized names for a single TimeZone. michael@0: * michael@0: * Each such row contains (with i ranging from 0..n-1): michael@0: * michael@0: * zoneStrings[i][0] - time zone ID michael@0: * example: America/Los_Angeles michael@0: * zoneStrings[i][1] - long name of zone in standard time michael@0: * example: Pacific Standard Time michael@0: * zoneStrings[i][2] - short name of zone in standard time michael@0: * example: PST michael@0: * zoneStrings[i][3] - long name of zone in daylight savings time michael@0: * example: Pacific Daylight Time michael@0: * zoneStrings[i][4] - short name of zone in daylight savings time michael@0: * example: PDT michael@0: * zoneStrings[i][5] - location name of zone michael@0: * example: United States (Los Angeles) michael@0: * zoneStrings[i][6] - long generic name of zone michael@0: * example: Pacific Time michael@0: * zoneStrings[i][7] - short generic of zone michael@0: * example: PT michael@0: * michael@0: * The zone ID is not localized; it corresponds to the ID michael@0: * value associated with a system time zone object. All other entries michael@0: * are localized names. If a zone does not implement daylight savings michael@0: * time, the daylight savings time names are ignored. michael@0: * michael@0: * Note:CLDR 1.5 introduced metazone and its historical mappings. michael@0: * This simple two-dimensional array is no longer sufficient to represent michael@0: * localized names and its historic changes. Since ICU 3.8.1, localized michael@0: * zone names extracted from ICU locale data is stored in a ZoneStringFormat michael@0: * instance. But we still need to support the old way of customizing michael@0: * localized zone names, so we keep this field for the purpose. michael@0: */ michael@0: UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings michael@0: UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale michael@0: int32_t fZoneStringsRowCount; michael@0: int32_t fZoneStringsColCount; michael@0: michael@0: Locale fZSFLocale; // Locale used for getting ZoneStringFormat michael@0: michael@0: /** michael@0: * Localized date-time pattern characters. For example: use 'u' as 'y'. michael@0: */ michael@0: UnicodeString fLocalPatternChars; michael@0: michael@0: /** michael@0: * Capitalization transforms. For each usage type, the first array element indicates michael@0: * whether to titlecase for uiListOrMenu context, the second indicates whether to michael@0: * titlecase for stand-alone context. michael@0: */ michael@0: UBool fCapitalization[kCapContextUsageTypeCount][2]; michael@0: michael@0: private: michael@0: /** valid/actual locale information michael@0: * these are always ICU locales, so the length should not be a problem michael@0: */ michael@0: char validLocale[ULOC_FULLNAME_CAPACITY]; michael@0: char actualLocale[ULOC_FULLNAME_CAPACITY]; michael@0: michael@0: DateFormatSymbols(); // default constructor not implemented michael@0: michael@0: /** michael@0: * Called by the constructors to actually load data from the resources michael@0: * michael@0: * @param locale The locale to get symbols for. michael@0: * @param type Calendar Type (as from Calendar::getType()) michael@0: * @param status Input/output parameter, set to success or michael@0: * failure code upon return. michael@0: * @param useLastResortData determine if use last resort data michael@0: */ michael@0: void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE); michael@0: michael@0: /** michael@0: * Copy or alias an array in another object, as appropriate. michael@0: * michael@0: * @param dstArray the copy destination array. michael@0: * @param dstCount fill in with the lenth of 'dstArray'. michael@0: * @param srcArray the source array to be copied. michael@0: * @param srcCount the length of items to be copied from the 'srcArray'. michael@0: */ michael@0: static void assignArray(UnicodeString*& dstArray, michael@0: int32_t& dstCount, michael@0: const UnicodeString* srcArray, michael@0: int32_t srcCount); michael@0: michael@0: /** michael@0: * Return true if the given arrays' contents are equal, or if the arrays are michael@0: * identical (pointers are equal). michael@0: * michael@0: * @param array1 one array to be compared with. michael@0: * @param array2 another array to be compared with. michael@0: * @param count the length of items to be copied. michael@0: * @return true if the given arrays' contents are equal, or if the arrays are michael@0: * identical (pointers are equal). michael@0: */ michael@0: static UBool arrayCompare(const UnicodeString* array1, michael@0: const UnicodeString* array2, michael@0: int32_t count); michael@0: michael@0: /** michael@0: * Create a copy, in fZoneStrings, of the given zone strings array. The michael@0: * member variables fZoneStringsRowCount and fZoneStringsColCount should be michael@0: * set already by the caller. michael@0: */ michael@0: void createZoneStrings(const UnicodeString *const * otherStrings); michael@0: michael@0: /** michael@0: * Delete all the storage owned by this object. michael@0: */ michael@0: void dispose(void); michael@0: michael@0: /** michael@0: * Copy all of the other's data to this. michael@0: * @param other the object to be copied. michael@0: */ michael@0: void copyData(const DateFormatSymbols& other); michael@0: michael@0: /** michael@0: * Create zone strings array by locale if not yet available michael@0: */ michael@0: void initZoneStringsArray(void); michael@0: michael@0: /** michael@0: * Delete just the zone strings. michael@0: */ michael@0: void disposeZoneStrings(void); michael@0: michael@0: /** michael@0: * Returns the date format field index of the pattern character c, michael@0: * or UDAT_FIELD_COUNT if c is not a pattern character. michael@0: */ michael@0: static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c); michael@0: michael@0: /** michael@0: * Returns TRUE if f (with its pattern character repeated count times) is a numeric field. michael@0: */ michael@0: static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count); michael@0: michael@0: /** michael@0: * Returns TRUE if c (repeated count times) is the pattern character for a numeric field. michael@0: */ michael@0: static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count); michael@0: }; michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* #if !UCONFIG_NO_FORMATTING */ michael@0: michael@0: #endif // _DTFMTSYM michael@0: //eof