ICU 64.2 64.2

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/uenum.h"
24 #include "unicode/localpointer.h"
25
47 typedef void *UDateTimePatternGenerator;
48
55 typedef enum UDateTimePatternField {
57 UDATPG_ERA_FIELD,
59 UDATPG_YEAR_FIELD,
61 UDATPG_QUARTER_FIELD,
63 UDATPG_MONTH_FIELD,
65 UDATPG_WEEK_OF_YEAR_FIELD,
67 UDATPG_WEEK_OF_MONTH_FIELD,
69 UDATPG_WEEKDAY_FIELD,
71 UDATPG_DAY_OF_YEAR_FIELD,
73 UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD,
75 UDATPG_DAY_FIELD,
77 UDATPG_DAYPERIOD_FIELD,
79 UDATPG_HOUR_FIELD,
81 UDATPG_MINUTE_FIELD,
83 UDATPG_SECOND_FIELD,
85 UDATPG_FRACTIONAL_SECOND_FIELD,
87 UDATPG_ZONE_FIELD,
88
89 /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
90 * it is needed for layout of DateTimePatternGenerator object. */
95 UDATPG_FIELD_COUNT
96 } UDateTimePatternField;
97
102 typedef enum UDateTimePGDisplayWidth {
104 UDATPG_WIDE,
106 UDATPG_ABBREVIATED,
108 UDATPG_NARROW
109 } UDateTimePGDisplayWidth;
110
118 typedef enum UDateTimePatternMatchOptions {
120 UDATPG_MATCH_NO_OPTIONS = 0,
122 UDATPG_MATCH_HOUR_FIELD_LENGTH = 1 << UDATPG_HOUR_FIELD,
123 #ifndef U_HIDE_INTERNAL_API
124
125 UDATPG_MATCH_MINUTE_FIELD_LENGTH = 1 << UDATPG_MINUTE_FIELD,
127 UDATPG_MATCH_SECOND_FIELD_LENGTH = 1 << UDATPG_SECOND_FIELD,
128 #endif /* U_HIDE_INTERNAL_API */
129
130 UDATPG_MATCH_ALL_FIELDS_LENGTH = (1 << UDATPG_FIELD_COUNT) - 1
131 } UDateTimePatternMatchOptions;
132
137 typedef enum UDateTimePatternConflict {
139 UDATPG_NO_CONFLICT,
141 UDATPG_BASE_CONFLICT,
143 UDATPG_CONFLICT,
144 #ifndef U_HIDE_DEPRECATED_API
145
149 UDATPG_CONFLICT_COUNT
150 #endif // U_HIDE_DEPRECATED_API
151 } UDateTimePatternConflict;
152
161 U_STABLE UDateTimePatternGenerator * U_EXPORT2
162 udatpg_open(const char *locale, UErrorCode *pErrorCode);
163
171 U_STABLE UDateTimePatternGenerator * U_EXPORT2
172 udatpg_openEmpty(UErrorCode *pErrorCode);
173
179 U_STABLE void U_EXPORT2
180 udatpg_close(UDateTimePatternGenerator *dtpg);
181
182 #if U_SHOW_CPLUSPLUS_API
183
184 U_NAMESPACE_BEGIN
185
195 U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateTimePatternGeneratorPointer, UDateTimePatternGenerator, udatpg_close);
196
197 U_NAMESPACE_END
198
199 #endif
200
209 U_STABLE UDateTimePatternGenerator * U_EXPORT2
210 udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
211
235 U_STABLE int32_t U_EXPORT2
236 udatpg_getBestPattern(UDateTimePatternGenerator *dtpg,
237 const UChar *skeleton, int32_t length,
238 UChar *bestPattern, int32_t capacity,
239 UErrorCode *pErrorCode);
240
271 U_STABLE int32_t U_EXPORT2
272 udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg,
273 const UChar *skeleton, int32_t length,
274 UDateTimePatternMatchOptions options,
275 UChar *bestPattern, int32_t capacity,
276 UErrorCode *pErrorCode);
277
299 U_STABLE int32_t U_EXPORT2
300 udatpg_getSkeleton(UDateTimePatternGenerator *unusedDtpg,
301 const UChar *pattern, int32_t length,
302 UChar *skeleton, int32_t capacity,
303 UErrorCode *pErrorCode);
304
329 U_STABLE int32_t U_EXPORT2
330 udatpg_getBaseSkeleton(UDateTimePatternGenerator *unusedDtpg,
331 const UChar *pattern, int32_t length,
332 UChar *baseSkeleton, int32_t capacity,
333 UErrorCode *pErrorCode);
334
359 U_STABLE UDateTimePatternConflict U_EXPORT2
360 udatpg_addPattern(UDateTimePatternGenerator *dtpg,
361 const UChar *pattern, int32_t patternLength,
362 UBool override,
363 UChar *conflictingPattern, int32_t capacity, int32_t *pLength,
364 UErrorCode *pErrorCode);
365
386 U_STABLE void U_EXPORT2
387 udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg,
388 UDateTimePatternField field,
389 const UChar *value, int32_t length);
390
401 U_STABLE const UChar * U_EXPORT2
402 udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg,
403 UDateTimePatternField field,
404 int32_t *pLength);
405
419 U_STABLE void U_EXPORT2
420 udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg,
421 UDateTimePatternField field,
422 const UChar *value, int32_t length);
423
436 U_STABLE const UChar * U_EXPORT2
437 udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg,
438 UDateTimePatternField field,
439 int32_t *pLength);
440
466 U_STABLE int32_t U_EXPORT2
467 udatpg_getFieldDisplayName(const UDateTimePatternGenerator *dtpg,
468 UDateTimePatternField field,
469 UDateTimePGDisplayWidth width,
470 UChar *fieldName, int32_t capacity,
471 UErrorCode *pErrorCode);
472
496 U_STABLE void U_EXPORT2
497 udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg,
498 const UChar *dtFormat, int32_t length);
499
507 U_STABLE const UChar * U_EXPORT2
508 udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg,
509 int32_t *pLength);
510
524 U_STABLE void U_EXPORT2
525 udatpg_setDecimal(UDateTimePatternGenerator *dtpg,
526 const UChar *decimal, int32_t length);
527
536 U_STABLE const UChar * U_EXPORT2
537 udatpg_getDecimal(const UDateTimePatternGenerator *dtpg,
538 int32_t *pLength);
539
565 U_STABLE int32_t U_EXPORT2
566 udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg,
567 const UChar *pattern, int32_t patternLength,
568 const UChar *skeleton, int32_t skeletonLength,
569 UChar *dest, int32_t destCapacity,
570 UErrorCode *pErrorCode);
571
602 U_STABLE int32_t U_EXPORT2
603 udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg,
604 const UChar *pattern, int32_t patternLength,
605 const UChar *skeleton, int32_t skeletonLength,
606 UDateTimePatternMatchOptions options,
607 UChar *dest, int32_t destCapacity,
608 UErrorCode *pErrorCode);
609
621 U_STABLE UEnumeration * U_EXPORT2
622 udatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
623
634 U_STABLE UEnumeration * U_EXPORT2
635 udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
636
647 U_STABLE const UChar * U_EXPORT2
648 udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg,
649 const UChar *skeleton, int32_t skeletonLength,
650 int32_t *pLength);
651
652 #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:127
UDATPG_HOUR_FIELD
Definition: udatpg.h:79
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:57
UDATPG_NO_CONFLICT
Definition: udatpg.h:139
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:63
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.
UDATPG_WEEKDAY_FIELD
Definition: udatpg.h:69
UDATPG_WIDE
Definition: udatpg.h:104
UDATPG_SECOND_FIELD
Definition: udatpg.h:83
LocalUDateTimePatternGeneratorPointer
"Smart pointer" class, closes a UDateTimePatternGenerator via udatpg_close().
UDATPG_CONFLICT
Definition: udatpg.h:143
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:81
UDATPG_WEEK_OF_YEAR_FIELD
Definition: udatpg.h:65
UDATPG_CONFLICT_COUNT
One more than the highest normal UDateTimePatternConflict value.
Definition: udatpg.h:149
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:77
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.
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
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:106
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:562
UDATPG_MATCH_MINUTE_FIELD_LENGTH
Definition: udatpg.h:125
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.
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:71
UDATPG_MATCH_NO_OPTIONS
Definition: udatpg.h:120
UDATPG_DAY_FIELD
Definition: udatpg.h:75
UDateTimePatternConflict
UDateTimePatternConflict
Status return values from udatpg_addPattern().
Definition: udatpg.h:137
UDATPG_YEAR_FIELD
Definition: udatpg.h:59
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:95
UChar
uint16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:342
udatpg_close
void udatpg_close(UDateTimePatternGenerator *dtpg)
Close a generator.
UDATPG_WEEK_OF_MONTH_FIELD
Definition: udatpg.h:67
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
UDateTimePatternField
UDateTimePatternField
Field number constants for udatpg_getAppendItemFormats() and similar functions.
Definition: udatpg.h:55
UDATPG_MATCH_ALL_FIELDS_LENGTH
Definition: udatpg.h:130
UDateTimePatternGenerator
void * UDateTimePatternGenerator
Opaque type for a date/time pattern generator object.
Definition: udatpg.h:47
UDATPG_ZONE_FIELD
Definition: udatpg.h:87
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:401
UDateTimePGDisplayWidth
UDateTimePGDisplayWidth
Field display name width constants for udatpg_getFieldDisplayName().
Definition: udatpg.h:102
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:73
UDATPG_MATCH_HOUR_FIELD_LENGTH
Definition: udatpg.h:122
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:108
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:118
UDATPG_QUARTER_FIELD
Definition: udatpg.h:61
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:85
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225
UDATPG_BASE_CONFLICT
Definition: udatpg.h:141