ICU 67.1 67.1

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
11 #include "unicode/ufieldpositer.h"
12
34 typedef enum UFieldCategory {
40 UFIELD_CATEGORY_UNDEFINED = 0,
41
47 UFIELD_CATEGORY_DATE,
48
54 UFIELD_CATEGORY_NUMBER,
55
61 UFIELD_CATEGORY_LIST,
62
68 UFIELD_CATEGORY_RELATIVE_DATETIME,
69
75 UFIELD_CATEGORY_DATE_INTERVAL,
76
77 #ifndef U_HIDE_INTERNAL_API
78
79 UFIELD_CATEGORY_COUNT,
80 #endif /* U_HIDE_INTERNAL_API */
81
87 UFIELD_CATEGORY_LIST_SPAN = 0x1000 + UFIELD_CATEGORY_LIST,
88
94 UFIELD_CATEGORY_DATE_INTERVAL_SPAN = 0x1000 + UFIELD_CATEGORY_DATE_INTERVAL,
95
96 } UFieldCategory;
97
98
99 struct UConstrainedFieldPosition;
111 typedef struct UConstrainedFieldPosition UConstrainedFieldPosition;
112
113
123 U_STABLE UConstrainedFieldPosition* U_EXPORT2
124 ucfpos_open(UErrorCode* ec);
125
126
136 U_STABLE void U_EXPORT2
137 ucfpos_reset(
138 UConstrainedFieldPosition* ucfpos,
139 UErrorCode* ec);
140
141
148 U_STABLE void U_EXPORT2
149 ucfpos_close(UConstrainedFieldPosition* ucfpos);
150
151
177 U_STABLE void U_EXPORT2
178 ucfpos_constrainCategory(
179 UConstrainedFieldPosition* ucfpos,
180 int32_t category,
181 UErrorCode* ec);
182
183
210 U_STABLE void U_EXPORT2
211 ucfpos_constrainField(
212 UConstrainedFieldPosition* ucfpos,
213 int32_t category,
214 int32_t field,
215 UErrorCode* ec);
216
217
230 U_STABLE int32_t U_EXPORT2
231 ucfpos_getCategory(
232 const UConstrainedFieldPosition* ucfpos,
233 UErrorCode* ec);
234
235
248 U_STABLE int32_t U_EXPORT2
249 ucfpos_getField(
250 const UConstrainedFieldPosition* ucfpos,
251 UErrorCode* ec);
252
253
265 U_STABLE void U_EXPORT2
266 ucfpos_getIndexes(
267 const UConstrainedFieldPosition* ucfpos,
268 int32_t* pStart,
269 int32_t* pLimit,
270 UErrorCode* ec);
271
272
285 U_STABLE int64_t U_EXPORT2
286 ucfpos_getInt64IterationContext(
287 const UConstrainedFieldPosition* ucfpos,
288 UErrorCode* ec);
289
290
301 U_STABLE void U_EXPORT2
302 ucfpos_setInt64IterationContext(
303 UConstrainedFieldPosition* ucfpos,
304 int64_t context,
305 UErrorCode* ec);
306
307
320 U_STABLE UBool U_EXPORT2
321 ucfpos_matchesField(
322 const UConstrainedFieldPosition* ucfpos,
323 int32_t category,
324 int32_t field,
325 UErrorCode* ec);
326
327
344 U_STABLE void U_EXPORT2
345 ucfpos_setState(
346 UConstrainedFieldPosition* ucfpos,
347 int32_t category,
348 int32_t field,
349 int32_t start,
350 int32_t limit,
351 UErrorCode* ec);
352
353
354 struct UFormattedValue;
361 typedef struct UFormattedValue UFormattedValue;
362
363
377 U_STABLE const UChar* U_EXPORT2
378 ufmtval_getString(
379 const UFormattedValue* ufmtval,
380 int32_t* pLength,
381 UErrorCode* ec);
382
383
407 U_STABLE UBool U_EXPORT2
408 ufmtval_nextPosition(
409 const UFormattedValue* ufmtval,
410 UConstrainedFieldPosition* ucfpos,
411 UErrorCode* ec);
412
413
414 #if U_SHOW_CPLUSPLUS_API
415 U_NAMESPACE_BEGIN
416
429 U_DEFINE_LOCAL_OPEN_POINTER(LocalUConstrainedFieldPositionPointer,
430 UConstrainedFieldPosition,
431 ucfpos_close);
432
433 U_NAMESPACE_END
434 #endif // U_SHOW_CPLUSPLUS_API
435
436
437 #endif /* #if !UCONFIG_NO_FORMATTING */
438 #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:47
UFIELD_CATEGORY_DATE_INTERVAL_SPAN
Category for spans in a date interval.
Definition: uformattedvalue.h:94
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:79
UFIELD_CATEGORY_LIST
For fields in UListFormatterField (ulistformatter.h), from ICU 63.
Definition: uformattedvalue.h:61
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:40
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:34
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
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:87
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:376
ucfpos_constrainCategory
void ucfpos_constrainCategory(UConstrainedFieldPosition *ucfpos, int32_t category, UErrorCode *ec)
Sets a constraint on the field category.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
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:111
UFormattedValue
struct UFormattedValue UFormattedValue
An abstract formatted value: a string with associated field attributes.
Definition: uformattedvalue.h:361
ufmtval_getString
const UChar * ufmtval_getString(const UFormattedValue *ufmtval, int32_t *pLength, UErrorCode *ec)
Returns a pointer to the formatted string.
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:54
UFIELD_CATEGORY_RELATIVE_DATETIME
For fields in URelativeDateTimeFormatterField (ureldatefmt.h), from ICU 64.
Definition: uformattedvalue.h:68
U_STABLE
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:111
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261
UFIELD_CATEGORY_DATE_INTERVAL
Reserved for possible future fields in UDateIntervalFormatField.
Definition: uformattedvalue.h:75