udatpg.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. /*
  2. *******************************************************************************
  3. *
  4. * Copyright (C) 2007-2015, International Business Machines
  5. * Corporation and others. All Rights Reserved.
  6. *
  7. *******************************************************************************
  8. * file name: udatpg.h
  9. * encoding: US-ASCII
  10. * tab size: 8 (not used)
  11. * indentation:4
  12. *
  13. * created on: 2007jul30
  14. * created by: Markus W. Scherer
  15. */
  16. #ifndef __UDATPG_H__
  17. #define __UDATPG_H__
  18. #include "unicode/utypes.h"
  19. #include "unicode/uenum.h"
  20. #include "unicode/localpointer.h"
  21. /**
  22. * \file
  23. * \brief C API: Wrapper for icu::DateTimePatternGenerator (unicode/dtptngen.h).
  24. *
  25. * UDateTimePatternGenerator provides flexible generation of date format patterns,
  26. * like "yy-MM-dd". The user can build up the generator by adding successive
  27. * patterns. Once that is done, a query can be made using a "skeleton", which is
  28. * a pattern which just includes the desired fields and lengths. The generator
  29. * will return the "best fit" pattern corresponding to that skeleton.
  30. * <p>The main method people will use is udatpg_getBestPattern, since normally
  31. * UDateTimePatternGenerator is pre-built with data from a particular locale.
  32. * However, generators can be built directly from other data as well.
  33. * <p><i>Issue: may be useful to also have a function that returns the list of
  34. * fields in a pattern, in order, since we have that internally.
  35. * That would be useful for getting the UI order of field elements.</i>
  36. */
  37. /**
  38. * Opaque type for a date/time pattern generator object.
  39. * @stable ICU 3.8
  40. */
  41. typedef void *UDateTimePatternGenerator;
  42. /**
  43. * Field number constants for udatpg_getAppendItemFormats() and similar functions.
  44. * These constants are separate from UDateFormatField despite semantic overlap
  45. * because some fields are merged for the date/time pattern generator.
  46. * @stable ICU 3.8
  47. */
  48. typedef enum UDateTimePatternField {
  49. /** @stable ICU 3.8 */
  50. UDATPG_ERA_FIELD,
  51. /** @stable ICU 3.8 */
  52. UDATPG_YEAR_FIELD,
  53. /** @stable ICU 3.8 */
  54. UDATPG_QUARTER_FIELD,
  55. /** @stable ICU 3.8 */
  56. UDATPG_MONTH_FIELD,
  57. /** @stable ICU 3.8 */
  58. UDATPG_WEEK_OF_YEAR_FIELD,
  59. /** @stable ICU 3.8 */
  60. UDATPG_WEEK_OF_MONTH_FIELD,
  61. /** @stable ICU 3.8 */
  62. UDATPG_WEEKDAY_FIELD,
  63. /** @stable ICU 3.8 */
  64. UDATPG_DAY_OF_YEAR_FIELD,
  65. /** @stable ICU 3.8 */
  66. UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD,
  67. /** @stable ICU 3.8 */
  68. UDATPG_DAY_FIELD,
  69. /** @stable ICU 3.8 */
  70. UDATPG_DAYPERIOD_FIELD,
  71. /** @stable ICU 3.8 */
  72. UDATPG_HOUR_FIELD,
  73. /** @stable ICU 3.8 */
  74. UDATPG_MINUTE_FIELD,
  75. /** @stable ICU 3.8 */
  76. UDATPG_SECOND_FIELD,
  77. /** @stable ICU 3.8 */
  78. UDATPG_FRACTIONAL_SECOND_FIELD,
  79. /** @stable ICU 3.8 */
  80. UDATPG_ZONE_FIELD,
  81. /** @stable ICU 3.8 */
  82. UDATPG_FIELD_COUNT
  83. } UDateTimePatternField;
  84. /**
  85. * Masks to control forcing the length of specified fields in the returned
  86. * pattern to match those in the skeleton (when this would not happen
  87. * otherwise). These may be combined to force the length of multiple fields.
  88. * Used with udatpg_getBestPatternWithOptions, udatpg_replaceFieldTypesWithOptions.
  89. * @stable ICU 4.4
  90. */
  91. typedef enum UDateTimePatternMatchOptions {
  92. /** @stable ICU 4.4 */
  93. UDATPG_MATCH_NO_OPTIONS = 0,
  94. /** @stable ICU 4.4 */
  95. UDATPG_MATCH_HOUR_FIELD_LENGTH = 1 << UDATPG_HOUR_FIELD,
  96. #ifndef U_HIDE_INTERNAL_API
  97. /** @internal ICU 4.4 */
  98. UDATPG_MATCH_MINUTE_FIELD_LENGTH = 1 << UDATPG_MINUTE_FIELD,
  99. /** @internal ICU 4.4 */
  100. UDATPG_MATCH_SECOND_FIELD_LENGTH = 1 << UDATPG_SECOND_FIELD,
  101. #endif /* U_HIDE_INTERNAL_API */
  102. /** @stable ICU 4.4 */
  103. UDATPG_MATCH_ALL_FIELDS_LENGTH = (1 << UDATPG_FIELD_COUNT) - 1
  104. } UDateTimePatternMatchOptions;
  105. /**
  106. * Status return values from udatpg_addPattern().
  107. * @stable ICU 3.8
  108. */
  109. typedef enum UDateTimePatternConflict {
  110. /** @stable ICU 3.8 */
  111. UDATPG_NO_CONFLICT,
  112. /** @stable ICU 3.8 */
  113. UDATPG_BASE_CONFLICT,
  114. /** @stable ICU 3.8 */
  115. UDATPG_CONFLICT,
  116. /** @stable ICU 3.8 */
  117. UDATPG_CONFLICT_COUNT
  118. } UDateTimePatternConflict;
  119. /**
  120. * Open a generator according to a given locale.
  121. * @param locale
  122. * @param pErrorCode a pointer to the UErrorCode which must not indicate a
  123. * failure before the function call.
  124. * @return a pointer to UDateTimePatternGenerator.
  125. * @stable ICU 3.8
  126. */
  127. U_STABLE UDateTimePatternGenerator * U_EXPORT2
  128. udatpg_open(const char *locale, UErrorCode *pErrorCode);
  129. /**
  130. * Open an empty generator, to be constructed with udatpg_addPattern(...) etc.
  131. * @param pErrorCode a pointer to the UErrorCode which must not indicate a
  132. * failure before the function call.
  133. * @return a pointer to UDateTimePatternGenerator.
  134. * @stable ICU 3.8
  135. */
  136. U_STABLE UDateTimePatternGenerator * U_EXPORT2
  137. udatpg_openEmpty(UErrorCode *pErrorCode);
  138. /**
  139. * Close a generator.
  140. * @param dtpg a pointer to UDateTimePatternGenerator.
  141. * @stable ICU 3.8
  142. */
  143. U_STABLE void U_EXPORT2
  144. udatpg_close(UDateTimePatternGenerator *dtpg);
  145. #if U_SHOW_CPLUSPLUS_API
  146. U_NAMESPACE_BEGIN
  147. /**
  148. * \class LocalUDateTimePatternGeneratorPointer
  149. * "Smart pointer" class, closes a UDateTimePatternGenerator via udatpg_close().
  150. * For most methods see the LocalPointerBase base class.
  151. *
  152. * @see LocalPointerBase
  153. * @see LocalPointer
  154. * @stable ICU 4.4
  155. */
  156. U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateTimePatternGeneratorPointer, UDateTimePatternGenerator, udatpg_close);
  157. U_NAMESPACE_END
  158. #endif
  159. /**
  160. * Create a copy pf a generator.
  161. * @param dtpg a pointer to UDateTimePatternGenerator to be copied.
  162. * @param pErrorCode a pointer to the UErrorCode which must not indicate a
  163. * failure before the function call.
  164. * @return a pointer to a new UDateTimePatternGenerator.
  165. * @stable ICU 3.8
  166. */
  167. U_STABLE UDateTimePatternGenerator * U_EXPORT2
  168. udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
  169. /**
  170. * Get the best pattern matching the input skeleton. It is guaranteed to
  171. * have all of the fields in the skeleton.
  172. *
  173. * Note that this function uses a non-const UDateTimePatternGenerator:
  174. * It uses a stateful pattern parser which is set up for each generator object,
  175. * rather than creating one for each function call.
  176. * Consecutive calls to this function do not affect each other,
  177. * but this function cannot be used concurrently on a single generator object.
  178. *
  179. * @param dtpg a pointer to UDateTimePatternGenerator.
  180. * @param skeleton
  181. * The skeleton is a pattern containing only the variable fields.
  182. * For example, "MMMdd" and "mmhh" are skeletons.
  183. * @param length the length of skeleton
  184. * @param bestPattern
  185. * The best pattern found from the given skeleton.
  186. * @param capacity the capacity of bestPattern.
  187. * @param pErrorCode a pointer to the UErrorCode which must not indicate a
  188. * failure before the function call.
  189. * @return the length of bestPattern.
  190. * @stable ICU 3.8
  191. */
  192. U_STABLE int32_t U_EXPORT2
  193. udatpg_getBestPattern(UDateTimePatternGenerator *dtpg,
  194. const UChar *skeleton, int32_t length,
  195. UChar *bestPattern, int32_t capacity,
  196. UErrorCode *pErrorCode);
  197. /**
  198. * Get the best pattern matching the input skeleton. It is guaranteed to
  199. * have all of the fields in the skeleton.
  200. *
  201. * Note that this function uses a non-const UDateTimePatternGenerator:
  202. * It uses a stateful pattern parser which is set up for each generator object,
  203. * rather than creating one for each function call.
  204. * Consecutive calls to this function do not affect each other,
  205. * but this function cannot be used concurrently on a single generator object.
  206. *
  207. * @param dtpg a pointer to UDateTimePatternGenerator.
  208. * @param skeleton
  209. * The skeleton is a pattern containing only the variable fields.
  210. * For example, "MMMdd" and "mmhh" are skeletons.
  211. * @param length the length of skeleton
  212. * @param options
  213. * Options for forcing the length of specified fields in the
  214. * returned pattern to match those in the skeleton (when this
  215. * would not happen otherwise). For default behavior, use
  216. * UDATPG_MATCH_NO_OPTIONS.
  217. * @param bestPattern
  218. * The best pattern found from the given skeleton.
  219. * @param capacity
  220. * the capacity of bestPattern.
  221. * @param pErrorCode
  222. * a pointer to the UErrorCode which must not indicate a
  223. * failure before the function call.
  224. * @return the length of bestPattern.
  225. * @stable ICU 4.4
  226. */
  227. U_STABLE int32_t U_EXPORT2
  228. udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg,
  229. const UChar *skeleton, int32_t length,
  230. UDateTimePatternMatchOptions options,
  231. UChar *bestPattern, int32_t capacity,
  232. UErrorCode *pErrorCode);
  233. /**
  234. * Get a unique skeleton from a given pattern. For example,
  235. * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd".
  236. *
  237. * Note that this function uses a non-const UDateTimePatternGenerator:
  238. * It uses a stateful pattern parser which is set up for each generator object,
  239. * rather than creating one for each function call.
  240. * Consecutive calls to this function do not affect each other,
  241. * but this function cannot be used concurrently on a single generator object.
  242. *
  243. * @param dtpg a pointer to UDateTimePatternGenerator.
  244. * @param pattern input pattern, such as "dd/MMM".
  245. * @param length the length of pattern.
  246. * @param skeleton such as "MMMdd"
  247. * @param capacity the capacity of skeleton.
  248. * @param pErrorCode a pointer to the UErrorCode which must not indicate a
  249. * failure before the function call.
  250. * @return the length of skeleton.
  251. * @stable ICU 3.8
  252. */
  253. U_STABLE int32_t U_EXPORT2
  254. udatpg_getSkeleton(UDateTimePatternGenerator *dtpg,
  255. const UChar *pattern, int32_t length,
  256. UChar *skeleton, int32_t capacity,
  257. UErrorCode *pErrorCode);
  258. /**
  259. * Get a unique base skeleton from a given pattern. This is the same
  260. * as the skeleton, except that differences in length are minimized so
  261. * as to only preserve the difference between string and numeric form. So
  262. * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd"
  263. * (notice the single d).
  264. *
  265. * Note that this function uses a non-const UDateTimePatternGenerator:
  266. * It uses a stateful pattern parser which is set up for each generator object,
  267. * rather than creating one for each function call.
  268. * Consecutive calls to this function do not affect each other,
  269. * but this function cannot be used concurrently on a single generator object.
  270. *
  271. * @param dtpg a pointer to UDateTimePatternGenerator.
  272. * @param pattern input pattern, such as "dd/MMM".
  273. * @param length the length of pattern.
  274. * @param baseSkeleton such as "Md"
  275. * @param capacity the capacity of base skeleton.
  276. * @param pErrorCode a pointer to the UErrorCode which must not indicate a
  277. * failure before the function call.
  278. * @return the length of baseSkeleton.
  279. * @stable ICU 3.8
  280. */
  281. U_STABLE int32_t U_EXPORT2
  282. udatpg_getBaseSkeleton(UDateTimePatternGenerator *dtpg,
  283. const UChar *pattern, int32_t length,
  284. UChar *baseSkeleton, int32_t capacity,
  285. UErrorCode *pErrorCode);
  286. /**
  287. * Adds a pattern to the generator. If the pattern has the same skeleton as
  288. * an existing pattern, and the override parameter is set, then the previous
  289. * value is overriden. Otherwise, the previous value is retained. In either
  290. * case, the conflicting status is set and previous vale is stored in
  291. * conflicting pattern.
  292. * <p>
  293. * Note that single-field patterns (like "MMM") are automatically added, and
  294. * don't need to be added explicitly!
  295. *
  296. * @param dtpg a pointer to UDateTimePatternGenerator.
  297. * @param pattern input pattern, such as "dd/MMM"
  298. * @param patternLength the length of pattern.
  299. * @param override When existing values are to be overridden use true,
  300. * otherwise use false.
  301. * @param conflictingPattern Previous pattern with the same skeleton.
  302. * @param capacity the capacity of conflictingPattern.
  303. * @param pLength a pointer to the length of conflictingPattern.
  304. * @param pErrorCode a pointer to the UErrorCode which must not indicate a
  305. * failure before the function call.
  306. * @return conflicting status. The value could be UDATPG_NO_CONFLICT,
  307. * UDATPG_BASE_CONFLICT or UDATPG_CONFLICT.
  308. * @stable ICU 3.8
  309. */
  310. U_STABLE UDateTimePatternConflict U_EXPORT2
  311. udatpg_addPattern(UDateTimePatternGenerator *dtpg,
  312. const UChar *pattern, int32_t patternLength,
  313. UBool override,
  314. UChar *conflictingPattern, int32_t capacity, int32_t *pLength,
  315. UErrorCode *pErrorCode);
  316. /**
  317. * An AppendItem format is a pattern used to append a field if there is no
  318. * good match. For example, suppose that the input skeleton is "GyyyyMMMd",
  319. * and there is no matching pattern internally, but there is a pattern
  320. * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the
  321. * G. The way these two are conjoined is by using the AppendItemFormat for G
  322. * (era). So if that value is, say "{0}, {1}" then the final resulting
  323. * pattern is "d-MM-yyyy, G".
  324. * <p>
  325. * There are actually three available variables: {0} is the pattern so far,
  326. * {1} is the element we are adding, and {2} is the name of the element.
  327. * <p>
  328. * This reflects the way that the CLDR data is organized.
  329. *
  330. * @param dtpg a pointer to UDateTimePatternGenerator.
  331. * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD
  332. * @param value pattern, such as "{0}, {1}"
  333. * @param length the length of value.
  334. * @stable ICU 3.8
  335. */
  336. U_STABLE void U_EXPORT2
  337. udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg,
  338. UDateTimePatternField field,
  339. const UChar *value, int32_t length);
  340. /**
  341. * Getter corresponding to setAppendItemFormat. Values below 0 or at or
  342. * above UDATPG_FIELD_COUNT are illegal arguments.
  343. *
  344. * @param dtpg A pointer to UDateTimePatternGenerator.
  345. * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD
  346. * @param pLength A pointer that will receive the length of appendItemFormat.
  347. * @return appendItemFormat for field.
  348. * @stable ICU 3.8
  349. */
  350. U_STABLE const UChar * U_EXPORT2
  351. udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg,
  352. UDateTimePatternField field,
  353. int32_t *pLength);
  354. /**
  355. * Set the name of field, eg "era" in English for ERA. These are only
  356. * used if the corresponding AppendItemFormat is used, and if it contains a
  357. * {2} variable.
  358. * <p>
  359. * This reflects the way that the CLDR data is organized.
  360. *
  361. * @param dtpg a pointer to UDateTimePatternGenerator.
  362. * @param field UDateTimePatternField
  363. * @param value name for the field.
  364. * @param length the length of value.
  365. * @stable ICU 3.8
  366. */
  367. U_STABLE void U_EXPORT2
  368. udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg,
  369. UDateTimePatternField field,
  370. const UChar *value, int32_t length);
  371. /**
  372. * Getter corresponding to setAppendItemNames. Values below 0 or at or above
  373. * UDATPG_FIELD_COUNT are illegal arguments.
  374. *
  375. * @param dtpg a pointer to UDateTimePatternGenerator.
  376. * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD
  377. * @param pLength A pointer that will receive the length of the name for field.
  378. * @return name for field
  379. * @stable ICU 3.8
  380. */
  381. U_STABLE const UChar * U_EXPORT2
  382. udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg,
  383. UDateTimePatternField field,
  384. int32_t *pLength);
  385. /**
  386. * The DateTimeFormat is a message format pattern used to compose date and
  387. * time patterns. The default pattern in the root locale is "{1} {0}", where
  388. * {1} will be replaced by the date pattern and {0} will be replaced by the
  389. * time pattern; however, other locales may specify patterns such as
  390. * "{1}, {0}" or "{1} 'at' {0}", etc.
  391. * <p>
  392. * This is used when the input skeleton contains both date and time fields,
  393. * but there is not a close match among the added patterns. For example,
  394. * suppose that this object was created by adding "dd-MMM" and "hh:mm", and
  395. * its DateTimeFormat is the default "{1} {0}". Then if the input skeleton
  396. * is "MMMdhmm", there is not an exact match, so the input skeleton is
  397. * broken up into two components "MMMd" and "hmm". There are close matches
  398. * for those two skeletons, so the result is put together with this pattern,
  399. * resulting in "d-MMM h:mm".
  400. *
  401. * @param dtpg a pointer to UDateTimePatternGenerator.
  402. * @param dtFormat
  403. * message format pattern, here {1} will be replaced by the date
  404. * pattern and {0} will be replaced by the time pattern.
  405. * @param length the length of dtFormat.
  406. * @stable ICU 3.8
  407. */
  408. U_STABLE void U_EXPORT2
  409. udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg,
  410. const UChar *dtFormat, int32_t length);
  411. /**
  412. * Getter corresponding to setDateTimeFormat.
  413. * @param dtpg a pointer to UDateTimePatternGenerator.
  414. * @param pLength A pointer that will receive the length of the format
  415. * @return dateTimeFormat.
  416. * @stable ICU 3.8
  417. */
  418. U_STABLE const UChar * U_EXPORT2
  419. udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg,
  420. int32_t *pLength);
  421. /**
  422. * The decimal value is used in formatting fractions of seconds. If the
  423. * skeleton contains fractional seconds, then this is used with the
  424. * fractional seconds. For example, suppose that the input pattern is
  425. * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and
  426. * the decimal string is ",". Then the resulting pattern is modified to be
  427. * "H:mm:ss,SSSS"
  428. *
  429. * @param dtpg a pointer to UDateTimePatternGenerator.
  430. * @param decimal
  431. * @param length the length of decimal.
  432. * @stable ICU 3.8
  433. */
  434. U_STABLE void U_EXPORT2
  435. udatpg_setDecimal(UDateTimePatternGenerator *dtpg,
  436. const UChar *decimal, int32_t length);
  437. /**
  438. * Getter corresponding to setDecimal.
  439. *
  440. * @param dtpg a pointer to UDateTimePatternGenerator.
  441. * @param pLength A pointer that will receive the length of the decimal string.
  442. * @return corresponding to the decimal point.
  443. * @stable ICU 3.8
  444. */
  445. U_STABLE const UChar * U_EXPORT2
  446. udatpg_getDecimal(const UDateTimePatternGenerator *dtpg,
  447. int32_t *pLength);
  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. * Note that this function uses a non-const UDateTimePatternGenerator:
  456. * It uses a stateful pattern parser which is set up for each generator object,
  457. * rather than creating one for each function call.
  458. * Consecutive calls to this function do not affect each other,
  459. * but this function cannot be used concurrently on a single generator object.
  460. *
  461. * @param dtpg a pointer to UDateTimePatternGenerator.
  462. * @param pattern Input pattern
  463. * @param patternLength the length of input pattern.
  464. * @param skeleton
  465. * @param skeletonLength the length of input skeleton.
  466. * @param dest pattern adjusted to match the skeleton fields widths and subtypes.
  467. * @param destCapacity the capacity of dest.
  468. * @param pErrorCode a pointer to the UErrorCode which must not indicate a
  469. * failure before the function call.
  470. * @return the length of dest.
  471. * @stable ICU 3.8
  472. */
  473. U_STABLE int32_t U_EXPORT2
  474. udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg,
  475. const UChar *pattern, int32_t patternLength,
  476. const UChar *skeleton, int32_t skeletonLength,
  477. UChar *dest, int32_t destCapacity,
  478. UErrorCode *pErrorCode);
  479. /**
  480. * Adjusts the field types (width and subtype) of a pattern to match what is
  481. * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a
  482. * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be
  483. * "dd-MMMM hh:mm". This is used internally to get the best match for the
  484. * input skeleton, but can also be used externally.
  485. *
  486. * Note that this function uses a non-const UDateTimePatternGenerator:
  487. * It uses a stateful pattern parser which is set up for each generator object,
  488. * rather than creating one for each function call.
  489. * Consecutive calls to this function do not affect each other,
  490. * but this function cannot be used concurrently on a single generator object.
  491. *
  492. * @param dtpg a pointer to UDateTimePatternGenerator.
  493. * @param pattern Input pattern
  494. * @param patternLength the length of input pattern.
  495. * @param skeleton
  496. * @param skeletonLength the length of input skeleton.
  497. * @param options
  498. * Options controlling whether the length of specified fields in the
  499. * pattern are adjusted to match those in the skeleton (when this
  500. * would not happen otherwise). For default behavior, use
  501. * UDATPG_MATCH_NO_OPTIONS.
  502. * @param dest pattern adjusted to match the skeleton fields widths and subtypes.
  503. * @param destCapacity the capacity of dest.
  504. * @param pErrorCode a pointer to the UErrorCode which must not indicate a
  505. * failure before the function call.
  506. * @return the length of dest.
  507. * @stable ICU 4.4
  508. */
  509. U_STABLE int32_t U_EXPORT2
  510. udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg,
  511. const UChar *pattern, int32_t patternLength,
  512. const UChar *skeleton, int32_t skeletonLength,
  513. UDateTimePatternMatchOptions options,
  514. UChar *dest, int32_t destCapacity,
  515. UErrorCode *pErrorCode);
  516. /**
  517. * Return a UEnumeration list of all the skeletons in canonical form.
  518. * Call udatpg_getPatternForSkeleton() to get the corresponding pattern.
  519. *
  520. * @param dtpg a pointer to UDateTimePatternGenerator.
  521. * @param pErrorCode a pointer to the UErrorCode which must not indicate a
  522. * failure before the function call
  523. * @return a UEnumeration list of all the skeletons
  524. * The caller must close the object.
  525. * @stable ICU 3.8
  526. */
  527. U_STABLE UEnumeration * U_EXPORT2
  528. udatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
  529. /**
  530. * Return a UEnumeration list of all the base skeletons in canonical form.
  531. *
  532. * @param dtpg a pointer to UDateTimePatternGenerator.
  533. * @param pErrorCode a pointer to the UErrorCode which must not indicate a
  534. * failure before the function call.
  535. * @return a UEnumeration list of all the base skeletons
  536. * The caller must close the object.
  537. * @stable ICU 3.8
  538. */
  539. U_STABLE UEnumeration * U_EXPORT2
  540. udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
  541. /**
  542. * Get the pattern corresponding to a given skeleton.
  543. *
  544. * @param dtpg a pointer to UDateTimePatternGenerator.
  545. * @param skeleton
  546. * @param skeletonLength pointer to the length of skeleton.
  547. * @param pLength pointer to the length of return pattern.
  548. * @return pattern corresponding to a given skeleton.
  549. * @stable ICU 3.8
  550. */
  551. U_STABLE const UChar * U_EXPORT2
  552. udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg,
  553. const UChar *skeleton, int32_t skeletonLength,
  554. int32_t *pLength);
  555. #endif