ICU 64.2 64.2

uformattedvalue.h
Go to the documentation of this file.
1 // © 2018 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3
4 #ifndef __UFORMATTEDVALUE_H__
5 #define __UFORMATTEDVALUE_H__
6
7 #include "unicode/utypes.h"
8
9 #if !UCONFIG_NO_FORMATTING
10 #ifndef U_HIDE_DRAFT_API
11
12 #include "unicode/ufieldpositer.h"
13
35 typedef enum UFieldCategory {
41 UFIELD_CATEGORY_UNDEFINED = 0,
42
48 UFIELD_CATEGORY_DATE,
49
55 UFIELD_CATEGORY_NUMBER,
56
62 UFIELD_CATEGORY_LIST,
63
69 UFIELD_CATEGORY_RELATIVE_DATETIME,
70
76 UFIELD_CATEGORY_DATE_INTERVAL,
77
78 #ifndef U_HIDE_INTERNAL_API
79
80 UFIELD_CATEGORY_COUNT,
81 #endif /* U_HIDE_INTERNAL_API */
82
88 UFIELD_CATEGORY_LIST_SPAN = 0x1000 + UFIELD_CATEGORY_LIST,
89
95 UFIELD_CATEGORY_DATE_INTERVAL_SPAN = 0x1000 + UFIELD_CATEGORY_DATE_INTERVAL,
96
97 } UFieldCategory;
98
99
100 struct UConstrainedFieldPosition;
112 typedef struct UConstrainedFieldPosition UConstrainedFieldPosition;
113
114
124 U_DRAFT UConstrainedFieldPosition* U_EXPORT2
125 ucfpos_open(UErrorCode* ec);
126
127
137 U_DRAFT void U_EXPORT2
138 ucfpos_reset(
139 UConstrainedFieldPosition* ucfpos,
140 UErrorCode* ec);
141
142
149 U_DRAFT void U_EXPORT2
150 ucfpos_close(UConstrainedFieldPosition* ucfpos);
151
152
178 U_DRAFT void U_EXPORT2
179 ucfpos_constrainCategory(
180 UConstrainedFieldPosition* ucfpos,
181 int32_t category,
182 UErrorCode* ec);
183
184
211 U_DRAFT void U_EXPORT2
212 ucfpos_constrainField(
213 UConstrainedFieldPosition* ucfpos,
214 int32_t category,
215 int32_t field,
216 UErrorCode* ec);
217
218
231 U_DRAFT int32_t U_EXPORT2
232 ucfpos_getCategory(
233 const UConstrainedFieldPosition* ucfpos,
234 UErrorCode* ec);
235
236
249 U_DRAFT int32_t U_EXPORT2
250 ucfpos_getField(
251 const UConstrainedFieldPosition* ucfpos,
252 UErrorCode* ec);
253
254
266 U_DRAFT void U_EXPORT2
267 ucfpos_getIndexes(
268 const UConstrainedFieldPosition* ucfpos,
269 int32_t* pStart,
270 int32_t* pLimit,
271 UErrorCode* ec);
272
273
286 U_DRAFT int64_t U_EXPORT2
287 ucfpos_getInt64IterationContext(
288 const UConstrainedFieldPosition* ucfpos,
289 UErrorCode* ec);
290
291
302 U_DRAFT void U_EXPORT2
303 ucfpos_setInt64IterationContext(
304 UConstrainedFieldPosition* ucfpos,
305 int64_t context,
306 UErrorCode* ec);
307
308
321 U_DRAFT UBool U_EXPORT2
322 ucfpos_matchesField(
323 const UConstrainedFieldPosition* ucfpos,
324 int32_t category,
325 int32_t field,
326 UErrorCode* ec);
327
328
345 U_DRAFT void U_EXPORT2
346 ucfpos_setState(
347 UConstrainedFieldPosition* ucfpos,
348 int32_t category,
349 int32_t field,
350 int32_t start,
351 int32_t limit,
352 UErrorCode* ec);
353
354
355 struct UFormattedValue;
362 typedef struct UFormattedValue UFormattedValue;
363
364
378 U_DRAFT const UChar* U_EXPORT2
379 ufmtval_getString(
380 const UFormattedValue* ufmtval,
381 int32_t* pLength,
382 UErrorCode* ec);
383
384
408 U_DRAFT UBool U_EXPORT2
409 ufmtval_nextPosition(
410 const UFormattedValue* ufmtval,
411 UConstrainedFieldPosition* ucfpos,
412 UErrorCode* ec);
413
414
415 #if U_SHOW_CPLUSPLUS_API
416 U_NAMESPACE_BEGIN
417
430 U_DEFINE_LOCAL_OPEN_POINTER(LocalUConstrainedFieldPositionPointer,
431 UConstrainedFieldPosition,
432 ucfpos_close);
433
434 U_NAMESPACE_END
435 #endif // U_SHOW_CPLUSPLUS_API
436
437
438 #endif /* U_HIDE_DRAFT_API */
439 #endif /* #if !UCONFIG_NO_FORMATTING */
440 #endif // __UFORMATTEDVALUE_H__
LocalUConstrainedFieldPositionPointer
"Smart pointer" class; closes a UConstrainedFieldPosition via ucfpos_close().
ucfpos_setInt64IterationContext
void ucfpos_setInt64IterationContext(UConstrainedFieldPosition *ucfpos, int64_t context, UErrorCode *ec)
Sets an int64 that FormattedValue implementations may use for storage.
UFIELD_CATEGORY_DATE
For fields in UDateFormatField (udat.h), from ICU 3.0.
Definition: uformattedvalue.h:48
UFIELD_CATEGORY_DATE_INTERVAL_SPAN
Category for spans in a date interval.
Definition: uformattedvalue.h:95
ufmtval_nextPosition
UBool ufmtval_nextPosition(const UFormattedValue *ufmtval, UConstrainedFieldPosition *ucfpos, UErrorCode *ec)
Iterates over field positions in the UFormattedValue.
UFIELD_CATEGORY_COUNT
Definition: uformattedvalue.h:80
UFIELD_CATEGORY_LIST
For fields in UListFormatterField (ulistformatter.h), from ICU 63.
Definition: uformattedvalue.h:62
ucfpos_getField
int32_t ucfpos_getField(const UConstrainedFieldPosition *ucfpos, UErrorCode *ec)
Gets the field for the current position.
UFIELD_CATEGORY_UNDEFINED
For an undefined field category.
Definition: uformattedvalue.h:41
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
ucfpos_getCategory
int32_t ucfpos_getCategory(const UConstrainedFieldPosition *ucfpos, UErrorCode *ec)
Gets the field category for the current position.
UFieldCategory
UFieldCategory
All possible field categories in ICU.
Definition: uformattedvalue.h:35
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
ucfpos_close
void ucfpos_close(UConstrainedFieldPosition *ucfpos)
Destroys a UConstrainedFieldPosition and releases its memory.
ucfpos_reset
void ucfpos_reset(UConstrainedFieldPosition *ucfpos, UErrorCode *ec)
Resets a UConstrainedFieldPosition to its initial state, as if it were newly created.
UFIELD_CATEGORY_LIST_SPAN
Category for spans in a list.
Definition: uformattedvalue.h:88
UChar
uint16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:342
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
ucfpos_constrainCategory
void ucfpos_constrainCategory(UConstrainedFieldPosition *ucfpos, int32_t category, UErrorCode *ec)
Sets a constraint on the field category.
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:401
ucfpos_constrainField
void ucfpos_constrainField(UConstrainedFieldPosition *ucfpos, int32_t category, int32_t field, UErrorCode *ec)
Sets a constraint on the category and field.
ufieldpositer.h
C API: UFieldPositionIterator for use with format APIs.
ucfpos_matchesField
UBool ucfpos_matchesField(const UConstrainedFieldPosition *ucfpos, int32_t category, int32_t field, UErrorCode *ec)
Determines whether a given field should be included given the constraints.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
ucfpos_getIndexes
void ucfpos_getIndexes(const UConstrainedFieldPosition *ucfpos, int32_t *pStart, int32_t *pLimit, UErrorCode *ec)
Gets the INCLUSIVE start and EXCLUSIVE end index stored for the current position.
ucfpos_setState
void ucfpos_setState(UConstrainedFieldPosition *ucfpos, int32_t category, int32_t field, int32_t start, int32_t limit, UErrorCode *ec)
Sets new values for the primary public getters.
ucfpos_open
UConstrainedFieldPosition * ucfpos_open(UErrorCode *ec)
Creates a new UConstrainedFieldPosition.
UConstrainedFieldPosition
struct UConstrainedFieldPosition UConstrainedFieldPosition
Represents a span of a string containing a given field.
Definition: uformattedvalue.h:112
UFormattedValue
struct UFormattedValue UFormattedValue
An abstract formatted value: a string with associated field attributes.
Definition: uformattedvalue.h:362
ufmtval_getString
const UChar * ufmtval_getString(const UFormattedValue *ufmtval, int32_t *pLength, UErrorCode *ec)
Returns a pointer to the formatted string.
U_DRAFT
#define U_DRAFT
This is used to declare a function as a draft public ICU C API.
Definition: umachine.h:113
ucfpos_getInt64IterationContext
int64_t ucfpos_getInt64IterationContext(const UConstrainedFieldPosition *ucfpos, UErrorCode *ec)
Gets an int64 that FormattedValue implementations may use for storage.
UFIELD_CATEGORY_NUMBER
For fields in UNumberFormatFields (unum.h), from ICU 49.
Definition: uformattedvalue.h:55
UFIELD_CATEGORY_RELATIVE_DATETIME
For fields in URelativeDateTimeFormatterField (ureldatefmt.h), from ICU 64.
Definition: uformattedvalue.h:69
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225
UFIELD_CATEGORY_DATE_INTERVAL
Reserved for possible future fields in UDateIntervalFormatField.
Definition: uformattedvalue.h:76