intl/icu/source/i18n/unicode/dtfmtsym.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

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

mercurial