uformattable.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************
* Copyright (C) 2013-2014, International Business Machines Corporation and others.
* All Rights Reserved.
********************************************************************************
*
* File UFORMATTABLE.H
*
* Modification History:
*
* Date Name Description
* 2013 Jun 7 srl New
********************************************************************************
*/
#ifndef UFORMATTABLE_H
#define UFORMATTABLE_H
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
#endif // U_SHOW_CPLUSPLUS_API
typedef enum UFormattableType {
UFMT_DATE = 0,
UFMT_DOUBLE,
UFMT_LONG,
UFMT_STRING,
UFMT_ARRAY,
UFMT_INT64,
UFMT_OBJECT,
#ifndef U_HIDE_DEPRECATED_API
UFMT_COUNT
#endif /* U_HIDE_DEPRECATED_API */
} UFormattableType;
typedef void *UFormattable;
U_CAPI UFormattable* U_EXPORT2
ufmt_open(UErrorCode* status);
U_CAPI void U_EXPORT2
ufmt_close(UFormattable* fmt);
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattablePointer, UFormattable, ufmt_close);
U_NAMESPACE_END
#endif
U_CAPI UFormattableType U_EXPORT2
ufmt_getType(const UFormattable* fmt, UErrorCode *status);
U_CAPI UBool U_EXPORT2
ufmt_isNumeric(const UFormattable* fmt);
U_CAPI UDate U_EXPORT2
ufmt_getDate(const UFormattable* fmt, UErrorCode *status);
U_CAPI double U_EXPORT2
ufmt_getDouble(UFormattable* fmt, UErrorCode *status);
U_CAPI int32_t U_EXPORT2
ufmt_getLong(UFormattable* fmt, UErrorCode *status);
U_CAPI int64_t U_EXPORT2
ufmt_getInt64(UFormattable* fmt, UErrorCode *status);
U_CAPI const void *U_EXPORT2
ufmt_getObject(const UFormattable* fmt, UErrorCode *status);
U_CAPI const UChar* U_EXPORT2
ufmt_getUChars(UFormattable* fmt, int32_t *len, UErrorCode *status);
U_CAPI int32_t U_EXPORT2
ufmt_getArrayLength(const UFormattable* fmt, UErrorCode *status);
U_CAPI UFormattable * U_EXPORT2
ufmt_getArrayItemByIndex(UFormattable* fmt, int32_t n, UErrorCode *status);
U_CAPI const char * U_EXPORT2
ufmt_getDecNumChars(UFormattable *fmt, int32_t *len, UErrorCode *status);
#endif
#endif
LocalUFormattablePointer
"Smart pointer" class, closes a UFormattable via ufmt_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
ufmt_close
U_CAPI void ufmt_close(UFormattable *fmt)
Cleanup any additional memory allocated by this UFormattable.
ufmt_getUChars
U_CAPI const UChar * ufmt_getUChars(UFormattable *fmt, int32_t *len, UErrorCode *status)
Gets the string value of this object as a UChar string.
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_getDouble
U_CAPI double ufmt_getDouble(UFormattable *fmt, UErrorCode *status)
Gets the double value of this object.
ufmt_getInt64
U_CAPI int64_t ufmt_getInt64(UFormattable *fmt, UErrorCode *status)
Gets the int64_t value of this object.
ufmt_isNumeric
U_CAPI UBool ufmt_isNumeric(const UFormattable *fmt)
Return whether the object is numeric.
UFormattableType
UFormattableType
Enum designating the type of a UFormattable instance.
Definition: uformattable.h:48
UFMT_STRING
@ UFMT_STRING
ufmt_getUChars() will return without conversion.
Definition: uformattable.h:52
UFMT_LONG
@ UFMT_LONG
ufmt_getLong() will return without conversion.
Definition: uformattable.h:51
UFMT_ARRAY
@ UFMT_ARRAY
ufmt_countArray() and ufmt_getArray() will return the value.
Definition: uformattable.h:53
UFMT_OBJECT
@ UFMT_OBJECT
ufmt_getObject() will return without conversion.
Definition: uformattable.h:55
UFMT_DOUBLE
@ UFMT_DOUBLE
ufmt_getDouble() will return without conversion.
Definition: uformattable.h:50
UFMT_DATE
@ UFMT_DATE
ufmt_getDate() will return without conversion.
Definition: uformattable.h:49
UFMT_COUNT
@ UFMT_COUNT
One more than the highest normal UFormattableType value.
Definition: uformattable.h:61
UFMT_INT64
@ UFMT_INT64
ufmt_getInt64() will return without conversion.
Definition: uformattable.h:54
ufmt_getLong
U_CAPI int32_t ufmt_getLong(UFormattable *fmt, UErrorCode *status)
Gets the long (int32_t) value of this object.
ufmt_getDecNumChars
U_CAPI const char * ufmt_getDecNumChars(UFormattable *fmt, int32_t *len, UErrorCode *status)
Returns a numeric string representation of the number contained within this formattable,...
UFormattable
void * UFormattable
Opaque type representing various types of data which may be used for formatting and parsing operation...
Definition: uformattable.h:72
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.
ufmt_getObject
U_CAPI const void * ufmt_getObject(const UFormattable *fmt, UErrorCode *status)
Returns a pointer to the UObject contained within this formattable (as a const void*),...
ufmt_getDate
U_CAPI UDate ufmt_getDate(const UFormattable *fmt, UErrorCode *status)
Gets the UDate value of this object.
ufmt_getArrayItemByIndex
U_CAPI UFormattable * ufmt_getArrayItemByIndex(UFormattable *fmt, int32_t n, UErrorCode *status)
Get the specified value from the array of UFormattables.
ufmt_getType
U_CAPI UFormattableType ufmt_getType(const UFormattable *fmt, UErrorCode *status)
Return the type of this object.
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:378
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
UDate
double UDate
Date and Time data type.
Definition: utypes.h:203