|
||||
Warning, file /include/unicode/dtptngen.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // © 2016 and later: Unicode, Inc. and others. 0002 // License & terms of use: http://www.unicode.org/copyright.html 0003 /* 0004 ******************************************************************************* 0005 * Copyright (C) 2007-2016, International Business Machines Corporation and 0006 * others. All Rights Reserved. 0007 ******************************************************************************* 0008 * 0009 * File DTPTNGEN.H 0010 * 0011 ******************************************************************************* 0012 */ 0013 0014 #ifndef __DTPTNGEN_H__ 0015 #define __DTPTNGEN_H__ 0016 0017 #include "unicode/utypes.h" 0018 0019 #if U_SHOW_CPLUSPLUS_API 0020 0021 #include "unicode/datefmt.h" 0022 #include "unicode/locid.h" 0023 #include "unicode/udat.h" 0024 #include "unicode/udatpg.h" 0025 #include "unicode/unistr.h" 0026 0027 U_NAMESPACE_BEGIN 0028 0029 /** 0030 * \file 0031 * \brief C++ API: Date/Time Pattern Generator 0032 */ 0033 0034 0035 class CharString; 0036 class Hashtable; 0037 class FormatParser; 0038 class DateTimeMatcher; 0039 class DistanceInfo; 0040 class PatternMap; 0041 class PtnSkeleton; 0042 class SharedDateTimePatternGenerator; 0043 0044 /** 0045 * This class provides flexible generation of date format patterns, like "yy-MM-dd". 0046 * The user can build up the generator by adding successive patterns. Once that 0047 * is done, a query can be made using a "skeleton", which is a pattern which just 0048 * includes the desired fields and lengths. The generator will return the "best fit" 0049 * pattern corresponding to that skeleton. 0050 * <p>The main method people will use is getBestPattern(String skeleton), 0051 * since normally this class is pre-built with data from a particular locale. 0052 * However, generators can be built directly from other data as well. 0053 * <p><i>Issue: may be useful to also have a function that returns the list of 0054 * fields in a pattern, in order, since we have that internally. 0055 * That would be useful for getting the UI order of field elements.</i> 0056 * @stable ICU 3.8 0057 **/ 0058 class U_I18N_API DateTimePatternGenerator : public UObject { 0059 public: 0060 /** 0061 * Construct a flexible generator according to default locale. 0062 * @param status Output param set to success/failure code on exit, 0063 * which must not indicate a failure before the function call. 0064 * @stable ICU 3.8 0065 */ 0066 static DateTimePatternGenerator* U_EXPORT2 createInstance(UErrorCode& status); 0067 0068 /** 0069 * Construct a flexible generator according to data for a given locale. 0070 * @param uLocale 0071 * @param status Output param set to success/failure code on exit, 0072 * which must not indicate a failure before the function call. 0073 * @stable ICU 3.8 0074 */ 0075 static DateTimePatternGenerator* U_EXPORT2 createInstance(const Locale& uLocale, UErrorCode& status); 0076 0077 #ifndef U_HIDE_INTERNAL_API 0078 0079 /** 0080 * For ICU use only. Skips loading the standard date/time patterns (which is done via DateFormat). 0081 * 0082 * @internal 0083 */ 0084 static DateTimePatternGenerator* U_EXPORT2 createInstanceNoStdPat(const Locale& uLocale, UErrorCode& status); 0085 0086 #endif /* U_HIDE_INTERNAL_API */ 0087 0088 /** 0089 * Create an empty generator, to be constructed with addPattern(...) etc. 0090 * @param status Output param set to success/failure code on exit, 0091 * which must not indicate a failure before the function call. 0092 * @stable ICU 3.8 0093 */ 0094 static DateTimePatternGenerator* U_EXPORT2 createEmptyInstance(UErrorCode& status); 0095 0096 /** 0097 * Destructor. 0098 * @stable ICU 3.8 0099 */ 0100 virtual ~DateTimePatternGenerator(); 0101 0102 /** 0103 * Clone DateTimePatternGenerator object. Clients are responsible for 0104 * deleting the DateTimePatternGenerator object cloned. 0105 * @stable ICU 3.8 0106 */ 0107 DateTimePatternGenerator* clone() const; 0108 0109 /** 0110 * Return true if another object is semantically equal to this one. 0111 * 0112 * @param other the DateTimePatternGenerator object to be compared with. 0113 * @return true if other is semantically equal to this. 0114 * @stable ICU 3.8 0115 */ 0116 bool operator==(const DateTimePatternGenerator& other) const; 0117 0118 /** 0119 * Return true if another object is semantically unequal to this one. 0120 * 0121 * @param other the DateTimePatternGenerator object to be compared with. 0122 * @return true if other is semantically unequal to this. 0123 * @stable ICU 3.8 0124 */ 0125 bool operator!=(const DateTimePatternGenerator& other) const; 0126 0127 /** 0128 * Utility to return a unique skeleton from a given pattern. For example, 0129 * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". 0130 * 0131 * @param pattern Input pattern, such as "dd/MMM" 0132 * @param status Output param set to success/failure code on exit, 0133 * which must not indicate a failure before the function call. 0134 * @return skeleton such as "MMMdd" 0135 * @stable ICU 56 0136 */ 0137 static UnicodeString staticGetSkeleton(const UnicodeString& pattern, UErrorCode& status); 0138 0139 /** 0140 * Utility to return a unique skeleton from a given pattern. For example, 0141 * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". 0142 * getSkeleton() works exactly like staticGetSkeleton(). 0143 * Use staticGetSkeleton() instead of getSkeleton(). 0144 * 0145 * @param pattern Input pattern, such as "dd/MMM" 0146 * @param status Output param set to success/failure code on exit, 0147 * which must not indicate a failure before the function call. 0148 * @return skeleton such as "MMMdd" 0149 * @stable ICU 3.8 0150 */ 0151 UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status); /* { 0152 The function is commented out because it is a stable API calling a draft API. 0153 After staticGetSkeleton becomes stable, staticGetSkeleton can be used and 0154 these comments and the definition of getSkeleton in dtptngen.cpp should be removed. 0155 return staticGetSkeleton(pattern, status); 0156 }*/ 0157 0158 /** 0159 * Utility to return a unique base skeleton from a given pattern. This is 0160 * the same as the skeleton, except that differences in length are minimized 0161 * so as to only preserve the difference between string and numeric form. So 0162 * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" 0163 * (notice the single d). 0164 * 0165 * @param pattern Input pattern, such as "dd/MMM" 0166 * @param status Output param set to success/failure code on exit, 0167 * which must not indicate a failure before the function call. 0168 * @return base skeleton, such as "MMMd" 0169 * @stable ICU 56 0170 */ 0171 static UnicodeString staticGetBaseSkeleton(const UnicodeString& pattern, UErrorCode& status); 0172 0173 /** 0174 * Utility to return a unique base skeleton from a given pattern. This is 0175 * the same as the skeleton, except that differences in length are minimized 0176 * so as to only preserve the difference between string and numeric form. So 0177 * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" 0178 * (notice the single d). 0179 * getBaseSkeleton() works exactly like staticGetBaseSkeleton(). 0180 * Use staticGetBaseSkeleton() instead of getBaseSkeleton(). 0181 * 0182 * @param pattern Input pattern, such as "dd/MMM" 0183 * @param status Output param set to success/failure code on exit, 0184 * which must not indicate a failure before the function call. 0185 * @return base skeleton, such as "MMMd" 0186 * @stable ICU 3.8 0187 */ 0188 UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status); /* { 0189 The function is commented out because it is a stable API calling a draft API. 0190 After staticGetBaseSkeleton becomes stable, staticGetBaseSkeleton can be used and 0191 these comments and the definition of getBaseSkeleton in dtptngen.cpp should be removed. 0192 return staticGetBaseSkeleton(pattern, status); 0193 }*/ 0194 0195 /** 0196 * Adds a pattern to the generator. If the pattern has the same skeleton as 0197 * an existing pattern, and the override parameter is set, then the previous 0198 * value is overridden. Otherwise, the previous value is retained. In either 0199 * case, the conflicting status is set and previous vale is stored in 0200 * conflicting pattern. 0201 * <p> 0202 * Note that single-field patterns (like "MMM") are automatically added, and 0203 * don't need to be added explicitly! 0204 * 0205 * @param pattern Input pattern, such as "dd/MMM" 0206 * @param override When existing values are to be overridden use true, 0207 * otherwise use false. 0208 * @param conflictingPattern Previous pattern with the same skeleton. 0209 * @param status Output param set to success/failure code on exit, 0210 * which must not indicate a failure before the function call. 0211 * @return conflicting status. The value could be UDATPG_NO_CONFLICT, 0212 * UDATPG_BASE_CONFLICT or UDATPG_CONFLICT. 0213 * @stable ICU 3.8 0214 * <p> 0215 * <h4>Sample code</h4> 0216 * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1 0217 * \snippet samples/dtptngsample/dtptngsample.cpp addPatternExample 0218 * <p> 0219 */ 0220 UDateTimePatternConflict addPattern(const UnicodeString& pattern, 0221 UBool override, 0222 UnicodeString& conflictingPattern, 0223 UErrorCode& status); 0224 0225 /** 0226 * An AppendItem format is a pattern used to append a field if there is no 0227 * good match. For example, suppose that the input skeleton is "GyyyyMMMd", 0228 * and there is no matching pattern internally, but there is a pattern 0229 * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the 0230 * G. The way these two are conjoined is by using the AppendItemFormat for G 0231 * (era). So if that value is, say "{0}, {1}" then the final resulting 0232 * pattern is "d-MM-yyyy, G". 0233 * <p> 0234 * There are actually three available variables: {0} is the pattern so far, 0235 * {1} is the element we are adding, and {2} is the name of the element. 0236 * <p> 0237 * This reflects the way that the CLDR data is organized. 0238 * 0239 * @param field such as UDATPG_ERA_FIELD. 0240 * @param value pattern, such as "{0}, {1}" 0241 * @stable ICU 3.8 0242 */ 0243 void setAppendItemFormat(UDateTimePatternField field, const UnicodeString& value); 0244 0245 /** 0246 * Getter corresponding to setAppendItemFormat. Values below 0 or at or 0247 * above UDATPG_FIELD_COUNT are illegal arguments. 0248 * 0249 * @param field such as UDATPG_ERA_FIELD. 0250 * @return append pattern for field 0251 * @stable ICU 3.8 0252 */ 0253 const UnicodeString& getAppendItemFormat(UDateTimePatternField field) const; 0254 0255 /** 0256 * Sets the names of field, eg "era" in English for ERA. These are only 0257 * used if the corresponding AppendItemFormat is used, and if it contains a 0258 * {2} variable. 0259 * <p> 0260 * This reflects the way that the CLDR data is organized. 0261 * 0262 * @param field such as UDATPG_ERA_FIELD. 0263 * @param value name of the field 0264 * @stable ICU 3.8 0265 */ 0266 void setAppendItemName(UDateTimePatternField field, const UnicodeString& value); 0267 0268 /** 0269 * Getter corresponding to setAppendItemNames. Values below 0 or at or above 0270 * UDATPG_FIELD_COUNT are illegal arguments. Note: The more general method 0271 * for getting date/time field display names is getFieldDisplayName. 0272 * 0273 * @param field such as UDATPG_ERA_FIELD. 0274 * @return name for field 0275 * @see getFieldDisplayName 0276 * @stable ICU 3.8 0277 */ 0278 const UnicodeString& getAppendItemName(UDateTimePatternField field) const; 0279 0280 /** 0281 * The general interface to get a display name for a particular date/time field, 0282 * in one of several possible display widths. 0283 * 0284 * @param field The desired UDateTimePatternField, such as UDATPG_ERA_FIELD. 0285 * @param width The desired UDateTimePGDisplayWidth, such as UDATPG_ABBREVIATED. 0286 * @return The display name for field 0287 * @stable ICU 61 0288 */ 0289 UnicodeString getFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width) const; 0290 0291 /** 0292 * The DateTimeFormat is a message format pattern used to compose date and 0293 * time patterns. The default pattern in the root locale is "{1} {0}", where 0294 * {1} will be replaced by the date pattern and {0} will be replaced by the 0295 * time pattern; however, other locales may specify patterns such as 0296 * "{1}, {0}" or "{1} 'at' {0}", etc. 0297 * <p> 0298 * This is used when the input skeleton contains both date and time fields, 0299 * but there is not a close match among the added patterns. For example, 0300 * suppose that this object was created by adding "dd-MMM" and "hh:mm", and 0301 * its datetimeFormat is the default "{1} {0}". Then if the input skeleton 0302 * is "MMMdhmm", there is not an exact match, so the input skeleton is 0303 * broken up into two components "MMMd" and "hmm". There are close matches 0304 * for those two skeletons, so the result is put together with this pattern, 0305 * resulting in "d-MMM h:mm". 0306 * 0307 * There are four DateTimeFormats in a DateTimePatternGenerator object, 0308 * corresponding to date styles UDAT_FULL..UDAT_SHORT. This method sets 0309 * all of them to the specified pattern. To set them individually, see 0310 * setDateTimeFormat(UDateFormatStyle style, ...). 0311 * 0312 * @param dateTimeFormat 0313 * message format pattern, here {1} will be replaced by the date 0314 * pattern and {0} will be replaced by the time pattern. 0315 * @stable ICU 3.8 0316 */ 0317 void setDateTimeFormat(const UnicodeString& dateTimeFormat); 0318 0319 /** 0320 * Getter corresponding to setDateTimeFormat. 0321 * 0322 * There are four DateTimeFormats in a DateTimePatternGenerator object, 0323 * corresponding to date styles UDAT_FULL..UDAT_SHORT. This method gets 0324 * the style for UDAT_MEDIUM (the default). To get them individually, see 0325 * getDateTimeFormat(UDateFormatStyle style). 0326 * 0327 * @return DateTimeFormat. 0328 * @stable ICU 3.8 0329 */ 0330 const UnicodeString& getDateTimeFormat() const; 0331 0332 #if !UCONFIG_NO_FORMATTING 0333 /** 0334 * dateTimeFormats are message patterns used to compose combinations of date 0335 * and time patterns. There are four length styles, corresponding to the 0336 * inferred style of the date pattern; these are UDateFormatStyle values: 0337 * - UDAT_FULL (for date pattern with weekday and long month), else 0338 * - UDAT_LONG (for a date pattern with long month), else 0339 * - UDAT_MEDIUM (for a date pattern with abbreviated month), else 0340 * - UDAT_SHORT (for any other date pattern). 0341 * For details on dateTimeFormats, see 0342 * https://www.unicode.org/reports/tr35/tr35-dates.html#dateTimeFormats. 0343 * The default pattern in the root locale for all styles is "{1} {0}". 0344 * 0345 * @param style 0346 * one of DateFormat.FULL..DateFormat.SHORT. Error if out of range. 0347 * @param dateTimeFormat 0348 * the new dateTimeFormat to set for the the specified style 0349 * @param status 0350 * in/out parameter; if no failure status is already set, 0351 * it will be set according to result of the function (e.g. 0352 * U_ILLEGAL_ARGUMENT_ERROR for style out of range). 0353 * @stable ICU 71 0354 */ 0355 void setDateTimeFormat(UDateFormatStyle style, const UnicodeString& dateTimeFormat, 0356 UErrorCode& status); 0357 0358 /** 0359 * Getter corresponding to setDateTimeFormat. 0360 * 0361 * @param style 0362 * one of UDAT_FULL..UDAT_SHORT. Error if out of range. 0363 * @param status 0364 * in/out parameter; if no failure status is already set, 0365 * it will be set according to result of the function (e.g. 0366 * U_ILLEGAL_ARGUMENT_ERROR for style out of range). 0367 * @return 0368 * the current dateTimeFormat for the the specified style, or 0369 * empty string in case of error. The UnicodeString reference, 0370 * or the contents of the string, may no longer be valid if 0371 * setDateTimeFormat is called, or the DateTimePatternGenerator 0372 * object is deleted. 0373 * @stable ICU 71 0374 */ 0375 const UnicodeString& getDateTimeFormat(UDateFormatStyle style, 0376 UErrorCode& status) const; 0377 #endif /* #if !UCONFIG_NO_FORMATTING */ 0378 0379 /** 0380 * Return the best pattern matching the input skeleton. It is guaranteed to 0381 * have all of the fields in the skeleton. 0382 * 0383 * @param skeleton 0384 * The skeleton is a pattern containing only the variable fields. 0385 * For example, "MMMdd" and "mmhh" are skeletons. 0386 * @param status Output param set to success/failure code on exit, 0387 * which must not indicate a failure before the function call. 0388 * @return bestPattern 0389 * The best pattern found from the given skeleton. 0390 * @stable ICU 3.8 0391 * <p> 0392 * <h4>Sample code</h4> 0393 * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1 0394 * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample 0395 * <p> 0396 */ 0397 UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status); 0398 0399 0400 /** 0401 * Return the best pattern matching the input skeleton. It is guaranteed to 0402 * have all of the fields in the skeleton. 0403 * 0404 * @param skeleton 0405 * The skeleton is a pattern containing only the variable fields. 0406 * For example, "MMMdd" and "mmhh" are skeletons. 0407 * @param options 0408 * Options for forcing the length of specified fields in the 0409 * returned pattern to match those in the skeleton (when this 0410 * would not happen otherwise). For default behavior, use 0411 * UDATPG_MATCH_NO_OPTIONS. 0412 * @param status 0413 * Output param set to success/failure code on exit, 0414 * which must not indicate a failure before the function call. 0415 * @return bestPattern 0416 * The best pattern found from the given skeleton. 0417 * @stable ICU 4.4 0418 */ 0419 UnicodeString getBestPattern(const UnicodeString& skeleton, 0420 UDateTimePatternMatchOptions options, 0421 UErrorCode& status); 0422 0423 0424 /** 0425 * Adjusts the field types (width and subtype) of a pattern to match what is 0426 * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a 0427 * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be 0428 * "dd-MMMM hh:mm". This is used internally to get the best match for the 0429 * input skeleton, but can also be used externally. 0430 * 0431 * @param pattern Input pattern 0432 * @param skeleton 0433 * The skeleton is a pattern containing only the variable fields. 0434 * For example, "MMMdd" and "mmhh" are skeletons. 0435 * @param status Output param set to success/failure code on exit, 0436 * which must not indicate a failure before the function call. 0437 * @return pattern adjusted to match the skeleton fields widths and subtypes. 0438 * @stable ICU 3.8 0439 * <p> 0440 * <h4>Sample code</h4> 0441 * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1 0442 * \snippet samples/dtptngsample/dtptngsample.cpp replaceFieldTypesExample 0443 * <p> 0444 */ 0445 UnicodeString replaceFieldTypes(const UnicodeString& pattern, 0446 const UnicodeString& skeleton, 0447 UErrorCode& status); 0448 0449 /** 0450 * Adjusts the field types (width and subtype) of a pattern to match what is 0451 * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a 0452 * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be 0453 * "dd-MMMM hh:mm". This is used internally to get the best match for the 0454 * input skeleton, but can also be used externally. 0455 * 0456 * @param pattern Input pattern 0457 * @param skeleton 0458 * The skeleton is a pattern containing only the variable fields. 0459 * For example, "MMMdd" and "mmhh" are skeletons. 0460 * @param options 0461 * Options controlling whether the length of specified fields in the 0462 * pattern are adjusted to match those in the skeleton (when this 0463 * would not happen otherwise). For default behavior, use 0464 * UDATPG_MATCH_NO_OPTIONS. 0465 * @param status 0466 * Output param set to success/failure code on exit, 0467 * which must not indicate a failure before the function call. 0468 * @return pattern adjusted to match the skeleton fields widths and subtypes. 0469 * @stable ICU 4.4 0470 */ 0471 UnicodeString replaceFieldTypes(const UnicodeString& pattern, 0472 const UnicodeString& skeleton, 0473 UDateTimePatternMatchOptions options, 0474 UErrorCode& status); 0475 0476 /** 0477 * Return a list of all the skeletons (in canonical form) from this class. 0478 * 0479 * Call getPatternForSkeleton() to get the corresponding pattern. 0480 * 0481 * @param status Output param set to success/failure code on exit, 0482 * which must not indicate a failure before the function call. 0483 * @return StringEnumeration with the skeletons. 0484 * The caller must delete the object. 0485 * @stable ICU 3.8 0486 */ 0487 StringEnumeration* getSkeletons(UErrorCode& status) const; 0488 0489 /** 0490 * Get the pattern corresponding to a given skeleton. 0491 * @param skeleton 0492 * @return pattern corresponding to a given skeleton. 0493 * @stable ICU 3.8 0494 */ 0495 const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const; 0496 0497 /** 0498 * Return a list of all the base skeletons (in canonical form) from this class. 0499 * 0500 * @param status Output param set to success/failure code on exit, 0501 * which must not indicate a failure before the function call. 0502 * @return a StringEnumeration with the base skeletons. 0503 * The caller must delete the object. 0504 * @stable ICU 3.8 0505 */ 0506 StringEnumeration* getBaseSkeletons(UErrorCode& status) const; 0507 0508 #ifndef U_HIDE_INTERNAL_API 0509 /** 0510 * Return a list of redundant patterns are those which if removed, make no 0511 * difference in the resulting getBestPattern values. This method returns a 0512 * list of them, to help check the consistency of the patterns used to build 0513 * this generator. 0514 * 0515 * @param status Output param set to success/failure code on exit, 0516 * which must not indicate a failure before the function call. 0517 * @return a StringEnumeration with the redundant pattern. 0518 * The caller must delete the object. 0519 * @internal ICU 3.8 0520 */ 0521 StringEnumeration* getRedundants(UErrorCode& status); 0522 #endif /* U_HIDE_INTERNAL_API */ 0523 0524 /** 0525 * The decimal value is used in formatting fractions of seconds. If the 0526 * skeleton contains fractional seconds, then this is used with the 0527 * fractional seconds. For example, suppose that the input pattern is 0528 * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and 0529 * the decimal string is ",". Then the resulting pattern is modified to be 0530 * "H:mm:ss,SSSS" 0531 * 0532 * @param decimal 0533 * @stable ICU 3.8 0534 */ 0535 void setDecimal(const UnicodeString& decimal); 0536 0537 /** 0538 * Getter corresponding to setDecimal. 0539 * @return UnicodeString corresponding to the decimal point 0540 * @stable ICU 3.8 0541 */ 0542 const UnicodeString& getDecimal() const; 0543 0544 #if !UCONFIG_NO_FORMATTING 0545 0546 /** 0547 * Get the default hour cycle for a locale. Uses the locale that the 0548 * DateTimePatternGenerator was initially created with. 0549 * 0550 * Cannot be used on an empty DateTimePatternGenerator instance. 0551 * 0552 * @param status Output param set to success/failure code on exit, which 0553 * which must not indicate a failure before the function call. 0554 * Set to U_UNSUPPORTED_ERROR if used on an empty instance. 0555 * @return the default hour cycle. 0556 * @stable ICU 67 0557 */ 0558 UDateFormatHourCycle getDefaultHourCycle(UErrorCode& status) const; 0559 0560 #endif /* #if !UCONFIG_NO_FORMATTING */ 0561 0562 /** 0563 * ICU "poor man's RTTI", returns a UClassID for the actual class. 0564 * 0565 * @stable ICU 3.8 0566 */ 0567 virtual UClassID getDynamicClassID() const override; 0568 0569 /** 0570 * ICU "poor man's RTTI", returns a UClassID for this class. 0571 * 0572 * @stable ICU 3.8 0573 */ 0574 static UClassID U_EXPORT2 getStaticClassID(void); 0575 0576 private: 0577 /** 0578 * Constructor. 0579 */ 0580 DateTimePatternGenerator(UErrorCode & status); 0581 0582 /** 0583 * Constructor. 0584 */ 0585 DateTimePatternGenerator(const Locale& locale, UErrorCode & status, UBool skipStdPatterns = false); 0586 0587 /** 0588 * Copy constructor. 0589 * @param other DateTimePatternGenerator to copy 0590 */ 0591 DateTimePatternGenerator(const DateTimePatternGenerator& other); 0592 0593 /** 0594 * Default assignment operator. 0595 * @param other DateTimePatternGenerator to copy 0596 */ 0597 DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other); 0598 0599 static const int32_t UDATPG_WIDTH_COUNT = UDATPG_NARROW + 1; 0600 0601 Locale pLocale; // pattern locale 0602 FormatParser *fp; 0603 DateTimeMatcher* dtMatcher; 0604 DistanceInfo *distanceInfo; 0605 PatternMap *patternMap; 0606 UnicodeString appendItemFormats[UDATPG_FIELD_COUNT]; 0607 UnicodeString fieldDisplayNames[UDATPG_FIELD_COUNT][UDATPG_WIDTH_COUNT]; 0608 UnicodeString dateTimeFormat[4]; 0609 UnicodeString decimal; 0610 DateTimeMatcher *skipMatcher; 0611 Hashtable *fAvailableFormatKeyHash; 0612 UnicodeString emptyString; 0613 char16_t fDefaultHourFormatChar; 0614 0615 int32_t fAllowedHourFormats[7]; // Actually an array of AllowedHourFormat enum type, ending with UNKNOWN. 0616 0617 // Internal error code used for recording/reporting errors that occur during methods that do not 0618 // have a UErrorCode parameter. For example: the Copy Constructor, or the ::clone() method. 0619 // When this is set to an error the object is in an invalid state. 0620 UErrorCode internalErrorCode; 0621 0622 /* internal flags masks for adjustFieldTypes etc. */ 0623 enum { 0624 kDTPGNoFlags = 0, 0625 kDTPGFixFractionalSeconds = 1, 0626 kDTPGSkeletonUsesCapJ = 2 0627 // with #13183, no longer need flags for b, B 0628 }; 0629 0630 void initData(const Locale &locale, UErrorCode &status, UBool skipStdPatterns = false); 0631 void addCanonicalItems(UErrorCode &status); 0632 void addICUPatterns(const Locale& locale, UErrorCode& status); 0633 void hackTimes(const UnicodeString& hackPattern, UErrorCode& status); 0634 void getCalendarTypeToUse(const Locale& locale, CharString& destination, UErrorCode& err); 0635 void consumeShortTimePattern(const UnicodeString& shortTimePattern, UErrorCode& status); 0636 void addCLDRData(const Locale& locale, UErrorCode& status); 0637 UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status); 0638 void initHashtable(UErrorCode& status); 0639 void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status); 0640 void setDecimalSymbols(const Locale& locale, UErrorCode& status); 0641 UDateTimePatternField getAppendFormatNumber(const char* field) const; 0642 // Note for the next 3: UDateTimePGDisplayWidth is now stable ICU 61 0643 UDateTimePatternField getFieldAndWidthIndices(const char* key, UDateTimePGDisplayWidth* widthP) const; 0644 void setFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width, const UnicodeString& value); 0645 UnicodeString& getMutableFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width); 0646 void getAppendName(UDateTimePatternField field, UnicodeString& value); 0647 UnicodeString mapSkeletonMetacharacters(const UnicodeString& patternForm, int32_t* flags, UErrorCode& status); 0648 const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, UErrorCode& status, const PtnSkeleton** specifiedSkeletonPtr = 0); 0649 UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS); 0650 UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UErrorCode& status, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS); 0651 int32_t getTopBitNumber(int32_t foundMask) const; 0652 void setAvailableFormat(const UnicodeString &key, UErrorCode& status); 0653 UBool isAvailableFormatSet(const UnicodeString &key) const; 0654 void copyHashtable(Hashtable *other, UErrorCode &status); 0655 UBool isCanonicalItem(const UnicodeString& item) const; 0656 static void U_CALLCONV loadAllowedHourFormatsData(UErrorCode &status); 0657 void getAllowedHourFormats(const Locale &locale, UErrorCode &status); 0658 0659 struct U_HIDDEN AppendItemFormatsSink; 0660 struct U_HIDDEN AppendItemNamesSink; 0661 struct U_HIDDEN AvailableFormatsSink; 0662 } ;// end class DateTimePatternGenerator 0663 0664 U_NAMESPACE_END 0665 0666 #endif /* U_SHOW_CPLUSPLUS_API */ 0667 0668 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |