dtptngen.h (29983B)
1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ******************************************************************************* 5 * Copyright (C) 2007-2016, International Business Machines Corporation and 6 * others. All Rights Reserved. 7 ******************************************************************************* 8 * 9 * File DTPTNGEN.H 10 * 11 ******************************************************************************* 12 */ 13 14 #ifndef __DTPTNGEN_H__ 15 #define __DTPTNGEN_H__ 16 17 #include "unicode/utypes.h" 18 19 #if U_SHOW_CPLUSPLUS_API 20 21 #include "unicode/datefmt.h" 22 #include "unicode/locid.h" 23 #include "unicode/udat.h" 24 #include "unicode/udatpg.h" 25 #include "unicode/unistr.h" 26 27 U_NAMESPACE_BEGIN 28 29 /** 30 * \file 31 * \brief C++ API: Date/Time Pattern Generator 32 */ 33 34 35 class CharString; 36 class Hashtable; 37 class FormatParser; 38 class DateTimeMatcher; 39 class DistanceInfo; 40 class PatternMap; 41 class PtnSkeleton; 42 class SharedDateTimePatternGenerator; 43 44 /** 45 * This class provides flexible generation of date format patterns, like "yy-MM-dd". 46 * The user can build up the generator by adding successive patterns. Once that 47 * is done, a query can be made using a "skeleton", which is a pattern which just 48 * includes the desired fields and lengths. The generator will return the "best fit" 49 * pattern corresponding to that skeleton. 50 * <p>The main method people will use is getBestPattern(String skeleton), 51 * since normally this class is pre-built with data from a particular locale. 52 * However, generators can be built directly from other data as well. 53 * <p><i>Issue: may be useful to also have a function that returns the list of 54 * fields in a pattern, in order, since we have that internally. 55 * That would be useful for getting the UI order of field elements.</i> 56 * @stable ICU 3.8 57 **/ 58 class U_I18N_API_CLASS DateTimePatternGenerator : public UObject { 59 public: 60 /** 61 * Construct a flexible generator according to default locale. 62 * @param status Output param set to success/failure code on exit, 63 * which must not indicate a failure before the function call. 64 * @stable ICU 3.8 65 */ 66 U_I18N_API static DateTimePatternGenerator* createInstance(UErrorCode& status); 67 68 /** 69 * Construct a flexible generator according to data for a given locale. 70 * @param uLocale 71 * @param status Output param set to success/failure code on exit, 72 * which must not indicate a failure before the function call. 73 * @stable ICU 3.8 74 */ 75 U_I18N_API static DateTimePatternGenerator* createInstance(const Locale& uLocale, UErrorCode& status); 76 77 #ifndef U_HIDE_INTERNAL_API 78 79 /** 80 * For ICU use only. Skips loading the standard date/time patterns (which is done via DateFormat). 81 * 82 * @internal 83 */ 84 U_I18N_API static DateTimePatternGenerator* createInstanceNoStdPat(const Locale& uLocale, 85 UErrorCode& status); 86 87 #endif /* U_HIDE_INTERNAL_API */ 88 89 /** 90 * Create an empty generator, to be constructed with addPattern(...) etc. 91 * @param status Output param set to success/failure code on exit, 92 * which must not indicate a failure before the function call. 93 * @stable ICU 3.8 94 */ 95 U_I18N_API static DateTimePatternGenerator* createEmptyInstance(UErrorCode& status); 96 97 /** 98 * Destructor. 99 * @stable ICU 3.8 100 */ 101 U_I18N_API virtual ~DateTimePatternGenerator(); 102 103 /** 104 * Clone DateTimePatternGenerator object. Clients are responsible for 105 * deleting the DateTimePatternGenerator object cloned. 106 * @stable ICU 3.8 107 */ 108 U_I18N_API DateTimePatternGenerator* clone() const; 109 110 /** 111 * Return true if another object is semantically equal to this one. 112 * 113 * @param other the DateTimePatternGenerator object to be compared with. 114 * @return true if other is semantically equal to this. 115 * @stable ICU 3.8 116 */ 117 U_I18N_API bool operator==(const DateTimePatternGenerator& other) const; 118 119 /** 120 * Return true if another object is semantically unequal to this one. 121 * 122 * @param other the DateTimePatternGenerator object to be compared with. 123 * @return true if other is semantically unequal to this. 124 * @stable ICU 3.8 125 */ 126 U_I18N_API bool operator!=(const DateTimePatternGenerator& other) const; 127 128 /** 129 * Utility to return a unique skeleton from a given pattern. For example, 130 * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". 131 * 132 * @param pattern Input pattern, such as "dd/MMM" 133 * @param status Output param set to success/failure code on exit, 134 * which must not indicate a failure before the function call. 135 * @return skeleton such as "MMMdd" 136 * @stable ICU 56 137 */ 138 U_I18N_API static UnicodeString staticGetSkeleton(const UnicodeString& pattern, UErrorCode& status); 139 140 /** 141 * Utility to return a unique skeleton from a given pattern. For example, 142 * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". 143 * getSkeleton() works exactly like staticGetSkeleton(). 144 * Use staticGetSkeleton() instead of getSkeleton(). 145 * 146 * @param pattern Input pattern, such as "dd/MMM" 147 * @param status Output param set to success/failure code on exit, 148 * which must not indicate a failure before the function call. 149 * @return skeleton such as "MMMdd" 150 * @stable ICU 3.8 151 */ 152 U_I18N_API UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status); /* { 153 The function is commented out because it is a stable API calling a draft API. 154 After staticGetSkeleton becomes stable, staticGetSkeleton can be used and 155 these comments and the definition of getSkeleton in dtptngen.cpp should be removed. 156 return staticGetSkeleton(pattern, status); 157 }*/ 158 159 /** 160 * Utility to return a unique base skeleton from a given pattern. This is 161 * the same as the skeleton, except that differences in length are minimized 162 * so as to only preserve the difference between string and numeric form. So 163 * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" 164 * (notice the single d). 165 * 166 * @param pattern Input pattern, such as "dd/MMM" 167 * @param status Output param set to success/failure code on exit, 168 * which must not indicate a failure before the function call. 169 * @return base skeleton, such as "MMMd" 170 * @stable ICU 56 171 */ 172 U_I18N_API static UnicodeString staticGetBaseSkeleton(const UnicodeString& pattern, 173 UErrorCode& status); 174 175 /** 176 * Utility to return a unique base skeleton from a given pattern. This is 177 * the same as the skeleton, except that differences in length are minimized 178 * so as to only preserve the difference between string and numeric form. So 179 * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" 180 * (notice the single d). 181 * getBaseSkeleton() works exactly like staticGetBaseSkeleton(). 182 * Use staticGetBaseSkeleton() instead of getBaseSkeleton(). 183 * 184 * @param pattern Input pattern, such as "dd/MMM" 185 * @param status Output param set to success/failure code on exit, 186 * which must not indicate a failure before the function call. 187 * @return base skeleton, such as "MMMd" 188 * @stable ICU 3.8 189 */ 190 U_I18N_API UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status); /* { 191 The function is commented out because it is a stable API calling a draft API. 192 After staticGetBaseSkeleton becomes stable, staticGetBaseSkeleton can be used and 193 these comments and the definition of getBaseSkeleton in dtptngen.cpp should be removed. 194 return staticGetBaseSkeleton(pattern, status); 195 }*/ 196 197 /** 198 * Adds a pattern to the generator. If the pattern has the same skeleton as 199 * an existing pattern, and the override parameter is set, then the previous 200 * value is overridden. Otherwise, the previous value is retained. In either 201 * case, the conflicting status is set and previous vale is stored in 202 * conflicting pattern. 203 * <p> 204 * Note that single-field patterns (like "MMM") are automatically added, and 205 * don't need to be added explicitly! 206 * 207 * @param pattern Input pattern, such as "dd/MMM" 208 * @param override When existing values are to be overridden use true, 209 * otherwise use false. 210 * @param conflictingPattern Previous pattern with the same skeleton. 211 * @param status Output param set to success/failure code on exit, 212 * which must not indicate a failure before the function call. 213 * @return conflicting status. The value could be UDATPG_NO_CONFLICT, 214 * UDATPG_BASE_CONFLICT or UDATPG_CONFLICT. 215 * @stable ICU 3.8 216 */ 217 U_I18N_API UDateTimePatternConflict addPattern(const UnicodeString& pattern, 218 UBool override, 219 UnicodeString& conflictingPattern, 220 UErrorCode& status); 221 222 #ifndef U_HIDE_INTERNAL_API 223 /** 224 * Like addPattern, but associates the pattern with the given skeleton. 225 * 226 * @internal ICU 78 227 */ 228 U_I18N_API UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, 229 const UnicodeString& skeletonToUse, 230 UBool override, 231 UnicodeString& conflictingPattern, 232 UErrorCode& status); 233 #endif /* U_HIDE_INTERNAL_API */ 234 235 /** 236 * An AppendItem format is a pattern used to append a field if there is no 237 * good match. For example, suppose that the input skeleton is "GyyyyMMMd", 238 * and there is no matching pattern internally, but there is a pattern 239 * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the 240 * G. The way these two are conjoined is by using the AppendItemFormat for G 241 * (era). So if that value is, say "{0}, {1}" then the final resulting 242 * pattern is "d-MM-yyyy, G". 243 * <p> 244 * There are actually three available variables: {0} is the pattern so far, 245 * {1} is the element we are adding, and {2} is the name of the element. 246 * <p> 247 * This reflects the way that the CLDR data is organized. 248 * 249 * @param field such as UDATPG_ERA_FIELD. 250 * @param value pattern, such as "{0}, {1}" 251 * @stable ICU 3.8 252 */ 253 U_I18N_API void setAppendItemFormat(UDateTimePatternField field, const UnicodeString& value); 254 255 /** 256 * Getter corresponding to setAppendItemFormat. Values below 0 or at or 257 * above UDATPG_FIELD_COUNT are illegal arguments. 258 * 259 * @param field such as UDATPG_ERA_FIELD. 260 * @return append pattern for field 261 * @stable ICU 3.8 262 */ 263 U_I18N_API const UnicodeString& getAppendItemFormat(UDateTimePatternField field) const; 264 265 /** 266 * Sets the names of field, eg "era" in English for ERA. These are only 267 * used if the corresponding AppendItemFormat is used, and if it contains a 268 * {2} variable. 269 * <p> 270 * This reflects the way that the CLDR data is organized. 271 * 272 * @param field such as UDATPG_ERA_FIELD. 273 * @param value name of the field 274 * @stable ICU 3.8 275 */ 276 U_I18N_API void setAppendItemName(UDateTimePatternField field, const UnicodeString& value); 277 278 /** 279 * Getter corresponding to setAppendItemNames. Values below 0 or at or above 280 * UDATPG_FIELD_COUNT are illegal arguments. Note: The more general method 281 * for getting date/time field display names is getFieldDisplayName. 282 * 283 * @param field such as UDATPG_ERA_FIELD. 284 * @return name for field 285 * @see getFieldDisplayName 286 * @stable ICU 3.8 287 */ 288 U_I18N_API const UnicodeString& getAppendItemName(UDateTimePatternField field) const; 289 290 /** 291 * The general interface to get a display name for a particular date/time field, 292 * in one of several possible display widths. 293 * 294 * @param field The desired UDateTimePatternField, such as UDATPG_ERA_FIELD. 295 * @param width The desired UDateTimePGDisplayWidth, such as UDATPG_ABBREVIATED. 296 * @return The display name for field 297 * @stable ICU 61 298 */ 299 U_I18N_API UnicodeString getFieldDisplayName(UDateTimePatternField field, 300 UDateTimePGDisplayWidth width) const; 301 302 /** 303 * The DateTimeFormat is a message format pattern used to compose date and 304 * time patterns. The default pattern in the root locale is "{1} {0}", where 305 * {1} will be replaced by the date pattern and {0} will be replaced by the 306 * time pattern; however, other locales may specify patterns such as 307 * "{1}, {0}" or "{1} 'at' {0}", etc. 308 * <p> 309 * This is used when the input skeleton contains both date and time fields, 310 * but there is not a close match among the added patterns. For example, 311 * suppose that this object was created by adding "dd-MMM" and "hh:mm", and 312 * its datetimeFormat is the default "{1} {0}". Then if the input skeleton 313 * is "MMMdhmm", there is not an exact match, so the input skeleton is 314 * broken up into two components "MMMd" and "hmm". There are close matches 315 * for those two skeletons, so the result is put together with this pattern, 316 * resulting in "d-MMM h:mm". 317 * 318 * There are four DateTimeFormats in a DateTimePatternGenerator object, 319 * corresponding to date styles UDAT_FULL..UDAT_SHORT. This method sets 320 * all of them to the specified pattern. To set them individually, see 321 * setDateTimeFormat(UDateFormatStyle style, ...). 322 * 323 * @param dateTimeFormat 324 * message format pattern, here {1} will be replaced by the date 325 * pattern and {0} will be replaced by the time pattern. 326 * @stable ICU 3.8 327 */ 328 U_I18N_API void setDateTimeFormat(const UnicodeString& dateTimeFormat); 329 330 /** 331 * Getter corresponding to setDateTimeFormat. 332 * 333 * There are four DateTimeFormats in a DateTimePatternGenerator object, 334 * corresponding to date styles UDAT_FULL..UDAT_SHORT. This method gets 335 * the style for UDAT_MEDIUM (the default). To get them individually, see 336 * getDateTimeFormat(UDateFormatStyle style). 337 * 338 * @return DateTimeFormat. 339 * @stable ICU 3.8 340 */ 341 U_I18N_API const UnicodeString& getDateTimeFormat() const; 342 343 #if !UCONFIG_NO_FORMATTING 344 /** 345 * dateTimeFormats are message patterns used to compose combinations of date 346 * and time patterns. There are four length styles, corresponding to the 347 * inferred style of the date pattern; these are UDateFormatStyle values: 348 * - UDAT_FULL (for date pattern with weekday and long month), else 349 * - UDAT_LONG (for a date pattern with long month), else 350 * - UDAT_MEDIUM (for a date pattern with abbreviated month), else 351 * - UDAT_SHORT (for any other date pattern). 352 * For details on dateTimeFormats, see 353 * https://www.unicode.org/reports/tr35/tr35-dates.html#dateTimeFormats. 354 * The default pattern in the root locale for all styles is "{1} {0}". 355 * 356 * @param style 357 * one of DateFormat.FULL..DateFormat.SHORT. Error if out of range. 358 * @param dateTimeFormat 359 * the new dateTimeFormat to set for the specified style 360 * @param status 361 * in/out parameter; if no failure status is already set, 362 * it will be set according to result of the function (e.g. 363 * U_ILLEGAL_ARGUMENT_ERROR for style out of range). 364 * @stable ICU 71 365 */ 366 U_I18N_API void setDateTimeFormat(UDateFormatStyle style, 367 const UnicodeString& dateTimeFormat, 368 UErrorCode& status); 369 370 /** 371 * Getter corresponding to setDateTimeFormat. 372 * 373 * @param style 374 * one of UDAT_FULL..UDAT_SHORT. Error if out of range. 375 * @param status 376 * in/out parameter; if no failure status is already set, 377 * it will be set according to result of the function (e.g. 378 * U_ILLEGAL_ARGUMENT_ERROR for style out of range). 379 * @return 380 * the current dateTimeFormat for the specified style, or 381 * empty string in case of error. The UnicodeString reference, 382 * or the contents of the string, may no longer be valid if 383 * setDateTimeFormat is called, or the DateTimePatternGenerator 384 * object is deleted. 385 * @stable ICU 71 386 */ 387 U_I18N_API const UnicodeString& getDateTimeFormat(UDateFormatStyle style, UErrorCode& status) const; 388 #endif /* #if !UCONFIG_NO_FORMATTING */ 389 390 /** 391 * Return the best pattern matching the input skeleton. It is guaranteed to 392 * have all of the fields in the skeleton. 393 * 394 * @param skeleton 395 * The skeleton is a pattern containing only the variable fields. 396 * For example, "MMMdd" and "mmhh" are skeletons. 397 * @param status Output param set to success/failure code on exit, 398 * which must not indicate a failure before the function call. 399 * @return bestPattern 400 * The best pattern found from the given skeleton. 401 * @stable ICU 3.8 402 */ 403 U_I18N_API UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status); 404 405 /** 406 * Return the best pattern matching the input skeleton. It is guaranteed to 407 * have all of the fields in the skeleton. 408 * 409 * @param skeleton 410 * The skeleton is a pattern containing only the variable fields. 411 * For example, "MMMdd" and "mmhh" are skeletons. 412 * @param options 413 * Options for forcing the length of specified fields in the 414 * returned pattern to match those in the skeleton (when this 415 * would not happen otherwise). For default behavior, use 416 * UDATPG_MATCH_NO_OPTIONS. 417 * @param status 418 * Output param set to success/failure code on exit, 419 * which must not indicate a failure before the function call. 420 * @return bestPattern 421 * The best pattern found from the given skeleton. 422 * @stable ICU 4.4 423 */ 424 U_I18N_API UnicodeString getBestPattern(const UnicodeString& skeleton, 425 UDateTimePatternMatchOptions options, 426 UErrorCode& status); 427 428 /** 429 * Adjusts the field types (width and subtype) of a pattern to match what is 430 * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a 431 * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be 432 * "dd-MMMM hh:mm". This is used internally to get the best match for the 433 * input skeleton, but can also be used externally. 434 * 435 * @param pattern Input pattern 436 * @param skeleton 437 * The skeleton is a pattern containing only the variable fields. 438 * For example, "MMMdd" and "mmhh" are skeletons. 439 * @param status Output param set to success/failure code on exit, 440 * which must not indicate a failure before the function call. 441 * @return pattern adjusted to match the skeleton fields widths and subtypes. 442 * @stable ICU 3.8 443 */ 444 U_I18N_API UnicodeString replaceFieldTypes(const UnicodeString& pattern, 445 const UnicodeString& skeleton, 446 UErrorCode& status); 447 448 /** 449 * Adjusts the field types (width and subtype) of a pattern to match what is 450 * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a 451 * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be 452 * "dd-MMMM hh:mm". This is used internally to get the best match for the 453 * input skeleton, but can also be used externally. 454 * 455 * @param pattern Input pattern 456 * @param skeleton 457 * The skeleton is a pattern containing only the variable fields. 458 * For example, "MMMdd" and "mmhh" are skeletons. 459 * @param options 460 * Options controlling whether the length of specified fields in the 461 * pattern are adjusted to match those in the skeleton (when this 462 * would not happen otherwise). For default behavior, use 463 * UDATPG_MATCH_NO_OPTIONS. 464 * @param status 465 * Output param set to success/failure code on exit, 466 * which must not indicate a failure before the function call. 467 * @return pattern adjusted to match the skeleton fields widths and subtypes. 468 * @stable ICU 4.4 469 */ 470 U_I18N_API UnicodeString replaceFieldTypes(const UnicodeString& pattern, 471 const UnicodeString& skeleton, 472 UDateTimePatternMatchOptions options, 473 UErrorCode& status); 474 475 /** 476 * Return a list of all the skeletons (in canonical form) from this class. 477 * 478 * Call getPatternForSkeleton() to get the corresponding pattern. 479 * 480 * @param status Output param set to success/failure code on exit, 481 * which must not indicate a failure before the function call. 482 * @return StringEnumeration with the skeletons. 483 * The caller must delete the object. 484 * @stable ICU 3.8 485 */ 486 U_I18N_API StringEnumeration* getSkeletons(UErrorCode& status) const; 487 488 /** 489 * Get the pattern corresponding to a given skeleton. 490 * @param skeleton 491 * @return pattern corresponding to a given skeleton. 492 * @stable ICU 3.8 493 */ 494 U_I18N_API const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const; 495 496 /** 497 * Return a list of all the base skeletons (in canonical form) from this class. 498 * 499 * @param status Output param set to success/failure code on exit, 500 * which must not indicate a failure before the function call. 501 * @return a StringEnumeration with the base skeletons. 502 * The caller must delete the object. 503 * @stable ICU 3.8 504 */ 505 U_I18N_API StringEnumeration* getBaseSkeletons(UErrorCode& status) const; 506 507 #ifndef U_HIDE_INTERNAL_API 508 /** 509 * Return a list of redundant patterns are those which if removed, make no 510 * difference in the resulting getBestPattern values. This method returns a 511 * list of them, to help check the consistency of the patterns used to build 512 * this generator. 513 * 514 * @param status Output param set to success/failure code on exit, 515 * which must not indicate a failure before the function call. 516 * @return a StringEnumeration with the redundant pattern. 517 * The caller must delete the object. 518 * @internal ICU 3.8 519 */ 520 U_I18N_API StringEnumeration* getRedundants(UErrorCode& status); 521 #endif /* U_HIDE_INTERNAL_API */ 522 523 /** 524 * The decimal value is used in formatting fractions of seconds. If the 525 * skeleton contains fractional seconds, then this is used with the 526 * fractional seconds. For example, suppose that the input pattern is 527 * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and 528 * the decimal string is ",". Then the resulting pattern is modified to be 529 * "H:mm:ss,SSSS" 530 * 531 * @param decimal 532 * @stable ICU 3.8 533 */ 534 U_I18N_API void setDecimal(const UnicodeString& decimal); 535 536 /** 537 * Getter corresponding to setDecimal. 538 * @return UnicodeString corresponding to the decimal point 539 * @stable ICU 3.8 540 */ 541 U_I18N_API const UnicodeString& getDecimal() const; 542 543 #if !UCONFIG_NO_FORMATTING 544 545 /** 546 * Get the default hour cycle for a locale. Uses the locale that the 547 * DateTimePatternGenerator was initially created with. 548 * 549 * Cannot be used on an empty DateTimePatternGenerator instance. 550 * 551 * @param status Output param set to success/failure code on exit, which 552 * which must not indicate a failure before the function call. 553 * Set to U_UNSUPPORTED_ERROR if used on an empty instance. 554 * @return the default hour cycle. 555 * @stable ICU 67 556 */ 557 U_I18N_API UDateFormatHourCycle getDefaultHourCycle(UErrorCode& status) const; 558 559 #endif /* #if !UCONFIG_NO_FORMATTING */ 560 561 /** 562 * ICU "poor man's RTTI", returns a UClassID for the actual class. 563 * 564 * @stable ICU 3.8 565 */ 566 U_I18N_API virtual UClassID getDynamicClassID() const override; 567 568 /** 569 * ICU "poor man's RTTI", returns a UClassID for this class. 570 * 571 * @stable ICU 3.8 572 */ 573 U_I18N_API static UClassID getStaticClassID(); 574 575 private: 576 /** 577 * Constructor. 578 */ 579 DateTimePatternGenerator(UErrorCode & status); 580 581 /** 582 * Constructor. 583 */ 584 DateTimePatternGenerator(const Locale& locale, UErrorCode & status, UBool skipStdPatterns = false); 585 586 /** 587 * Copy constructor. 588 * @param other DateTimePatternGenerator to copy 589 */ 590 DateTimePatternGenerator(const DateTimePatternGenerator& other); 591 592 /** 593 * Default assignment operator. 594 * @param other DateTimePatternGenerator to copy 595 */ 596 DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other); 597 598 static const int32_t UDATPG_WIDTH_COUNT = UDATPG_NARROW + 1; 599 600 Locale pLocale; // pattern locale 601 FormatParser *fp; 602 DateTimeMatcher* dtMatcher; 603 DistanceInfo *distanceInfo; 604 PatternMap *patternMap; 605 UnicodeString appendItemFormats[UDATPG_FIELD_COUNT]; 606 UnicodeString fieldDisplayNames[UDATPG_FIELD_COUNT][UDATPG_WIDTH_COUNT]; 607 UnicodeString dateTimeFormat[4]; 608 UnicodeString decimal; 609 DateTimeMatcher *skipMatcher; 610 Hashtable *fAvailableFormatKeyHash; 611 UnicodeString emptyString; 612 char16_t fDefaultHourFormatChar; 613 614 int32_t fAllowedHourFormats[7]; // Actually an array of AllowedHourFormat enum type, ending with UNKNOWN. 615 616 // Internal error code used for recording/reporting errors that occur during methods that do not 617 // have a UErrorCode parameter. For example: the Copy Constructor, or the ::clone() method. 618 // When this is set to an error the object is in an invalid state. 619 UErrorCode internalErrorCode; 620 621 /* internal flags masks for adjustFieldTypes etc. */ 622 enum { 623 kDTPGNoFlags = 0, 624 kDTPGFixFractionalSeconds = 1, 625 kDTPGSkeletonUsesCapJ = 2 626 // with #13183, no longer need flags for b, B 627 }; 628 629 void initData(const Locale &locale, UErrorCode &status, UBool skipStdPatterns = false); 630 void addCanonicalItems(UErrorCode &status); 631 void addICUPatterns(const Locale& locale, UErrorCode& status); 632 void hackTimes(const UnicodeString& hackPattern, UErrorCode& status); 633 void getCalendarTypeToUse(const Locale& locale, CharString& destination, UErrorCode& err); 634 void consumeShortTimePattern(const UnicodeString& shortTimePattern, UErrorCode& status); 635 void addCLDRData(const Locale& locale, UErrorCode& status); 636 UDateTimePatternConflict addPatternWithOptionalSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status); 637 void initHashtable(UErrorCode& status); 638 void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status); 639 void setDecimalSymbols(const Locale& locale, UErrorCode& status); 640 UDateTimePatternField getAppendFormatNumber(const char* field) const; 641 // Note for the next 3: UDateTimePGDisplayWidth is now stable ICU 61 642 UDateTimePatternField getFieldAndWidthIndices(const char* key, UDateTimePGDisplayWidth* widthP) const; 643 void setFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width, const UnicodeString& value); 644 UnicodeString& getMutableFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width); 645 void getAppendName(UDateTimePatternField field, UnicodeString& value); 646 UnicodeString mapSkeletonMetacharacters(const UnicodeString& patternForm, int32_t* flags, UErrorCode& status); 647 const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, UErrorCode& status, const PtnSkeleton** specifiedSkeletonPtr = nullptr); 648 UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS); 649 UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UErrorCode& status, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS); 650 int32_t getTopBitNumber(int32_t foundMask) const; 651 void setAvailableFormat(const UnicodeString &key, UErrorCode& status); 652 UBool isAvailableFormatSet(const UnicodeString &key) const; 653 void copyHashtable(Hashtable *other, UErrorCode &status); 654 UBool isCanonicalItem(const UnicodeString& item) const; 655 static void U_CALLCONV loadAllowedHourFormatsData(UErrorCode &status); 656 void getAllowedHourFormats(const Locale &locale, UErrorCode &status); 657 658 struct U_HIDDEN AppendItemFormatsSink; 659 struct U_HIDDEN AppendItemNamesSink; 660 struct U_HIDDEN AvailableFormatsSink; 661 } ;// end class DateTimePatternGenerator 662 663 U_NAMESPACE_END 664 665 #endif /* U_SHOW_CPLUSPLUS_API */ 666 667 #endif