ICU 67.1 67.1

udatpg.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 *
6 * Copyright (C) 2007-2015, International Business Machines
7 * Corporation and others. All Rights Reserved.
8 *
9 *******************************************************************************
10 * file name: udatpg.h
11 * encoding: UTF-8
12 * tab size: 8 (not used)
13 * indentation:4
14 *
15 * created on: 2007jul30
16 * created by: Markus W. Scherer
17 */
18
19 #ifndef __UDATPG_H__
20 #define __UDATPG_H__
21
22 #include "unicode/utypes.h"
23 #include "unicode/udat.h"
24 #include "unicode/uenum.h"
25 #include "unicode/localpointer.h"
26
48 typedef void *UDateTimePatternGenerator;
49
56 typedef enum UDateTimePatternField {
58 UDATPG_ERA_FIELD,
60 UDATPG_YEAR_FIELD,
62 UDATPG_QUARTER_FIELD,
64 UDATPG_MONTH_FIELD,
66 UDATPG_WEEK_OF_YEAR_FIELD,
68 UDATPG_WEEK_OF_MONTH_FIELD,
70 UDATPG_WEEKDAY_FIELD,
72 UDATPG_DAY_OF_YEAR_FIELD,
74 UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD,
76 UDATPG_DAY_FIELD,
78 UDATPG_DAYPERIOD_FIELD,
80 UDATPG_HOUR_FIELD,
82 UDATPG_MINUTE_FIELD,
84 UDATPG_SECOND_FIELD,
86 UDATPG_FRACTIONAL_SECOND_FIELD,
88 UDATPG_ZONE_FIELD,
89
90 /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
91 * it is needed for layout of DateTimePatternGenerator object. */
92 #ifndef U_FORCE_HIDE_DEPRECATED_API
93
97 UDATPG_FIELD_COUNT
98 #endif // U_FORCE_HIDE_DEPRECATED_API
99 } UDateTimePatternField;
100
105 typedef enum UDateTimePGDisplayWidth {
107 UDATPG_WIDE,
109 UDATPG_ABBREVIATED,
111 UDATPG_NARROW
112 } UDateTimePGDisplayWidth;
113
121 typedef enum UDateTimePatternMatchOptions {
123 UDATPG_MATCH_NO_OPTIONS = 0,
125 UDATPG_MATCH_HOUR_FIELD_LENGTH = 1 << UDATPG_HOUR_FIELD,
126 #ifndef U_HIDE_INTERNAL_API
127
128 UDATPG_MATCH_MINUTE_FIELD_LENGTH = 1 << UDATPG_MINUTE_FIELD,
130 UDATPG_MATCH_SECOND_FIELD_LENGTH = 1 << UDATPG_SECOND_FIELD,
131 #endif /* U_HIDE_INTERNAL_API */
132
133 UDATPG_MATCH_ALL_FIELDS_LENGTH = (1 << UDATPG_FIELD_COUNT) - 1
134 } UDateTimePatternMatchOptions;
135
140 typedef enum UDateTimePatternConflict {
142 UDATPG_NO_CONFLICT,
144 UDATPG_BASE_CONFLICT,
146 UDATPG_CONFLICT,
147 #ifndef U_HIDE_DEPRECATED_API
148
152 UDATPG_CONFLICT_COUNT
153 #endif // U_HIDE_DEPRECATED_API
154 } UDateTimePatternConflict;
155
164 U_STABLE UDateTimePatternGenerator * U_EXPORT2
165 udatpg_open(const char *locale, UErrorCode *pErrorCode);
166
174 U_STABLE UDateTimePatternGenerator * U_EXPORT2
175 udatpg_openEmpty(UErrorCode *pErrorCode);
176
182 U_STABLE void U_EXPORT2
183 udatpg_close(UDateTimePatternGenerator *dtpg);
184
185 #if U_SHOW_CPLUSPLUS_API
186
187 U_NAMESPACE_BEGIN
188
198 U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateTimePatternGeneratorPointer, UDateTimePatternGenerator, udatpg_close);
199
200 U_NAMESPACE_END
201
202 #endif
203
212 U_STABLE UDateTimePatternGenerator * U_EXPORT2
213 udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
214
238 U_STABLE int32_t U_EXPORT2
239 udatpg_getBestPattern(UDateTimePatternGenerator *dtpg,
240 const UChar *skeleton, int32_t length,
241 UChar *bestPattern, int32_t capacity,
242 UErrorCode *pErrorCode);
243
274 U_STABLE int32_t U_EXPORT2
275 udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg,
276 const UChar *skeleton, int32_t length,
277 UDateTimePatternMatchOptions options,
278 UChar *bestPattern, int32_t capacity,
279 UErrorCode *pErrorCode);
280
302 U_STABLE int32_t U_EXPORT2
303 udatpg_getSkeleton(UDateTimePatternGenerator *unusedDtpg,
304 const UChar *pattern, int32_t length,
305 UChar *skeleton, int32_t capacity,
306 UErrorCode *pErrorCode);
307
332 U_STABLE int32_t U_EXPORT2
333 udatpg_getBaseSkeleton(UDateTimePatternGenerator *unusedDtpg,
334 const UChar *pattern, int32_t length,
335 UChar *baseSkeleton, int32_t capacity,
336 UErrorCode *pErrorCode);
337
362 U_STABLE UDateTimePatternConflict U_EXPORT2
363 udatpg_addPattern(UDateTimePatternGenerator *dtpg,
364 const UChar *pattern, int32_t patternLength,
365 UBool override,
366 UChar *conflictingPattern, int32_t capacity, int32_t *pLength,
367 UErrorCode *pErrorCode);
368
389 U_STABLE void U_EXPORT2
390 udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg,
391 UDateTimePatternField field,
392 const UChar *value, int32_t length);
393
404 U_STABLE const UChar * U_EXPORT2
405 udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg,
406 UDateTimePatternField field,
407 int32_t *pLength);
408
422 U_STABLE void U_EXPORT2
423 udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg,
424 UDateTimePatternField field,
425 const UChar *value, int32_t length);
426
439 U_STABLE const UChar * U_EXPORT2
440 udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg,
441 UDateTimePatternField field,
442 int32_t *pLength);
443
469 U_STABLE int32_t U_EXPORT2
470 udatpg_getFieldDisplayName(const UDateTimePatternGenerator *dtpg,
471 UDateTimePatternField field,
472 UDateTimePGDisplayWidth width,
473 UChar *fieldName, int32_t capacity,
474 UErrorCode *pErrorCode);
475
499 U_STABLE void U_EXPORT2
500 udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg,
501 const UChar *dtFormat, int32_t length);
502
510 U_STABLE const UChar * U_EXPORT2
511 udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg,
512 int32_t *pLength);
513
527 U_STABLE void U_EXPORT2
528 udatpg_setDecimal(UDateTimePatternGenerator *dtpg,
529 const UChar *decimal, int32_t length);
530
539 U_STABLE const UChar * U_EXPORT2
540 udatpg_getDecimal(const UDateTimePatternGenerator *dtpg,
541 int32_t *pLength);
542
568 U_STABLE int32_t U_EXPORT2
569 udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg,
570 const UChar *pattern, int32_t patternLength,
571 const UChar *skeleton, int32_t skeletonLength,
572 UChar *dest, int32_t destCapacity,
573 UErrorCode *pErrorCode);
574
605 U_STABLE int32_t U_EXPORT2
606 udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg,
607 const UChar *pattern, int32_t patternLength,
608 const UChar *skeleton, int32_t skeletonLength,
609 UDateTimePatternMatchOptions options,
610 UChar *dest, int32_t destCapacity,
611 UErrorCode *pErrorCode);
612
624 U_STABLE UEnumeration * U_EXPORT2
625 udatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
626
637 U_STABLE UEnumeration * U_EXPORT2
638 udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
639
650 U_STABLE const UChar * U_EXPORT2
651 udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg,
652 const UChar *skeleton, int32_t skeletonLength,
653 int32_t *pLength);
654
655 #if !UCONFIG_NO_FORMATTING
656
657 #ifndef U_HIDE_DRAFT_API
658
671 U_DRAFT UDateFormatHourCycle U_EXPORT2
672 udatpg_getDefaultHourCycle(const UDateTimePatternGenerator *dtpg, UErrorCode* pErrorCode);
673 #endif /* U_HIDE_DRAFT_API */
674
675 #endif /* #if !UCONFIG_NO_FORMATTING */
676
677 #endif
udatpg_getAppendItemFormat
const UChar * udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg, UDateTimePatternField field, int32_t *pLength)
Getter corresponding to setAppendItemFormat.
udatpg_getBestPatternWithOptions
int32_t udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg, const UChar *skeleton, int32_t length, UDateTimePatternMatchOptions options, UChar *bestPattern, int32_t capacity, UErrorCode *pErrorCode)
Get the best pattern matching the input skeleton.
UDATPG_MATCH_SECOND_FIELD_LENGTH
Definition: udatpg.h:130
UDATPG_HOUR_FIELD
Definition: udatpg.h:80
udatpg_getSkeleton
int32_t udatpg_getSkeleton(UDateTimePatternGenerator *unusedDtpg, const UChar *pattern, int32_t length, UChar *skeleton, int32_t capacity, UErrorCode *pErrorCode)
Get a unique skeleton from a given pattern.
UDATPG_ERA_FIELD
Definition: udatpg.h:58
UDATPG_NO_CONFLICT
Definition: udatpg.h:142
udatpg_getAppendItemName
const UChar * udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg, UDateTimePatternField field, int32_t *pLength)
Getter corresponding to setAppendItemNames.
udatpg_replaceFieldTypes
int32_t udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg, const UChar *pattern, int32_t patternLength, const UChar *skeleton, int32_t skeletonLength, UChar *dest, int32_t destCapacity, UErrorCode *pErrorCode)
Adjusts the field types (width and subtype) of a pattern to match what is in a skeleton.
UEnumeration
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition: uenum.h:43
UDATPG_MONTH_FIELD
Definition: udatpg.h:64
udatpg_setDateTimeFormat
void udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg, const UChar *dtFormat, int32_t length)
The DateTimeFormat is a message format pattern used to compose date and time patterns.
UDateFormatHourCycle
UDateFormatHourCycle
Hour Cycle.
Definition: udat.h:966
UDATPG_WEEKDAY_FIELD
Definition: udatpg.h:70
UDATPG_WIDE
Definition: udatpg.h:107
UDATPG_SECOND_FIELD
Definition: udatpg.h:84
LocalUDateTimePatternGeneratorPointer
"Smart pointer" class, closes a UDateTimePatternGenerator via udatpg_close().
UDATPG_CONFLICT
Definition: udatpg.h:146
udatpg_getBestPattern
int32_t udatpg_getBestPattern(UDateTimePatternGenerator *dtpg, const UChar *skeleton, int32_t length, UChar *bestPattern, int32_t capacity, UErrorCode *pErrorCode)
Get the best pattern matching the input skeleton.
UDATPG_MINUTE_FIELD
Definition: udatpg.h:82
UDATPG_WEEK_OF_YEAR_FIELD
Definition: udatpg.h:66
UDATPG_CONFLICT_COUNT
One more than the highest normal UDateTimePatternConflict value.
Definition: udatpg.h:152
udatpg_setAppendItemFormat
void udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg, UDateTimePatternField field, const UChar *value, int32_t length)
An AppendItem format is a pattern used to append a field if there is no good match.
UDATPG_DAYPERIOD_FIELD
Definition: udatpg.h:78
udatpg_setAppendItemName
void udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg, UDateTimePatternField field, const UChar *value, int32_t length)
Set the name of field, eg "era" in English for ERA.
udatpg_addPattern
UDateTimePatternConflict udatpg_addPattern(UDateTimePatternGenerator *dtpg, const UChar *pattern, int32_t patternLength, UBool override, UChar *conflictingPattern, int32_t capacity, int32_t *pLength, UErrorCode *pErrorCode)
Adds a pattern to the generator.
UDATPG_ABBREVIATED
Definition: udatpg.h:109
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:550
UDATPG_MATCH_MINUTE_FIELD_LENGTH
Definition: udatpg.h:128
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
udatpg_open
UDateTimePatternGenerator * udatpg_open(const char *locale, UErrorCode *pErrorCode)
Open a generator according to a given locale.
udat.h
C API: DateFormat.
udatpg_getFieldDisplayName
int32_t udatpg_getFieldDisplayName(const UDateTimePatternGenerator *dtpg, UDateTimePatternField field, UDateTimePGDisplayWidth width, UChar *fieldName, int32_t capacity, UErrorCode *pErrorCode)
The general interface to get a display name for a particular date/time field, in one of several possi...
UDATPG_DAY_OF_YEAR_FIELD
Definition: udatpg.h:72
UDATPG_MATCH_NO_OPTIONS
Definition: udatpg.h:123
UDATPG_DAY_FIELD
Definition: udatpg.h:76
UDateTimePatternConflict
UDateTimePatternConflict
Status return values from udatpg_addPattern().
Definition: udatpg.h:140
UDATPG_YEAR_FIELD
Definition: udatpg.h:60
udatpg_getBaseSkeleton
int32_t udatpg_getBaseSkeleton(UDateTimePatternGenerator *unusedDtpg, const UChar *pattern, int32_t length, UChar *baseSkeleton, int32_t capacity, UErrorCode *pErrorCode)
Get a unique base skeleton from a given pattern.
udatpg_openSkeletons
UEnumeration * udatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode)
Return a UEnumeration list of all the skeletons in canonical form.
udatpg_clone
UDateTimePatternGenerator * udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode)
Create a copy pf a generator.
UDATPG_FIELD_COUNT
One more than the highest normal UDateTimePatternField value.
Definition: udatpg.h:97
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:376
udatpg_close
void udatpg_close(UDateTimePatternGenerator *dtpg)
Close a generator.
UDATPG_WEEK_OF_MONTH_FIELD
Definition: udatpg.h:68
UDateTimePatternField
UDateTimePatternField
Field number constants for udatpg_getAppendItemFormats() and similar functions.
Definition: udatpg.h:56
UDATPG_MATCH_ALL_FIELDS_LENGTH
Definition: udatpg.h:133
UDateTimePatternGenerator
void * UDateTimePatternGenerator
Opaque type for a date/time pattern generator object.
Definition: udatpg.h:48
UDATPG_ZONE_FIELD
Definition: udatpg.h:88
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
udatpg_getDefaultHourCycle
UDateFormatHourCycle udatpg_getDefaultHourCycle(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode)
Return the default hour cycle for a locale.
UDateTimePGDisplayWidth
UDateTimePGDisplayWidth
Field display name width constants for udatpg_getFieldDisplayName().
Definition: udatpg.h:105
udatpg_openBaseSkeletons
UEnumeration * udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode)
Return a UEnumeration list of all the base skeletons in canonical form.
udatpg_openEmpty
UDateTimePatternGenerator * udatpg_openEmpty(UErrorCode *pErrorCode)
Open an empty generator, to be constructed with udatpg_addPattern(...) etc.
UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD
Definition: udatpg.h:74
UDATPG_MATCH_HOUR_FIELD_LENGTH
Definition: udatpg.h:125
uenum.h
C API: String Enumeration.
udatpg_setDecimal
void udatpg_setDecimal(UDateTimePatternGenerator *dtpg, const UChar *decimal, int32_t length)
The decimal value is used in formatting fractions of seconds.
udatpg_getDecimal
const UChar * udatpg_getDecimal(const UDateTimePatternGenerator *dtpg, int32_t *pLength)
Getter corresponding to setDecimal.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
udatpg_getDateTimeFormat
const UChar * udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg, int32_t *pLength)
Getter corresponding to setDateTimeFormat.
UDATPG_NARROW
Definition: udatpg.h:111
U_DRAFT
#define U_DRAFT
This is used to declare a function as a draft public ICU C API.
Definition: umachine.h:113
udatpg_replaceFieldTypesWithOptions
int32_t udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg, const UChar *pattern, int32_t patternLength, const UChar *skeleton, int32_t skeletonLength, UDateTimePatternMatchOptions options, UChar *dest, int32_t destCapacity, UErrorCode *pErrorCode)
Adjusts the field types (width and subtype) of a pattern to match what is in a skeleton.
UDateTimePatternMatchOptions
UDateTimePatternMatchOptions
Masks to control forcing the length of specified fields in the returned pattern to match those in the...
Definition: udatpg.h:121
UDATPG_QUARTER_FIELD
Definition: udatpg.h:62
udatpg_getPatternForSkeleton
const UChar * udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg, const UChar *skeleton, int32_t skeletonLength, int32_t *pLength)
Get the pattern corresponding to a given skeleton.
U_STABLE
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:111
UDATPG_FRACTIONAL_SECOND_FIELD
Definition: udatpg.h:86
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261
UDATPG_BASE_CONFLICT
Definition: udatpg.h:144