uformattedvalue.h
Go to the documentation of this file.
// © 2018 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
#ifndef __UFORMATTEDVALUE_H__
#define __UFORMATTEDVALUE_H__
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#include "unicode/ufieldpositer.h"
typedef enum UFieldCategory {
UFIELD_CATEGORY_UNDEFINED = 0,
UFIELD_CATEGORY_DATE,
UFIELD_CATEGORY_NUMBER,
UFIELD_CATEGORY_LIST,
UFIELD_CATEGORY_RELATIVE_DATETIME,
UFIELD_CATEGORY_DATE_INTERVAL,
#ifndef U_HIDE_INTERNAL_API
UFIELD_CATEGORY_COUNT,
#endif /* U_HIDE_INTERNAL_API */
UFIELD_CATEGORY_LIST_SPAN = 0x1000 + UFIELD_CATEGORY_LIST,
UFIELD_CATEGORY_DATE_INTERVAL_SPAN = 0x1000 + UFIELD_CATEGORY_DATE_INTERVAL,
UFIELD_CATEGORY_NUMBER_RANGE_SPAN = 0x1000 + UFIELD_CATEGORY_NUMBER,
} UFieldCategory;
struct UConstrainedFieldPosition;
typedef struct UConstrainedFieldPosition UConstrainedFieldPosition;
U_CAPI UConstrainedFieldPosition* U_EXPORT2
ucfpos_open(UErrorCode* ec);
U_CAPI void U_EXPORT2
ucfpos_reset(
UConstrainedFieldPosition* ucfpos,
UErrorCode* ec);
U_CAPI void U_EXPORT2
ucfpos_close(UConstrainedFieldPosition* ucfpos);
U_CAPI void U_EXPORT2
ucfpos_constrainCategory(
UConstrainedFieldPosition* ucfpos,
int32_t category,
UErrorCode* ec);
U_CAPI void U_EXPORT2
ucfpos_constrainField(
UConstrainedFieldPosition* ucfpos,
int32_t category,
int32_t field,
UErrorCode* ec);
U_CAPI int32_t U_EXPORT2
ucfpos_getCategory(
const UConstrainedFieldPosition* ucfpos,
UErrorCode* ec);
U_CAPI int32_t U_EXPORT2
ucfpos_getField(
const UConstrainedFieldPosition* ucfpos,
UErrorCode* ec);
U_CAPI void U_EXPORT2
ucfpos_getIndexes(
const UConstrainedFieldPosition* ucfpos,
int32_t* pStart,
int32_t* pLimit,
UErrorCode* ec);
U_CAPI int64_t U_EXPORT2
ucfpos_getInt64IterationContext(
const UConstrainedFieldPosition* ucfpos,
UErrorCode* ec);
U_CAPI void U_EXPORT2
ucfpos_setInt64IterationContext(
UConstrainedFieldPosition* ucfpos,
int64_t context,
UErrorCode* ec);
U_CAPI UBool U_EXPORT2
ucfpos_matchesField(
const UConstrainedFieldPosition* ucfpos,
int32_t category,
int32_t field,
UErrorCode* ec);
U_CAPI void U_EXPORT2
ucfpos_setState(
UConstrainedFieldPosition* ucfpos,
int32_t category,
int32_t field,
int32_t start,
int32_t limit,
UErrorCode* ec);
struct UFormattedValue;
typedef struct UFormattedValue UFormattedValue;
U_CAPI const UChar* U_EXPORT2
ufmtval_getString(
const UFormattedValue* ufmtval,
int32_t* pLength,
UErrorCode* ec);
U_CAPI UBool U_EXPORT2
ufmtval_nextPosition(
const UFormattedValue* ufmtval,
UConstrainedFieldPosition* ucfpos,
UErrorCode* ec);
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
U_DEFINE_LOCAL_OPEN_POINTER(LocalUConstrainedFieldPositionPointer,
UConstrainedFieldPosition,
ucfpos_close);
U_NAMESPACE_END
#endif // U_SHOW_CPLUSPLUS_API
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif // __UFORMATTEDVALUE_H__
LocalUConstrainedFieldPositionPointer
"Smart pointer" class; closes a UConstrainedFieldPosition via ucfpos_close().
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
ufieldpositer.h
C API: UFieldPositionIterator for use with format APIs.
ucfpos_constrainCategory
U_CAPI void ucfpos_constrainCategory(UConstrainedFieldPosition *ucfpos, int32_t category, UErrorCode *ec)
Sets a constraint on the field category.
ufmtval_getString
U_CAPI const UChar * ufmtval_getString(const UFormattedValue *ufmtval, int32_t *pLength, UErrorCode *ec)
Returns a pointer to the formatted string.
ucfpos_constrainField
U_CAPI void ucfpos_constrainField(UConstrainedFieldPosition *ucfpos, int32_t category, int32_t field, UErrorCode *ec)
Sets a constraint on the category and field.
ucfpos_getIndexes
U_CAPI 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.
UFieldCategory
UFieldCategory
All possible field categories in ICU.
Definition: uformattedvalue.h:34
UFIELD_CATEGORY_DATE_INTERVAL
@ UFIELD_CATEGORY_DATE_INTERVAL
Reserved for possible future fields in UDateIntervalFormatField.
Definition: uformattedvalue.h:75
UFIELD_CATEGORY_DATE_INTERVAL_SPAN
@ UFIELD_CATEGORY_DATE_INTERVAL_SPAN
Category for spans in a date interval.
Definition: uformattedvalue.h:94
UFIELD_CATEGORY_DATE
@ UFIELD_CATEGORY_DATE
For fields in UDateFormatField (udat.h), from ICU 3.0.
Definition: uformattedvalue.h:47
UFIELD_CATEGORY_LIST_SPAN
@ UFIELD_CATEGORY_LIST_SPAN
Category for spans in a list.
Definition: uformattedvalue.h:87
UFIELD_CATEGORY_RELATIVE_DATETIME
@ UFIELD_CATEGORY_RELATIVE_DATETIME
For fields in URelativeDateTimeFormatterField (ureldatefmt.h), from ICU 64.
Definition: uformattedvalue.h:68
UFIELD_CATEGORY_UNDEFINED
@ UFIELD_CATEGORY_UNDEFINED
For an undefined field category.
Definition: uformattedvalue.h:40
UFIELD_CATEGORY_LIST
@ UFIELD_CATEGORY_LIST
For fields in UListFormatterField (ulistformatter.h), from ICU 63.
Definition: uformattedvalue.h:61
UFIELD_CATEGORY_NUMBER_RANGE_SPAN
@ UFIELD_CATEGORY_NUMBER_RANGE_SPAN
Category for spans in a number range.
Definition: uformattedvalue.h:101
UFIELD_CATEGORY_COUNT
@ UFIELD_CATEGORY_COUNT
Definition: uformattedvalue.h:79
UFIELD_CATEGORY_NUMBER
@ UFIELD_CATEGORY_NUMBER
For fields in UNumberFormatFields (unum.h), from ICU 49.
Definition: uformattedvalue.h:54
ucfpos_close
U_CAPI void ucfpos_close(UConstrainedFieldPosition *ucfpos)
Destroys a UConstrainedFieldPosition and releases its memory.
UConstrainedFieldPosition
struct UConstrainedFieldPosition UConstrainedFieldPosition
Represents a span of a string containing a given field.
Definition: uformattedvalue.h:118
ucfpos_open
U_CAPI UConstrainedFieldPosition * ucfpos_open(UErrorCode *ec)
Creates a new UConstrainedFieldPosition.
ucfpos_reset
U_CAPI void ucfpos_reset(UConstrainedFieldPosition *ucfpos, UErrorCode *ec)
Resets a UConstrainedFieldPosition to its initial state, as if it were newly created.
ucfpos_matchesField
U_CAPI 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.
ucfpos_getCategory
U_CAPI int32_t ucfpos_getCategory(const UConstrainedFieldPosition *ucfpos, UErrorCode *ec)
Gets the field category for the current position.
ucfpos_setState
U_CAPI 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_getField
U_CAPI int32_t ucfpos_getField(const UConstrainedFieldPosition *ucfpos, UErrorCode *ec)
Gets the field for the current position.
ucfpos_getInt64IterationContext
U_CAPI int64_t ucfpos_getInt64IterationContext(const UConstrainedFieldPosition *ucfpos, UErrorCode *ec)
Gets an int64 that FormattedValue implementations may use for storage.
ufmtval_nextPosition
U_CAPI UBool ufmtval_nextPosition(const UFormattedValue *ufmtval, UConstrainedFieldPosition *ucfpos, UErrorCode *ec)
Iterates over field positions in the UFormattedValue.
UFormattedValue
struct UFormattedValue UFormattedValue
An abstract formatted value: a string with associated field attributes.
Definition: uformattedvalue.h:368
ucfpos_setInt64IterationContext
U_CAPI void ucfpos_setInt64IterationContext(UConstrainedFieldPosition *ucfpos, int64_t context, UErrorCode *ec)
Sets an int64 that FormattedValue implementations may use for storage.
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
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:386
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:415