dtptngen.h 26 KB

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