ICU 71.1 71.1

uformattable.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 * Copyright (C) 2013-2014, International Business Machines Corporation and others.
6 * All Rights Reserved.
7 ********************************************************************************
8 *
9 * File UFORMATTABLE.H
10 *
11 * Modification History:
12 *
13 * Date Name Description
14 * 2013 Jun 7 srl New
15 ********************************************************************************
16 */
17
30 #ifndef UFORMATTABLE_H
31 #define UFORMATTABLE_H
32
33 #include "unicode/utypes.h"
34
35 #if !UCONFIG_NO_FORMATTING
36
37 #if U_SHOW_CPLUSPLUS_API
38 #include "unicode/localpointer.h"
39 #endif // U_SHOW_CPLUSPLUS_API
40
48 typedef enum UFormattableType {
49 UFMT_DATE = 0,
50 UFMT_DOUBLE,
51 UFMT_LONG,
52 UFMT_STRING,
53 UFMT_ARRAY,
54 UFMT_INT64,
55 UFMT_OBJECT,
56 #ifndef U_HIDE_DEPRECATED_API
57
61 UFMT_COUNT
62 #endif /* U_HIDE_DEPRECATED_API */
63 } UFormattableType;
64
65
72 typedef void *UFormattable;
73
84 U_CAPI UFormattable* U_EXPORT2
85 ufmt_open(UErrorCode* status);
86
93 U_CAPI void U_EXPORT2
94 ufmt_close(UFormattable* fmt);
95
96 #if U_SHOW_CPLUSPLUS_API
97
98 U_NAMESPACE_BEGIN
99
109 U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattablePointer, UFormattable, ufmt_close);
110
111 U_NAMESPACE_END
112
113 #endif
114
125 U_CAPI UFormattableType U_EXPORT2
126 ufmt_getType(const UFormattable* fmt, UErrorCode *status);
127
136 U_CAPI UBool U_EXPORT2
137 ufmt_isNumeric(const UFormattable* fmt);
138
149 U_CAPI UDate U_EXPORT2
150 ufmt_getDate(const UFormattable* fmt, UErrorCode *status);
151
167 U_CAPI double U_EXPORT2
168 ufmt_getDouble(UFormattable* fmt, UErrorCode *status);
169
188 U_CAPI int32_t U_EXPORT2
189 ufmt_getLong(UFormattable* fmt, UErrorCode *status);
190
191
209 U_CAPI int64_t U_EXPORT2
210 ufmt_getInt64(UFormattable* fmt, UErrorCode *status);
211
222 U_CAPI const void *U_EXPORT2
223 ufmt_getObject(const UFormattable* fmt, UErrorCode *status);
224
237 U_CAPI const UChar* U_EXPORT2
238 ufmt_getUChars(UFormattable* fmt, int32_t *len, UErrorCode *status);
239
248 U_CAPI int32_t U_EXPORT2
249 ufmt_getArrayLength(const UFormattable* fmt, UErrorCode *status);
250
260 U_CAPI UFormattable * U_EXPORT2
261 ufmt_getArrayItemByIndex(UFormattable* fmt, int32_t n, UErrorCode *status);
262
285 U_CAPI const char * U_EXPORT2
286 ufmt_getDecNumChars(UFormattable *fmt, int32_t *len, UErrorCode *status);
287
288 #endif
289
290 #endif
ufmt_getObject
const U_CAPI void * ufmt_getObject(const UFormattable *fmt, UErrorCode *status)
Returns a pointer to the UObject contained within this formattable (as a const void*),...
UFMT_DOUBLE
@ UFMT_DOUBLE
ufmt_getDouble() will return without conversion.
Definition: uformattable.h:50
ufmt_open
U_CAPI UFormattable * ufmt_open(UErrorCode *status)
Initialize a UFormattable, to type UNUM_LONG, value 0 may return error if memory allocation failed.
UFormattableType
UFormattableType
Enum designating the type of a UFormattable instance.
Definition: uformattable.h:48
UFormattable
void * UFormattable
Opaque type representing various types of data which may be used for formatting and parsing operation...
Definition: uformattable.h:72
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
ufmt_getArrayItemByIndex
U_CAPI UFormattable * ufmt_getArrayItemByIndex(UFormattable *fmt, int32_t n, UErrorCode *status)
Get the specified value from the array of UFormattables.
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
UFMT_DATE
@ UFMT_DATE
ufmt_getDate() will return without conversion.
Definition: uformattable.h:49
ufmt_getDecNumChars
const U_CAPI char * ufmt_getDecNumChars(UFormattable *fmt, int32_t *len, UErrorCode *status)
Returns a numeric string representation of the number contained within this formattable,...
UFMT_STRING
@ UFMT_STRING
ufmt_getUChars() will return without conversion.
Definition: uformattable.h:52
UFMT_COUNT
@ UFMT_COUNT
One more than the highest normal UFormattableType value.
Definition: uformattable.h:61
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
ufmt_getInt64
U_CAPI int64_t ufmt_getInt64(UFormattable *fmt, UErrorCode *status)
Gets the int64_t value of this object.
LocalUFormattablePointer
UFMT_OBJECT
@ UFMT_OBJECT
ufmt_getObject() will return without conversion.
Definition: uformattable.h:55
ufmt_close
U_CAPI void ufmt_close(UFormattable *fmt)
Cleanup any additional memory allocated by this UFormattable.
UFMT_INT64
@ UFMT_INT64
ufmt_getInt64() will return without conversion.
Definition: uformattable.h:54
ufmt_getDouble
U_CAPI double ufmt_getDouble(UFormattable *fmt, UErrorCode *status)
Gets the double value of this object.
ufmt_getDate
U_CAPI UDate ufmt_getDate(const UFormattable *fmt, UErrorCode *status)
Gets the UDate value of this object.
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
Definition: localpointer.h:550
ufmt_getArrayLength
U_CAPI int32_t ufmt_getArrayLength(const UFormattable *fmt, UErrorCode *status)
Get the number of array objects contained, if an array type UFMT_ARRAY.
ufmt_getUChars
const U_CAPI UChar * ufmt_getUChars(UFormattable *fmt, int32_t *len, UErrorCode *status)
Gets the string value of this object as a UChar string.
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
UDate
double UDate
Date and Time data type.
Definition: utypes.h:203
ufmt_isNumeric
U_CAPI UBool ufmt_isNumeric(const UFormattable *fmt)
Return whether the object is numeric.
UFMT_ARRAY
@ UFMT_ARRAY
ufmt_countArray() and ufmt_getArray() will return the value.
Definition: uformattable.h:53
ufmt_getLong
U_CAPI int32_t ufmt_getLong(UFormattable *fmt, UErrorCode *status)
Gets the long (int32_t) value of this object.
UChar
char16_t UChar
Definition: umachine.h:418
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
ufmt_getType
U_CAPI UFormattableType ufmt_getType(const UFormattable *fmt, UErrorCode *status)
Return the type of this object.
UFMT_LONG
@ UFMT_LONG
ufmt_getLong() will return without conversion.
Definition: uformattable.h:51