ICU 76.1: i18n/unicode/udatpg.h Source File

ICU 76.1 76.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
26#if U_SHOW_CPLUSPLUS_API
27#include "unicode/localpointer.h"
28#endif // U_SHOW_CPLUSPLUS_API
29
51 typedef void *UDateTimePatternGenerator;
52
59 typedef enum UDateTimePatternField {
61 UDATPG_ERA_FIELD,
63 UDATPG_YEAR_FIELD,
65 UDATPG_QUARTER_FIELD,
67 UDATPG_MONTH_FIELD,
69 UDATPG_WEEK_OF_YEAR_FIELD,
71 UDATPG_WEEK_OF_MONTH_FIELD,
73 UDATPG_WEEKDAY_FIELD,
75 UDATPG_DAY_OF_YEAR_FIELD,
77 UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD,
79 UDATPG_DAY_FIELD,
81 UDATPG_DAYPERIOD_FIELD,
83 UDATPG_HOUR_FIELD,
85 UDATPG_MINUTE_FIELD,
87 UDATPG_SECOND_FIELD,
89 UDATPG_FRACTIONAL_SECOND_FIELD,
91 UDATPG_ZONE_FIELD,
92
93 /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
94 * it is needed for layout of DateTimePatternGenerator object. */
95#ifndef U_FORCE_HIDE_DEPRECATED_API
100 UDATPG_FIELD_COUNT
101#endif // U_FORCE_HIDE_DEPRECATED_API
102} UDateTimePatternField;
103
108 typedef enum UDateTimePGDisplayWidth {
110 UDATPG_WIDE,
112 UDATPG_ABBREVIATED,
114 UDATPG_NARROW
115} UDateTimePGDisplayWidth;
116
124 typedef enum UDateTimePatternMatchOptions {
126 UDATPG_MATCH_NO_OPTIONS = 0,
128 UDATPG_MATCH_HOUR_FIELD_LENGTH = 1 << UDATPG_HOUR_FIELD,
129#ifndef U_HIDE_INTERNAL_API
131 UDATPG_MATCH_MINUTE_FIELD_LENGTH = 1 << UDATPG_MINUTE_FIELD,
133 UDATPG_MATCH_SECOND_FIELD_LENGTH = 1 << UDATPG_SECOND_FIELD,
134#endif /* U_HIDE_INTERNAL_API */
136 UDATPG_MATCH_ALL_FIELDS_LENGTH = (1 << UDATPG_FIELD_COUNT) - 1
137} UDateTimePatternMatchOptions;
138
143 typedef enum UDateTimePatternConflict {
145 UDATPG_NO_CONFLICT,
147 UDATPG_BASE_CONFLICT,
149 UDATPG_CONFLICT,
150#ifndef U_HIDE_DEPRECATED_API
155 UDATPG_CONFLICT_COUNT
156#endif // U_HIDE_DEPRECATED_API
157} UDateTimePatternConflict;
158
167 U_CAPI UDateTimePatternGenerator * U_EXPORT2
168udatpg_open(const char *locale, UErrorCode *pErrorCode);
169
177 U_CAPI UDateTimePatternGenerator * U_EXPORT2
178udatpg_openEmpty(UErrorCode *pErrorCode);
179
185 U_CAPI void U_EXPORT2
186udatpg_close(UDateTimePatternGenerator *dtpg);
187
188#if U_SHOW_CPLUSPLUS_API
189
190U_NAMESPACE_BEGIN
191
201 U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateTimePatternGeneratorPointer, UDateTimePatternGenerator, udatpg_close);
202
203U_NAMESPACE_END
204
205#endif
206
215 U_CAPI UDateTimePatternGenerator * U_EXPORT2
216udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
217
241 U_CAPI int32_t U_EXPORT2
242udatpg_getBestPattern(UDateTimePatternGenerator *dtpg,
243 const UChar *skeleton, int32_t length,
244 UChar *bestPattern, int32_t capacity,
245 UErrorCode *pErrorCode);
246
277 U_CAPI int32_t U_EXPORT2
278udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg,
279 const UChar *skeleton, int32_t length,
280 UDateTimePatternMatchOptions options,
281 UChar *bestPattern, int32_t capacity,
282 UErrorCode *pErrorCode);
283
305 U_CAPI int32_t U_EXPORT2
306udatpg_getSkeleton(UDateTimePatternGenerator *unusedDtpg,
307 const UChar *pattern, int32_t length,
308 UChar *skeleton, int32_t capacity,
309 UErrorCode *pErrorCode);
310
335 U_CAPI int32_t U_EXPORT2
336udatpg_getBaseSkeleton(UDateTimePatternGenerator *unusedDtpg,
337 const UChar *pattern, int32_t length,
338 UChar *baseSkeleton, int32_t capacity,
339 UErrorCode *pErrorCode);
340
365 U_CAPI UDateTimePatternConflict U_EXPORT2
366udatpg_addPattern(UDateTimePatternGenerator *dtpg,
367 const UChar *pattern, int32_t patternLength,
368 UBool override,
369 UChar *conflictingPattern, int32_t capacity, int32_t *pLength,
370 UErrorCode *pErrorCode);
371
392 U_CAPI void U_EXPORT2
393udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg,
394 UDateTimePatternField field,
395 const UChar *value, int32_t length);
396
407 U_CAPI const UChar * U_EXPORT2
408udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg,
409 UDateTimePatternField field,
410 int32_t *pLength);
411
425 U_CAPI void U_EXPORT2
426udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg,
427 UDateTimePatternField field,
428 const UChar *value, int32_t length);
429
442 U_CAPI const UChar * U_EXPORT2
443udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg,
444 UDateTimePatternField field,
445 int32_t *pLength);
446
472 U_CAPI int32_t U_EXPORT2
473udatpg_getFieldDisplayName(const UDateTimePatternGenerator *dtpg,
474 UDateTimePatternField field,
475 UDateTimePGDisplayWidth width,
476 UChar *fieldName, int32_t capacity,
477 UErrorCode *pErrorCode);
478
507 U_CAPI void U_EXPORT2
508udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg,
509 const UChar *dtFormat, int32_t length);
510
524 U_CAPI const UChar * U_EXPORT2
525udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg,
526 int32_t *pLength);
527
528#if !UCONFIG_NO_FORMATTING
556 U_CAPI void U_EXPORT2
557udatpg_setDateTimeFormatForStyle(UDateTimePatternGenerator *udtpg,
558 UDateFormatStyle style,
559 const UChar *dateTimeFormat, int32_t length,
560 UErrorCode *pErrorCode);
561
584 U_CAPI const UChar* U_EXPORT2
585udatpg_getDateTimeFormatForStyle(const UDateTimePatternGenerator *udtpg,
586 UDateFormatStyle style, int32_t *pLength,
587 UErrorCode *pErrorCode);
588#endif /* #if !UCONFIG_NO_FORMATTING */
589
603 U_CAPI void U_EXPORT2
604udatpg_setDecimal(UDateTimePatternGenerator *dtpg,
605 const UChar *decimal, int32_t length);
606
615 U_CAPI const UChar * U_EXPORT2
616udatpg_getDecimal(const UDateTimePatternGenerator *dtpg,
617 int32_t *pLength);
618
644 U_CAPI int32_t U_EXPORT2
645udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg,
646 const UChar *pattern, int32_t patternLength,
647 const UChar *skeleton, int32_t skeletonLength,
648 UChar *dest, int32_t destCapacity,
649 UErrorCode *pErrorCode);
650
681 U_CAPI int32_t U_EXPORT2
682udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg,
683 const UChar *pattern, int32_t patternLength,
684 const UChar *skeleton, int32_t skeletonLength,
685 UDateTimePatternMatchOptions options,
686 UChar *dest, int32_t destCapacity,
687 UErrorCode *pErrorCode);
688
700 U_CAPI UEnumeration * U_EXPORT2
701udatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
702
713 U_CAPI UEnumeration * U_EXPORT2
714udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
715
726 U_CAPI const UChar * U_EXPORT2
727udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg,
728 const UChar *skeleton, int32_t skeletonLength,
729 int32_t *pLength);
730
731#if !UCONFIG_NO_FORMATTING
732
746 U_CAPI UDateFormatHourCycle U_EXPORT2
747udatpg_getDefaultHourCycle(const UDateTimePatternGenerator *dtpg, UErrorCode* pErrorCode);
748
749#endif /* #if !UCONFIG_NO_FORMATTING */
750
751#endif
LocalUDateTimePatternGeneratorPointer
"Smart pointer" class, closes a UDateTimePatternGenerator via udatpg_close().
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
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
udat.h
C API: DateFormat.
UDateFormatStyle
UDateFormatStyle
The possible date/time format styles.
Definition udat.h:162
UDateFormatHourCycle
UDateFormatHourCycle
Hour Cycle.
Definition udat.h:983
udatpg_openSkeletons
U_CAPI UEnumeration * udatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode)
Return a UEnumeration list of all the skeletons in canonical form.
udatpg_getBestPatternWithOptions
U_CAPI 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.
UDateTimePGDisplayWidth
UDateTimePGDisplayWidth
Field display name width constants for udatpg_getFieldDisplayName().
Definition udatpg.h:108
UDATPG_ABBREVIATED
@ UDATPG_ABBREVIATED
Definition udatpg.h:112
UDATPG_WIDE
@ UDATPG_WIDE
Definition udatpg.h:110
UDATPG_NARROW
@ UDATPG_NARROW
Definition udatpg.h:114
udatpg_close
U_CAPI void udatpg_close(UDateTimePatternGenerator *dtpg)
Close a generator.
udatpg_getDateTimeFormat
U_CAPI const UChar * udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg, int32_t *pLength)
Getter corresponding to setDateTimeFormat.
udatpg_getAppendItemFormat
U_CAPI const UChar * udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg, UDateTimePatternField field, int32_t *pLength)
Getter corresponding to setAppendItemFormat.
UDateTimePatternGenerator
void * UDateTimePatternGenerator
Opaque type for a date/time pattern generator object.
Definition udatpg.h:51
udatpg_getDecimal
U_CAPI const UChar * udatpg_getDecimal(const UDateTimePatternGenerator *dtpg, int32_t *pLength)
Getter corresponding to setDecimal.
udatpg_setDecimal
U_CAPI void udatpg_setDecimal(UDateTimePatternGenerator *dtpg, const UChar *decimal, int32_t length)
The decimal value is used in formatting fractions of seconds.
udatpg_addPattern
U_CAPI 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_getDateTimeFormatForStyle
U_CAPI const UChar * udatpg_getDateTimeFormatForStyle(const UDateTimePatternGenerator *udtpg, UDateFormatStyle style, int32_t *pLength, UErrorCode *pErrorCode)
Getter corresponding to udatpg_setDateTimeFormatForStyle.
udatpg_setAppendItemFormat
U_CAPI 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_getBestPattern
U_CAPI 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_getSkeleton
U_CAPI 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.
UDateTimePatternConflict
UDateTimePatternConflict
Status return values from udatpg_addPattern().
Definition udatpg.h:143
UDATPG_NO_CONFLICT
@ UDATPG_NO_CONFLICT
Definition udatpg.h:145
UDATPG_BASE_CONFLICT
@ UDATPG_BASE_CONFLICT
Definition udatpg.h:147
UDATPG_CONFLICT
@ UDATPG_CONFLICT
Definition udatpg.h:149
UDATPG_CONFLICT_COUNT
@ UDATPG_CONFLICT_COUNT
One more than the highest normal UDateTimePatternConflict value.
Definition udatpg.h:155
udatpg_replaceFieldTypes
U_CAPI 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.
udatpg_openEmpty
U_CAPI UDateTimePatternGenerator * udatpg_openEmpty(UErrorCode *pErrorCode)
Open an empty generator, to be constructed with udatpg_addPattern(...) etc.
udatpg_setAppendItemName
U_CAPI 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_setDateTimeFormatForStyle
U_CAPI void udatpg_setDateTimeFormatForStyle(UDateTimePatternGenerator *udtpg, UDateFormatStyle style, const UChar *dateTimeFormat, int32_t length, UErrorCode *pErrorCode)
dateTimeFormats are message patterns used to compose combinations of date and time patterns.
udatpg_setDateTimeFormat
U_CAPI 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.
UDateTimePatternMatchOptions
UDateTimePatternMatchOptions
Masks to control forcing the length of specified fields in the returned pattern to match those in the...
Definition udatpg.h:124
UDATPG_MATCH_HOUR_FIELD_LENGTH
@ UDATPG_MATCH_HOUR_FIELD_LENGTH
Definition udatpg.h:128
UDATPG_MATCH_MINUTE_FIELD_LENGTH
@ UDATPG_MATCH_MINUTE_FIELD_LENGTH
Definition udatpg.h:131
UDATPG_MATCH_SECOND_FIELD_LENGTH
@ UDATPG_MATCH_SECOND_FIELD_LENGTH
Definition udatpg.h:133
UDATPG_MATCH_NO_OPTIONS
@ UDATPG_MATCH_NO_OPTIONS
Definition udatpg.h:126
UDATPG_MATCH_ALL_FIELDS_LENGTH
@ UDATPG_MATCH_ALL_FIELDS_LENGTH
Definition udatpg.h:136
udatpg_getAppendItemName
U_CAPI const UChar * udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg, UDateTimePatternField field, int32_t *pLength)
Getter corresponding to setAppendItemNames.
udatpg_getDefaultHourCycle
U_CAPI UDateFormatHourCycle udatpg_getDefaultHourCycle(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode)
Return the default hour cycle for a locale.
udatpg_replaceFieldTypesWithOptions
U_CAPI 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.
udatpg_getFieldDisplayName
U_CAPI 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_getBaseSkeleton
U_CAPI 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_open
U_CAPI UDateTimePatternGenerator * udatpg_open(const char *locale, UErrorCode *pErrorCode)
Open a generator according to a given locale.
udatpg_openBaseSkeletons
U_CAPI UEnumeration * udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode)
Return a UEnumeration list of all the base skeletons in canonical form.
udatpg_getPatternForSkeleton
U_CAPI const UChar * udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg, const UChar *skeleton, int32_t skeletonLength, int32_t *pLength)
Get the pattern corresponding to a given skeleton.
udatpg_clone
U_CAPI UDateTimePatternGenerator * udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode)
Create a copy pf a generator.
UDateTimePatternField
UDateTimePatternField
Field number constants for udatpg_getAppendItemFormats() and similar functions.
Definition udatpg.h:59
UDATPG_WEEK_OF_YEAR_FIELD
@ UDATPG_WEEK_OF_YEAR_FIELD
Definition udatpg.h:69
UDATPG_DAY_OF_YEAR_FIELD
@ UDATPG_DAY_OF_YEAR_FIELD
Definition udatpg.h:75
UDATPG_QUARTER_FIELD
@ UDATPG_QUARTER_FIELD
Definition udatpg.h:65
UDATPG_WEEKDAY_FIELD
@ UDATPG_WEEKDAY_FIELD
Definition udatpg.h:73
UDATPG_DAYPERIOD_FIELD
@ UDATPG_DAYPERIOD_FIELD
Definition udatpg.h:81
UDATPG_MONTH_FIELD
@ UDATPG_MONTH_FIELD
Definition udatpg.h:67
UDATPG_DAY_FIELD
@ UDATPG_DAY_FIELD
Definition udatpg.h:79
UDATPG_SECOND_FIELD
@ UDATPG_SECOND_FIELD
Definition udatpg.h:87
UDATPG_ZONE_FIELD
@ UDATPG_ZONE_FIELD
Definition udatpg.h:91
UDATPG_FRACTIONAL_SECOND_FIELD
@ UDATPG_FRACTIONAL_SECOND_FIELD
Definition udatpg.h:89
UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD
@ UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD
Definition udatpg.h:77
UDATPG_YEAR_FIELD
@ UDATPG_YEAR_FIELD
Definition udatpg.h:63
UDATPG_FIELD_COUNT
@ UDATPG_FIELD_COUNT
One more than the highest normal UDateTimePatternField value.
Definition udatpg.h:100
UDATPG_WEEK_OF_MONTH_FIELD
@ UDATPG_WEEK_OF_MONTH_FIELD
Definition udatpg.h:71
UDATPG_HOUR_FIELD
@ UDATPG_HOUR_FIELD
Definition udatpg.h:83
UDATPG_ERA_FIELD
@ UDATPG_ERA_FIELD
Definition udatpg.h:61
UDATPG_MINUTE_FIELD
@ UDATPG_MINUTE_FIELD
Definition udatpg.h:85
uenum.h
C API: String Enumeration.
UEnumeration
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition uenum.h:44
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:378
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:247
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition umachine.h:110
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:430