1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/unicode/dtfmtsym.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,847 @@ 1.4 +/* 1.5 +******************************************************************************** 1.6 +* Copyright (C) 1997-2013, International Business Machines 1.7 +* Corporation and others. All Rights Reserved. 1.8 +******************************************************************************** 1.9 +* 1.10 +* File DTFMTSYM.H 1.11 +* 1.12 +* Modification History: 1.13 +* 1.14 +* Date Name Description 1.15 +* 02/19/97 aliu Converted from java. 1.16 +* 07/21/98 stephen Added getZoneIndex() 1.17 +* Changed to match C++ conventions 1.18 +******************************************************************************** 1.19 +*/ 1.20 + 1.21 +#ifndef DTFMTSYM_H 1.22 +#define DTFMTSYM_H 1.23 + 1.24 +#include "unicode/utypes.h" 1.25 + 1.26 +#if !UCONFIG_NO_FORMATTING 1.27 + 1.28 +#include "unicode/calendar.h" 1.29 +#include "unicode/uobject.h" 1.30 +#include "unicode/locid.h" 1.31 +#include "unicode/udat.h" 1.32 +#include "unicode/ures.h" 1.33 + 1.34 +/** 1.35 + * \file 1.36 + * \brief C++ API: Symbols for formatting dates. 1.37 + */ 1.38 + 1.39 +U_NAMESPACE_BEGIN 1.40 + 1.41 +/* forward declaration */ 1.42 +class SimpleDateFormat; 1.43 +class Hashtable; 1.44 + 1.45 +/** 1.46 + * DateFormatSymbols is a public class for encapsulating localizable date-time 1.47 + * formatting data -- including timezone data. DateFormatSymbols is used by 1.48 + * DateFormat and SimpleDateFormat. 1.49 + * <P> 1.50 + * Rather than first creating a DateFormatSymbols to get a date-time formatter 1.51 + * by using a SimpleDateFormat constructor, clients are encouraged to create a 1.52 + * date-time formatter using the getTimeInstance(), getDateInstance(), or 1.53 + * getDateTimeInstance() method in DateFormat. Each of these methods can return a 1.54 + * date/time formatter initialized with a default format pattern along with the 1.55 + * date-time formatting data for a given or default locale. After a formatter is 1.56 + * created, clients may modify the format pattern using the setPattern function 1.57 + * as so desired. For more information on using these formatter factory 1.58 + * functions, see DateFormat. 1.59 + * <P> 1.60 + * If clients decide to create a date-time formatter with a particular format 1.61 + * pattern and locale, they can do so with new SimpleDateFormat(aPattern, 1.62 + * new DateFormatSymbols(aLocale)). This will load the appropriate date-time 1.63 + * formatting data from the locale. 1.64 + * <P> 1.65 + * DateFormatSymbols objects are clonable. When clients obtain a 1.66 + * DateFormatSymbols object, they can feel free to modify the date-time 1.67 + * formatting data as necessary. For instance, clients can 1.68 + * replace the localized date-time format pattern characters with the ones that 1.69 + * they feel easy to remember. Or they can change the representative cities 1.70 + * originally picked by default to using their favorite ones. 1.71 + * <P> 1.72 + * DateFormatSymbols are not expected to be subclassed. Data for a calendar is 1.73 + * loaded out of resource bundles. The 'type' parameter indicates the type of 1.74 + * calendar, for example, "gregorian" or "japanese". If the type is not gregorian 1.75 + * (or NULL, or an empty string) then the type is appended to the resource name, 1.76 + * for example, 'Eras_japanese' instead of 'Eras'. If the resource 'Eras_japanese' did 1.77 + * not exist (even in root), then this class will fall back to just 'Eras', that is, 1.78 + * Gregorian data. Therefore, the calendar implementor MUST ensure that the root 1.79 + * locale at least contains any resources that are to be particularized for the 1.80 + * calendar type. 1.81 + */ 1.82 +class U_I18N_API DateFormatSymbols : public UObject { 1.83 +public: 1.84 + /** 1.85 + * Construct a DateFormatSymbols object by loading format data from 1.86 + * resources for the default locale, in the default calendar (Gregorian). 1.87 + * <P> 1.88 + * NOTE: This constructor will never fail; if it cannot get resource 1.89 + * data for the default locale, it will return a last-resort object 1.90 + * based on hard-coded strings. 1.91 + * 1.92 + * @param status Status code. Failure 1.93 + * results if the resources for the default cannot be 1.94 + * found or cannot be loaded 1.95 + * @stable ICU 2.0 1.96 + */ 1.97 + DateFormatSymbols(UErrorCode& status); 1.98 + 1.99 + /** 1.100 + * Construct a DateFormatSymbols object by loading format data from 1.101 + * resources for the given locale, in the default calendar (Gregorian). 1.102 + * 1.103 + * @param locale Locale to load format data from. 1.104 + * @param status Status code. Failure 1.105 + * results if the resources for the locale cannot be 1.106 + * found or cannot be loaded 1.107 + * @stable ICU 2.0 1.108 + */ 1.109 + DateFormatSymbols(const Locale& locale, 1.110 + UErrorCode& status); 1.111 + 1.112 +#ifndef U_HIDE_INTERNAL_API 1.113 + /** 1.114 + * Construct a DateFormatSymbols object by loading format data from 1.115 + * resources for the default locale, in the default calendar (Gregorian). 1.116 + * <P> 1.117 + * NOTE: This constructor will never fail; if it cannot get resource 1.118 + * data for the default locale, it will return a last-resort object 1.119 + * based on hard-coded strings. 1.120 + * 1.121 + * @param type Type of calendar (as returned by Calendar::getType). 1.122 + * Will be used to access the correct set of strings. 1.123 + * (NULL or empty string defaults to "gregorian".) 1.124 + * @param status Status code. Failure 1.125 + * results if the resources for the default cannot be 1.126 + * found or cannot be loaded 1.127 + * @internal 1.128 + */ 1.129 + DateFormatSymbols(const char *type, UErrorCode& status); 1.130 + 1.131 + /** 1.132 + * Construct a DateFormatSymbols object by loading format data from 1.133 + * resources for the given locale, in the default calendar (Gregorian). 1.134 + * 1.135 + * @param locale Locale to load format data from. 1.136 + * @param type Type of calendar (as returned by Calendar::getType). 1.137 + * Will be used to access the correct set of strings. 1.138 + * (NULL or empty string defaults to "gregorian".) 1.139 + * @param status Status code. Failure 1.140 + * results if the resources for the locale cannot be 1.141 + * found or cannot be loaded 1.142 + * @internal 1.143 + */ 1.144 + DateFormatSymbols(const Locale& locale, 1.145 + const char *type, 1.146 + UErrorCode& status); 1.147 +#endif /* U_HIDE_INTERNAL_API */ 1.148 + 1.149 + /** 1.150 + * Copy constructor. 1.151 + * @stable ICU 2.0 1.152 + */ 1.153 + DateFormatSymbols(const DateFormatSymbols&); 1.154 + 1.155 + /** 1.156 + * Assignment operator. 1.157 + * @stable ICU 2.0 1.158 + */ 1.159 + DateFormatSymbols& operator=(const DateFormatSymbols&); 1.160 + 1.161 + /** 1.162 + * Destructor. This is nonvirtual because this class is not designed to be 1.163 + * subclassed. 1.164 + * @stable ICU 2.0 1.165 + */ 1.166 + virtual ~DateFormatSymbols(); 1.167 + 1.168 + /** 1.169 + * Return true if another object is semantically equal to this one. 1.170 + * 1.171 + * @param other the DateFormatSymbols object to be compared with. 1.172 + * @return true if other is semantically equal to this. 1.173 + * @stable ICU 2.0 1.174 + */ 1.175 + UBool operator==(const DateFormatSymbols& other) const; 1.176 + 1.177 + /** 1.178 + * Return true if another object is semantically unequal to this one. 1.179 + * 1.180 + * @param other the DateFormatSymbols object to be compared with. 1.181 + * @return true if other is semantically unequal to this. 1.182 + * @stable ICU 2.0 1.183 + */ 1.184 + UBool operator!=(const DateFormatSymbols& other) const { return !operator==(other); } 1.185 + 1.186 + /** 1.187 + * Gets abbreviated era strings. For example: "AD" and "BC". 1.188 + * 1.189 + * @param count Filled in with length of the array. 1.190 + * @return the era strings. 1.191 + * @stable ICU 2.0 1.192 + */ 1.193 + const UnicodeString* getEras(int32_t& count) const; 1.194 + 1.195 + /** 1.196 + * Sets abbreviated era strings. For example: "AD" and "BC". 1.197 + * @param eras Array of era strings (DateFormatSymbols retains ownership.) 1.198 + * @param count Filled in with length of the array. 1.199 + * @stable ICU 2.0 1.200 + */ 1.201 + void setEras(const UnicodeString* eras, int32_t count); 1.202 + 1.203 + /** 1.204 + * Gets era name strings. For example: "Anno Domini" and "Before Christ". 1.205 + * 1.206 + * @param count Filled in with length of the array. 1.207 + * @return the era name strings. 1.208 + * @stable ICU 3.4 1.209 + */ 1.210 + const UnicodeString* getEraNames(int32_t& count) const; 1.211 + 1.212 + /** 1.213 + * Sets era name strings. For example: "Anno Domini" and "Before Christ". 1.214 + * @param eraNames Array of era name strings (DateFormatSymbols retains ownership.) 1.215 + * @param count Filled in with length of the array. 1.216 + * @stable ICU 3.6 1.217 + */ 1.218 + void setEraNames(const UnicodeString* eraNames, int32_t count); 1.219 + 1.220 + /** 1.221 + * Gets narrow era strings. For example: "A" and "B". 1.222 + * 1.223 + * @param count Filled in with length of the array. 1.224 + * @return the narrow era strings. 1.225 + * @stable ICU 4.2 1.226 + */ 1.227 + const UnicodeString* getNarrowEras(int32_t& count) const; 1.228 + 1.229 + /** 1.230 + * Sets narrow era strings. For example: "A" and "B". 1.231 + * @param narrowEras Array of narrow era strings (DateFormatSymbols retains ownership.) 1.232 + * @param count Filled in with length of the array. 1.233 + * @stable ICU 4.2 1.234 + */ 1.235 + void setNarrowEras(const UnicodeString* narrowEras, int32_t count); 1.236 + 1.237 + /** 1.238 + * Gets month strings. For example: "January", "February", etc. 1.239 + * @param count Filled in with length of the array. 1.240 + * @return the month strings. (DateFormatSymbols retains ownership.) 1.241 + * @stable ICU 2.0 1.242 + */ 1.243 + const UnicodeString* getMonths(int32_t& count) const; 1.244 + 1.245 + /** 1.246 + * Sets month strings. For example: "January", "February", etc. 1.247 + * 1.248 + * @param months the new month strings. (not adopted; caller retains ownership) 1.249 + * @param count Filled in with length of the array. 1.250 + * @stable ICU 2.0 1.251 + */ 1.252 + void setMonths(const UnicodeString* months, int32_t count); 1.253 + 1.254 + /** 1.255 + * Gets short month strings. For example: "Jan", "Feb", etc. 1.256 + * 1.257 + * @param count Filled in with length of the array. 1.258 + * @return the short month strings. (DateFormatSymbols retains ownership.) 1.259 + * @stable ICU 2.0 1.260 + */ 1.261 + const UnicodeString* getShortMonths(int32_t& count) const; 1.262 + 1.263 + /** 1.264 + * Sets short month strings. For example: "Jan", "Feb", etc. 1.265 + * @param count Filled in with length of the array. 1.266 + * @param shortMonths the new short month strings. (not adopted; caller retains ownership) 1.267 + * @stable ICU 2.0 1.268 + */ 1.269 + void setShortMonths(const UnicodeString* shortMonths, int32_t count); 1.270 + 1.271 + /** 1.272 + * Selector for date formatting context 1.273 + * @stable ICU 3.6 1.274 + */ 1.275 + enum DtContextType { 1.276 + FORMAT, 1.277 + STANDALONE, 1.278 + DT_CONTEXT_COUNT 1.279 + }; 1.280 + 1.281 + /** 1.282 + * Selector for date formatting width 1.283 + * @stable ICU 3.6 1.284 + */ 1.285 + enum DtWidthType { 1.286 + ABBREVIATED, 1.287 + WIDE, 1.288 + NARROW, 1.289 +#ifndef U_HIDE_DRAFT_API 1.290 + /** 1.291 + * Short width is currently only supported for weekday names. 1.292 + * @draft ICU 51 1.293 + */ 1.294 + SHORT, 1.295 +#endif /* U_HIDE_DRAFT_API */ 1.296 + /** 1.297 + */ 1.298 + DT_WIDTH_COUNT = 4 1.299 + }; 1.300 + 1.301 + /** 1.302 + * Gets month strings by width and context. For example: "January", "February", etc. 1.303 + * @param count Filled in with length of the array. 1.304 + * @param context The formatting context, either FORMAT or STANDALONE 1.305 + * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW. 1.306 + * @return the month strings. (DateFormatSymbols retains ownership.) 1.307 + * @stable ICU 3.4 1.308 + */ 1.309 + const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const; 1.310 + 1.311 + /** 1.312 + * Sets month strings by width and context. For example: "January", "February", etc. 1.313 + * 1.314 + * @param months The new month strings. (not adopted; caller retains ownership) 1.315 + * @param count Filled in with length of the array. 1.316 + * @param context The formatting context, either FORMAT or STANDALONE 1.317 + * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW. 1.318 + * @stable ICU 3.6 1.319 + */ 1.320 + void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width); 1.321 + 1.322 + /** 1.323 + * Gets wide weekday strings. For example: "Sunday", "Monday", etc. 1.324 + * @param count Filled in with length of the array. 1.325 + * @return the weekday strings. (DateFormatSymbols retains ownership.) 1.326 + * @stable ICU 2.0 1.327 + */ 1.328 + const UnicodeString* getWeekdays(int32_t& count) const; 1.329 + 1.330 + 1.331 + /** 1.332 + * Sets wide weekday strings. For example: "Sunday", "Monday", etc. 1.333 + * @param weekdays the new weekday strings. (not adopted; caller retains ownership) 1.334 + * @param count Filled in with length of the array. 1.335 + * @stable ICU 2.0 1.336 + */ 1.337 + void setWeekdays(const UnicodeString* weekdays, int32_t count); 1.338 + 1.339 + /** 1.340 + * Gets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is 1.341 + * misleading; it does not get the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.) 1.342 + * @param count Filled in with length of the array. 1.343 + * @return the abbreviated weekday strings. (DateFormatSymbols retains ownership.) 1.344 + * @stable ICU 2.0 1.345 + */ 1.346 + const UnicodeString* getShortWeekdays(int32_t& count) const; 1.347 + 1.348 + /** 1.349 + * Sets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is 1.350 + * misleading; it does not set the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.) 1.351 + * @param abbrevWeekdays the new abbreviated weekday strings. (not adopted; caller retains ownership) 1.352 + * @param count Filled in with length of the array. 1.353 + * @stable ICU 2.0 1.354 + */ 1.355 + void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count); 1.356 + 1.357 + /** 1.358 + * Gets weekday strings by width and context. For example: "Sunday", "Monday", etc. 1.359 + * @param count Filled in with length of the array. 1.360 + * @param context The formatting context, either FORMAT or STANDALONE 1.361 + * @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW 1.362 + * @return the month strings. (DateFormatSymbols retains ownership.) 1.363 + * @stable ICU 3.4 1.364 + */ 1.365 + const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const; 1.366 + 1.367 + /** 1.368 + * Sets weekday strings by width and context. For example: "Sunday", "Monday", etc. 1.369 + * @param weekdays The new weekday strings. (not adopted; caller retains ownership) 1.370 + * @param count Filled in with length of the array. 1.371 + * @param context The formatting context, either FORMAT or STANDALONE 1.372 + * @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW 1.373 + * @stable ICU 3.6 1.374 + */ 1.375 + void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width); 1.376 + 1.377 + /** 1.378 + * Gets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc. 1.379 + * @param count Filled in with length of the array. 1.380 + * @param context The formatting context, either FORMAT or STANDALONE 1.381 + * @param width The width of returned strings, either WIDE or ABBREVIATED. There 1.382 + * are no NARROW quarters. 1.383 + * @return the quarter strings. (DateFormatSymbols retains ownership.) 1.384 + * @stable ICU 3.6 1.385 + */ 1.386 + const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const; 1.387 + 1.388 + /** 1.389 + * Sets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc. 1.390 + * 1.391 + * @param quarters The new quarter strings. (not adopted; caller retains ownership) 1.392 + * @param count Filled in with length of the array. 1.393 + * @param context The formatting context, either FORMAT or STANDALONE 1.394 + * @param width The width of returned strings, either WIDE or ABBREVIATED. There 1.395 + * are no NARROW quarters. 1.396 + * @stable ICU 3.6 1.397 + */ 1.398 + void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width); 1.399 + 1.400 + /** 1.401 + * Gets AM/PM strings. For example: "AM" and "PM". 1.402 + * @param count Filled in with length of the array. 1.403 + * @return the weekday strings. (DateFormatSymbols retains ownership.) 1.404 + * @stable ICU 2.0 1.405 + */ 1.406 + const UnicodeString* getAmPmStrings(int32_t& count) const; 1.407 + 1.408 + /** 1.409 + * Sets ampm strings. For example: "AM" and "PM". 1.410 + * @param ampms the new ampm strings. (not adopted; caller retains ownership) 1.411 + * @param count Filled in with length of the array. 1.412 + * @stable ICU 2.0 1.413 + */ 1.414 + void setAmPmStrings(const UnicodeString* ampms, int32_t count); 1.415 + 1.416 +#ifndef U_HIDE_INTERNAL_API 1.417 + /** 1.418 + * Somewhat temporary constants for leap month pattern types, adequate for supporting 1.419 + * just leap month patterns as needed for Chinese lunar calendar. 1.420 + * Eventually we will add full support for different month pattern types (needed for 1.421 + * other calendars such as Hindu) at which point this approach will be replaced by a 1.422 + * more complete approach. 1.423 + * @internal 1.424 + */ 1.425 + enum EMonthPatternType 1.426 + { 1.427 + kLeapMonthPatternFormatWide, 1.428 + kLeapMonthPatternFormatAbbrev, 1.429 + kLeapMonthPatternFormatNarrow, 1.430 + kLeapMonthPatternStandaloneWide, 1.431 + kLeapMonthPatternStandaloneAbbrev, 1.432 + kLeapMonthPatternStandaloneNarrow, 1.433 + kLeapMonthPatternNumeric, 1.434 + kMonthPatternsCount 1.435 + }; 1.436 + 1.437 + /** 1.438 + * Somewhat temporary function for getting complete set of leap month patterns for all 1.439 + * contexts & widths, indexed by EMonthPatternType values. Returns NULL if calendar 1.440 + * does not have leap month patterns. Note, there is currently no setter for this. 1.441 + * Eventually we will add full support for different month pattern types (needed for 1.442 + * other calendars such as Hindu) at which point this approach will be replaced by a 1.443 + * more complete approach. 1.444 + * @param count Filled in with length of the array (may be 0). 1.445 + * @return The leap month patterns (DateFormatSymbols retains ownership). 1.446 + * May be NULL if there are no leap month patterns for this calendar. 1.447 + * @internal 1.448 + */ 1.449 + const UnicodeString* getLeapMonthPatterns(int32_t& count) const; 1.450 + 1.451 +#endif /* U_HIDE_INTERNAL_API */ 1.452 + 1.453 +#ifndef U_HIDE_DEPRECATED_API 1.454 + /** 1.455 + * Gets timezone strings. These strings are stored in a 2-dimensional array. 1.456 + * @param rowCount Output param to receive number of rows. 1.457 + * @param columnCount Output param to receive number of columns. 1.458 + * @return The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.) 1.459 + * @deprecated ICU 3.6 1.460 + */ 1.461 + const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const; 1.462 +#endif /* U_HIDE_DEPRECATED_API */ 1.463 + 1.464 + /** 1.465 + * Sets timezone strings. These strings are stored in a 2-dimensional array. 1.466 + * <p><b>Note:</b> SimpleDateFormat no longer use the zone strings stored in 1.467 + * a DateFormatSymbols. Therefore, the time zone strings set by this mthod 1.468 + * have no effects in an instance of SimpleDateFormat for formatting time 1.469 + * zones. 1.470 + * @param strings The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership) 1.471 + * @param rowCount The number of rows (count of first index). 1.472 + * @param columnCount The number of columns (count of second index). 1.473 + * @stable ICU 2.0 1.474 + */ 1.475 + void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount); 1.476 + 1.477 + /** 1.478 + * Get the non-localized date-time pattern characters. 1.479 + * @return the non-localized date-time pattern characters 1.480 + * @stable ICU 2.0 1.481 + */ 1.482 + static const UChar * U_EXPORT2 getPatternUChars(void); 1.483 + 1.484 + /** 1.485 + * Gets localized date-time pattern characters. For example: 'u', 't', etc. 1.486 + * <p> 1.487 + * Note: ICU no longer provides localized date-time pattern characters for a locale 1.488 + * starting ICU 3.8. This method returns the non-localized date-time pattern 1.489 + * characters unless user defined localized data is set by setLocalPatternChars. 1.490 + * @param result Output param which will receive the localized date-time pattern characters. 1.491 + * @return A reference to 'result'. 1.492 + * @stable ICU 2.0 1.493 + */ 1.494 + UnicodeString& getLocalPatternChars(UnicodeString& result) const; 1.495 + 1.496 + /** 1.497 + * Sets localized date-time pattern characters. For example: 'u', 't', etc. 1.498 + * @param newLocalPatternChars the new localized date-time 1.499 + * pattern characters. 1.500 + * @stable ICU 2.0 1.501 + */ 1.502 + void setLocalPatternChars(const UnicodeString& newLocalPatternChars); 1.503 + 1.504 + /** 1.505 + * Returns the locale for this object. Two flavors are available: 1.506 + * valid and actual locale. 1.507 + * @stable ICU 2.8 1.508 + */ 1.509 + Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const; 1.510 + 1.511 + /** 1.512 + * Constants for capitalization context usage types. 1.513 + * @internal 1.514 + */ 1.515 + enum ECapitalizationContextUsageType 1.516 + { 1.517 + kCapContextUsageOther, 1.518 + kCapContextUsageMonthFormat, /* except narrow */ 1.519 + kCapContextUsageMonthStandalone, /* except narrow */ 1.520 + kCapContextUsageMonthNarrow, 1.521 + kCapContextUsageDayFormat, /* except narrow */ 1.522 + kCapContextUsageDayStandalone, /* except narrow */ 1.523 + kCapContextUsageDayNarrow, 1.524 + kCapContextUsageEraWide, 1.525 + kCapContextUsageEraAbbrev, 1.526 + kCapContextUsageEraNarrow, 1.527 + kCapContextUsageZoneLong, 1.528 + kCapContextUsageZoneShort, 1.529 + kCapContextUsageMetazoneLong, 1.530 + kCapContextUsageMetazoneShort, 1.531 + kCapContextUsageTypeCount 1.532 + }; 1.533 + 1.534 + /** 1.535 + * ICU "poor man's RTTI", returns a UClassID for the actual class. 1.536 + * 1.537 + * @stable ICU 2.2 1.538 + */ 1.539 + virtual UClassID getDynamicClassID() const; 1.540 + 1.541 + /** 1.542 + * ICU "poor man's RTTI", returns a UClassID for this class. 1.543 + * 1.544 + * @stable ICU 2.2 1.545 + */ 1.546 + static UClassID U_EXPORT2 getStaticClassID(); 1.547 + 1.548 +private: 1.549 + 1.550 + friend class SimpleDateFormat; 1.551 + friend class DateFormatSymbolsSingleSetter; // see udat.cpp 1.552 + 1.553 + /** 1.554 + * Abbreviated era strings. For example: "AD" and "BC". 1.555 + */ 1.556 + UnicodeString* fEras; 1.557 + int32_t fErasCount; 1.558 + 1.559 + /** 1.560 + * Era name strings. For example: "Anno Domini" and "Before Christ". 1.561 + */ 1.562 + UnicodeString* fEraNames; 1.563 + int32_t fEraNamesCount; 1.564 + 1.565 + /** 1.566 + * Narrow era strings. For example: "A" and "B". 1.567 + */ 1.568 + UnicodeString* fNarrowEras; 1.569 + int32_t fNarrowErasCount; 1.570 + 1.571 + /** 1.572 + * Month strings. For example: "January", "February", etc. 1.573 + */ 1.574 + UnicodeString* fMonths; 1.575 + int32_t fMonthsCount; 1.576 + 1.577 + /** 1.578 + * Short month strings. For example: "Jan", "Feb", etc. 1.579 + */ 1.580 + UnicodeString* fShortMonths; 1.581 + int32_t fShortMonthsCount; 1.582 + 1.583 + /** 1.584 + * Narrow month strings. For example: "J", "F", etc. 1.585 + */ 1.586 + UnicodeString* fNarrowMonths; 1.587 + int32_t fNarrowMonthsCount; 1.588 + 1.589 + /** 1.590 + * Standalone Month strings. For example: "January", "February", etc. 1.591 + */ 1.592 + UnicodeString* fStandaloneMonths; 1.593 + int32_t fStandaloneMonthsCount; 1.594 + 1.595 + /** 1.596 + * Standalone Short month strings. For example: "Jan", "Feb", etc. 1.597 + */ 1.598 + UnicodeString* fStandaloneShortMonths; 1.599 + int32_t fStandaloneShortMonthsCount; 1.600 + 1.601 + /** 1.602 + * Standalone Narrow month strings. For example: "J", "F", etc. 1.603 + */ 1.604 + UnicodeString* fStandaloneNarrowMonths; 1.605 + int32_t fStandaloneNarrowMonthsCount; 1.606 + 1.607 + /** 1.608 + * CLDR-style format wide weekday strings. For example: "Sunday", "Monday", etc. 1.609 + */ 1.610 + UnicodeString* fWeekdays; 1.611 + int32_t fWeekdaysCount; 1.612 + 1.613 + /** 1.614 + * CLDR-style format abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc. 1.615 + */ 1.616 + UnicodeString* fShortWeekdays; 1.617 + int32_t fShortWeekdaysCount; 1.618 + 1.619 + /** 1.620 + * CLDR-style format short weekday strings. For example: "Su", "Mo", etc. 1.621 + */ 1.622 + UnicodeString* fShorterWeekdays; 1.623 + int32_t fShorterWeekdaysCount; 1.624 + 1.625 + /** 1.626 + * CLDR-style format narrow weekday strings. For example: "S", "M", etc. 1.627 + */ 1.628 + UnicodeString* fNarrowWeekdays; 1.629 + int32_t fNarrowWeekdaysCount; 1.630 + 1.631 + /** 1.632 + * CLDR-style standalone wide weekday strings. For example: "Sunday", "Monday", etc. 1.633 + */ 1.634 + UnicodeString* fStandaloneWeekdays; 1.635 + int32_t fStandaloneWeekdaysCount; 1.636 + 1.637 + /** 1.638 + * CLDR-style standalone abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc. 1.639 + */ 1.640 + UnicodeString* fStandaloneShortWeekdays; 1.641 + int32_t fStandaloneShortWeekdaysCount; 1.642 + 1.643 + /** 1.644 + * CLDR-style standalone short weekday strings. For example: "Su", "Mo", etc. 1.645 + */ 1.646 + UnicodeString* fStandaloneShorterWeekdays; 1.647 + int32_t fStandaloneShorterWeekdaysCount; 1.648 + 1.649 + /** 1.650 + * Standalone Narrow weekday strings. For example: "Sun", "Mon", etc. 1.651 + */ 1.652 + UnicodeString* fStandaloneNarrowWeekdays; 1.653 + int32_t fStandaloneNarrowWeekdaysCount; 1.654 + 1.655 + /** 1.656 + * Ampm strings. For example: "AM" and "PM". 1.657 + */ 1.658 + UnicodeString* fAmPms; 1.659 + int32_t fAmPmsCount; 1.660 + 1.661 + /** 1.662 + * Quarter strings. For example: "1st quarter", "2nd quarter", etc. 1.663 + */ 1.664 + UnicodeString *fQuarters; 1.665 + int32_t fQuartersCount; 1.666 + 1.667 + /** 1.668 + * Short quarters. For example: "Q1", "Q2", etc. 1.669 + */ 1.670 + UnicodeString *fShortQuarters; 1.671 + int32_t fShortQuartersCount; 1.672 + 1.673 + /** 1.674 + * Standalone quarter strings. For example: "1st quarter", "2nd quarter", etc. 1.675 + */ 1.676 + UnicodeString *fStandaloneQuarters; 1.677 + int32_t fStandaloneQuartersCount; 1.678 + 1.679 + /** 1.680 + * Standalone short quarter strings. For example: "Q1", "Q2", etc. 1.681 + */ 1.682 + UnicodeString *fStandaloneShortQuarters; 1.683 + int32_t fStandaloneShortQuartersCount; 1.684 + 1.685 + /** 1.686 + * All leap month patterns, for example "{0}bis". 1.687 + */ 1.688 + UnicodeString *fLeapMonthPatterns; 1.689 + int32_t fLeapMonthPatternsCount; 1.690 + 1.691 + /** 1.692 + * (Format) Short cyclic year names, for example: "jia-zi", "yi-chou", ... "gui-hai" 1.693 + */ 1.694 + UnicodeString* fShortYearNames; 1.695 + int32_t fShortYearNamesCount; 1.696 + 1.697 + /** 1.698 + * Localized names of time zones in this locale. This is a 1.699 + * two-dimensional array of strings of size n by m, 1.700 + * where m is at least 5 and up to 7. Each of the n rows is an 1.701 + * entry containing the localized names for a single TimeZone. 1.702 + * 1.703 + * Each such row contains (with i ranging from 0..n-1): 1.704 + * 1.705 + * zoneStrings[i][0] - time zone ID 1.706 + * example: America/Los_Angeles 1.707 + * zoneStrings[i][1] - long name of zone in standard time 1.708 + * example: Pacific Standard Time 1.709 + * zoneStrings[i][2] - short name of zone in standard time 1.710 + * example: PST 1.711 + * zoneStrings[i][3] - long name of zone in daylight savings time 1.712 + * example: Pacific Daylight Time 1.713 + * zoneStrings[i][4] - short name of zone in daylight savings time 1.714 + * example: PDT 1.715 + * zoneStrings[i][5] - location name of zone 1.716 + * example: United States (Los Angeles) 1.717 + * zoneStrings[i][6] - long generic name of zone 1.718 + * example: Pacific Time 1.719 + * zoneStrings[i][7] - short generic of zone 1.720 + * example: PT 1.721 + * 1.722 + * The zone ID is not localized; it corresponds to the ID 1.723 + * value associated with a system time zone object. All other entries 1.724 + * are localized names. If a zone does not implement daylight savings 1.725 + * time, the daylight savings time names are ignored. 1.726 + * 1.727 + * Note:CLDR 1.5 introduced metazone and its historical mappings. 1.728 + * This simple two-dimensional array is no longer sufficient to represent 1.729 + * localized names and its historic changes. Since ICU 3.8.1, localized 1.730 + * zone names extracted from ICU locale data is stored in a ZoneStringFormat 1.731 + * instance. But we still need to support the old way of customizing 1.732 + * localized zone names, so we keep this field for the purpose. 1.733 + */ 1.734 + UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings 1.735 + UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale 1.736 + int32_t fZoneStringsRowCount; 1.737 + int32_t fZoneStringsColCount; 1.738 + 1.739 + Locale fZSFLocale; // Locale used for getting ZoneStringFormat 1.740 + 1.741 + /** 1.742 + * Localized date-time pattern characters. For example: use 'u' as 'y'. 1.743 + */ 1.744 + UnicodeString fLocalPatternChars; 1.745 + 1.746 + /** 1.747 + * Capitalization transforms. For each usage type, the first array element indicates 1.748 + * whether to titlecase for uiListOrMenu context, the second indicates whether to 1.749 + * titlecase for stand-alone context. 1.750 + */ 1.751 + UBool fCapitalization[kCapContextUsageTypeCount][2]; 1.752 + 1.753 +private: 1.754 + /** valid/actual locale information 1.755 + * these are always ICU locales, so the length should not be a problem 1.756 + */ 1.757 + char validLocale[ULOC_FULLNAME_CAPACITY]; 1.758 + char actualLocale[ULOC_FULLNAME_CAPACITY]; 1.759 + 1.760 + DateFormatSymbols(); // default constructor not implemented 1.761 + 1.762 + /** 1.763 + * Called by the constructors to actually load data from the resources 1.764 + * 1.765 + * @param locale The locale to get symbols for. 1.766 + * @param type Calendar Type (as from Calendar::getType()) 1.767 + * @param status Input/output parameter, set to success or 1.768 + * failure code upon return. 1.769 + * @param useLastResortData determine if use last resort data 1.770 + */ 1.771 + void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE); 1.772 + 1.773 + /** 1.774 + * Copy or alias an array in another object, as appropriate. 1.775 + * 1.776 + * @param dstArray the copy destination array. 1.777 + * @param dstCount fill in with the lenth of 'dstArray'. 1.778 + * @param srcArray the source array to be copied. 1.779 + * @param srcCount the length of items to be copied from the 'srcArray'. 1.780 + */ 1.781 + static void assignArray(UnicodeString*& dstArray, 1.782 + int32_t& dstCount, 1.783 + const UnicodeString* srcArray, 1.784 + int32_t srcCount); 1.785 + 1.786 + /** 1.787 + * Return true if the given arrays' contents are equal, or if the arrays are 1.788 + * identical (pointers are equal). 1.789 + * 1.790 + * @param array1 one array to be compared with. 1.791 + * @param array2 another array to be compared with. 1.792 + * @param count the length of items to be copied. 1.793 + * @return true if the given arrays' contents are equal, or if the arrays are 1.794 + * identical (pointers are equal). 1.795 + */ 1.796 + static UBool arrayCompare(const UnicodeString* array1, 1.797 + const UnicodeString* array2, 1.798 + int32_t count); 1.799 + 1.800 + /** 1.801 + * Create a copy, in fZoneStrings, of the given zone strings array. The 1.802 + * member variables fZoneStringsRowCount and fZoneStringsColCount should be 1.803 + * set already by the caller. 1.804 + */ 1.805 + void createZoneStrings(const UnicodeString *const * otherStrings); 1.806 + 1.807 + /** 1.808 + * Delete all the storage owned by this object. 1.809 + */ 1.810 + void dispose(void); 1.811 + 1.812 + /** 1.813 + * Copy all of the other's data to this. 1.814 + * @param other the object to be copied. 1.815 + */ 1.816 + void copyData(const DateFormatSymbols& other); 1.817 + 1.818 + /** 1.819 + * Create zone strings array by locale if not yet available 1.820 + */ 1.821 + void initZoneStringsArray(void); 1.822 + 1.823 + /** 1.824 + * Delete just the zone strings. 1.825 + */ 1.826 + void disposeZoneStrings(void); 1.827 + 1.828 + /** 1.829 + * Returns the date format field index of the pattern character c, 1.830 + * or UDAT_FIELD_COUNT if c is not a pattern character. 1.831 + */ 1.832 + static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c); 1.833 + 1.834 + /** 1.835 + * Returns TRUE if f (with its pattern character repeated count times) is a numeric field. 1.836 + */ 1.837 + static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count); 1.838 + 1.839 + /** 1.840 + * Returns TRUE if c (repeated count times) is the pattern character for a numeric field. 1.841 + */ 1.842 + static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count); 1.843 +}; 1.844 + 1.845 +U_NAMESPACE_END 1.846 + 1.847 +#endif /* #if !UCONFIG_NO_FORMATTING */ 1.848 + 1.849 +#endif // _DTFMTSYM 1.850 +//eof