159d709d503bab6e2b61931737e662dd293b40578ccornelius/*
259d709d503bab6e2b61931737e662dd293b40578ccornelius********************************************************************************
3f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius* Copyright (C) 2013-2014, International Business Machines Corporation and others.
459d709d503bab6e2b61931737e662dd293b40578ccornelius* All Rights Reserved.
559d709d503bab6e2b61931737e662dd293b40578ccornelius********************************************************************************
659d709d503bab6e2b61931737e662dd293b40578ccornelius*
759d709d503bab6e2b61931737e662dd293b40578ccornelius* File UFORMATTABLE.H
859d709d503bab6e2b61931737e662dd293b40578ccornelius*
959d709d503bab6e2b61931737e662dd293b40578ccornelius* Modification History:
1059d709d503bab6e2b61931737e662dd293b40578ccornelius*
1159d709d503bab6e2b61931737e662dd293b40578ccornelius*   Date        Name        Description
1259d709d503bab6e2b61931737e662dd293b40578ccornelius*   2013 Jun 7  srl         New
1359d709d503bab6e2b61931737e662dd293b40578ccornelius********************************************************************************
1459d709d503bab6e2b61931737e662dd293b40578ccornelius*/
1559d709d503bab6e2b61931737e662dd293b40578ccornelius
1659d709d503bab6e2b61931737e662dd293b40578ccornelius/**
1759d709d503bab6e2b61931737e662dd293b40578ccornelius * \file
1859d709d503bab6e2b61931737e662dd293b40578ccornelius * \brief C API: UFormattable is a thin wrapper for primitive types used for formatting and parsing.
1959d709d503bab6e2b61931737e662dd293b40578ccornelius *
2059d709d503bab6e2b61931737e662dd293b40578ccornelius * This is a C interface to the icu::Formattable class. Static functions on this class convert
2159d709d503bab6e2b61931737e662dd293b40578ccornelius * to and from this interface (via reinterpret_cast).  Note that Formattables (and thus UFormattables)
2259d709d503bab6e2b61931737e662dd293b40578ccornelius * are mutable, and many operations (even getters) may actually modify the internal state. For this
2359d709d503bab6e2b61931737e662dd293b40578ccornelius * reason, UFormattables are not thread safe, and should not be shared between threads.
2459d709d503bab6e2b61931737e662dd293b40578ccornelius *
2559d709d503bab6e2b61931737e662dd293b40578ccornelius * See {@link unum_parseToUFormattable} for example code.
2659d709d503bab6e2b61931737e662dd293b40578ccornelius */
2759d709d503bab6e2b61931737e662dd293b40578ccornelius
2859d709d503bab6e2b61931737e662dd293b40578ccornelius#ifndef UFORMATTABLE_H
2959d709d503bab6e2b61931737e662dd293b40578ccornelius#define UFORMATTABLE_H
3059d709d503bab6e2b61931737e662dd293b40578ccornelius
3159d709d503bab6e2b61931737e662dd293b40578ccornelius#include "unicode/utypes.h"
3259d709d503bab6e2b61931737e662dd293b40578ccornelius
3359d709d503bab6e2b61931737e662dd293b40578ccornelius#if !UCONFIG_NO_FORMATTING
3459d709d503bab6e2b61931737e662dd293b40578ccornelius
3559d709d503bab6e2b61931737e662dd293b40578ccornelius#include "unicode/localpointer.h"
3659d709d503bab6e2b61931737e662dd293b40578ccornelius
3759d709d503bab6e2b61931737e662dd293b40578ccornelius/**
3859d709d503bab6e2b61931737e662dd293b40578ccornelius * Enum designating the type of a UFormattable instance.
3959d709d503bab6e2b61931737e662dd293b40578ccornelius * Practically, this indicates which of the getters would return without conversion
4059d709d503bab6e2b61931737e662dd293b40578ccornelius * or error.
4159d709d503bab6e2b61931737e662dd293b40578ccornelius * @see icu::Formattable::Type
42f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
4359d709d503bab6e2b61931737e662dd293b40578ccornelius */
4459d709d503bab6e2b61931737e662dd293b40578ccorneliustypedef enum UFormattableType {
4559d709d503bab6e2b61931737e662dd293b40578ccornelius  UFMT_DATE = 0, /**< ufmt_getDate() will return without conversion. @see ufmt_getDate*/
4659d709d503bab6e2b61931737e662dd293b40578ccornelius  UFMT_DOUBLE,   /**< ufmt_getDouble() will return without conversion.  @see ufmt_getDouble*/
4759d709d503bab6e2b61931737e662dd293b40578ccornelius  UFMT_LONG,     /**< ufmt_getLong() will return without conversion. @see ufmt_getLong */
4859d709d503bab6e2b61931737e662dd293b40578ccornelius  UFMT_STRING,   /**< ufmt_getUChars() will return without conversion.  @see ufmt_getUChars*/
4959d709d503bab6e2b61931737e662dd293b40578ccornelius  UFMT_ARRAY,    /**< ufmt_countArray() and ufmt_getArray() will return the value.  @see ufmt_getArrayItemByIndex */
5059d709d503bab6e2b61931737e662dd293b40578ccornelius  UFMT_INT64,    /**< ufmt_getInt64() will return without conversion. @see ufmt_getInt64 */
5159d709d503bab6e2b61931737e662dd293b40578ccornelius  UFMT_OBJECT,   /**< ufmt_getObject() will return without conversion.  @see ufmt_getObject*/
5259d709d503bab6e2b61931737e662dd293b40578ccornelius  UFMT_COUNT     /**< Count of defined UFormattableType values */
5359d709d503bab6e2b61931737e662dd293b40578ccornelius} UFormattableType;
5459d709d503bab6e2b61931737e662dd293b40578ccornelius
5559d709d503bab6e2b61931737e662dd293b40578ccornelius
5659d709d503bab6e2b61931737e662dd293b40578ccornelius/**
5759d709d503bab6e2b61931737e662dd293b40578ccornelius * Opaque type representing various types of data which may be used for formatting
5859d709d503bab6e2b61931737e662dd293b40578ccornelius * and parsing operations.
5959d709d503bab6e2b61931737e662dd293b40578ccornelius * @see icu::Formattable
60f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
6159d709d503bab6e2b61931737e662dd293b40578ccornelius */
6259d709d503bab6e2b61931737e662dd293b40578ccorneliustypedef void *UFormattable;
6359d709d503bab6e2b61931737e662dd293b40578ccornelius
6459d709d503bab6e2b61931737e662dd293b40578ccornelius/**
6559d709d503bab6e2b61931737e662dd293b40578ccornelius * Initialize a UFormattable, to type UNUM_LONG, value 0
6659d709d503bab6e2b61931737e662dd293b40578ccornelius * may return error if memory allocation failed.
6759d709d503bab6e2b61931737e662dd293b40578ccornelius * parameter status error code.
6859d709d503bab6e2b61931737e662dd293b40578ccornelius * See {@link unum_parseToUFormattable} for example code.
69f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
7059d709d503bab6e2b61931737e662dd293b40578ccornelius * @return the new UFormattable
7159d709d503bab6e2b61931737e662dd293b40578ccornelius * @see ufmt_close
7259d709d503bab6e2b61931737e662dd293b40578ccornelius * @see icu::Formattable::Formattable()
7359d709d503bab6e2b61931737e662dd293b40578ccornelius */
74f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusU_STABLE UFormattable* U_EXPORT2
7559d709d503bab6e2b61931737e662dd293b40578ccorneliusufmt_open(UErrorCode* status);
7659d709d503bab6e2b61931737e662dd293b40578ccornelius
7759d709d503bab6e2b61931737e662dd293b40578ccornelius/**
7859d709d503bab6e2b61931737e662dd293b40578ccornelius * Cleanup any additional memory allocated by this UFormattable.
7959d709d503bab6e2b61931737e662dd293b40578ccornelius * @param fmt the formatter
80f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
8159d709d503bab6e2b61931737e662dd293b40578ccornelius * @see ufmt_open
8259d709d503bab6e2b61931737e662dd293b40578ccornelius */
83f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusU_STABLE void U_EXPORT2
8459d709d503bab6e2b61931737e662dd293b40578ccorneliusufmt_close(UFormattable* fmt);
8559d709d503bab6e2b61931737e662dd293b40578ccornelius
8659d709d503bab6e2b61931737e662dd293b40578ccornelius#if U_SHOW_CPLUSPLUS_API
8759d709d503bab6e2b61931737e662dd293b40578ccornelius
8859d709d503bab6e2b61931737e662dd293b40578ccorneliusU_NAMESPACE_BEGIN
8959d709d503bab6e2b61931737e662dd293b40578ccornelius
9059d709d503bab6e2b61931737e662dd293b40578ccornelius/**
9159d709d503bab6e2b61931737e662dd293b40578ccornelius * \class LocalUFormattablePointer
9259d709d503bab6e2b61931737e662dd293b40578ccornelius * "Smart pointer" class, closes a UFormattable via ufmt_close().
9359d709d503bab6e2b61931737e662dd293b40578ccornelius * For most methods see the LocalPointerBase base class.
9459d709d503bab6e2b61931737e662dd293b40578ccornelius *
9559d709d503bab6e2b61931737e662dd293b40578ccornelius * @see LocalPointerBase
9659d709d503bab6e2b61931737e662dd293b40578ccornelius * @see LocalPointer
97f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
9859d709d503bab6e2b61931737e662dd293b40578ccornelius */
9959d709d503bab6e2b61931737e662dd293b40578ccorneliusU_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattablePointer, UFormattable, ufmt_close);
10059d709d503bab6e2b61931737e662dd293b40578ccornelius
10159d709d503bab6e2b61931737e662dd293b40578ccorneliusU_NAMESPACE_END
10259d709d503bab6e2b61931737e662dd293b40578ccornelius
10359d709d503bab6e2b61931737e662dd293b40578ccornelius#endif
10459d709d503bab6e2b61931737e662dd293b40578ccornelius
10559d709d503bab6e2b61931737e662dd293b40578ccornelius/**
10659d709d503bab6e2b61931737e662dd293b40578ccornelius * Return the type of this object
10759d709d503bab6e2b61931737e662dd293b40578ccornelius * @param fmt the UFormattable object
10859d709d503bab6e2b61931737e662dd293b40578ccornelius * @param status status code - U_ILLEGAL_ARGUMENT_ERROR is returned if the UFormattable contains data not supported by
10959d709d503bab6e2b61931737e662dd293b40578ccornelius * the API
11059d709d503bab6e2b61931737e662dd293b40578ccornelius * @return the value as a UFormattableType
11159d709d503bab6e2b61931737e662dd293b40578ccornelius * @see ufmt_isNumeric
11259d709d503bab6e2b61931737e662dd293b40578ccornelius * @see icu::Formattable::getType() const
113f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
11459d709d503bab6e2b61931737e662dd293b40578ccornelius */
115f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusU_STABLE UFormattableType U_EXPORT2
11659d709d503bab6e2b61931737e662dd293b40578ccorneliusufmt_getType(const UFormattable* fmt, UErrorCode *status);
11759d709d503bab6e2b61931737e662dd293b40578ccornelius
11859d709d503bab6e2b61931737e662dd293b40578ccornelius/**
11959d709d503bab6e2b61931737e662dd293b40578ccornelius * Return whether the object is numeric.
12059d709d503bab6e2b61931737e662dd293b40578ccornelius * @param fmt the UFormattable object
12159d709d503bab6e2b61931737e662dd293b40578ccornelius * @return true if the object is a double, long, or int64 value, else false.
12259d709d503bab6e2b61931737e662dd293b40578ccornelius * @see ufmt_getType
12359d709d503bab6e2b61931737e662dd293b40578ccornelius * @see icu::Formattable::isNumeric() const
124f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
12559d709d503bab6e2b61931737e662dd293b40578ccornelius */
126f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusU_STABLE UBool U_EXPORT2
12759d709d503bab6e2b61931737e662dd293b40578ccorneliusufmt_isNumeric(const UFormattable* fmt);
12859d709d503bab6e2b61931737e662dd293b40578ccornelius
12959d709d503bab6e2b61931737e662dd293b40578ccornelius/**
13059d709d503bab6e2b61931737e662dd293b40578ccornelius * Gets the UDate value of this object.  If the type is not of type UFMT_DATE,
13159d709d503bab6e2b61931737e662dd293b40578ccornelius * status is set to U_INVALID_FORMAT_ERROR and the return value is
13259d709d503bab6e2b61931737e662dd293b40578ccornelius * undefined.
13359d709d503bab6e2b61931737e662dd293b40578ccornelius * @param fmt the UFormattable object
13459d709d503bab6e2b61931737e662dd293b40578ccornelius * @param status the error code - any conversion or format errors
13559d709d503bab6e2b61931737e662dd293b40578ccornelius * @return the value
136f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
13759d709d503bab6e2b61931737e662dd293b40578ccornelius * @see icu::Formattable::getDate(UErrorCode&) const
13859d709d503bab6e2b61931737e662dd293b40578ccornelius */
139f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusU_STABLE UDate U_EXPORT2
14059d709d503bab6e2b61931737e662dd293b40578ccorneliusufmt_getDate(const UFormattable* fmt, UErrorCode *status);
14159d709d503bab6e2b61931737e662dd293b40578ccornelius
14259d709d503bab6e2b61931737e662dd293b40578ccornelius/**
14359d709d503bab6e2b61931737e662dd293b40578ccornelius * Gets the double value of this object. If the type is not a UFMT_DOUBLE, or
14459d709d503bab6e2b61931737e662dd293b40578ccornelius * if there are additional significant digits than fit in a double type,
14559d709d503bab6e2b61931737e662dd293b40578ccornelius * a conversion is performed with  possible loss of precision.
14659d709d503bab6e2b61931737e662dd293b40578ccornelius * If the type is UFMT_OBJECT and the
14759d709d503bab6e2b61931737e662dd293b40578ccornelius * object is a Measure, then the result of
14859d709d503bab6e2b61931737e662dd293b40578ccornelius * getNumber().getDouble(status) is returned.  If this object is
14959d709d503bab6e2b61931737e662dd293b40578ccornelius * neither a numeric type nor a Measure, then 0 is returned and
15059d709d503bab6e2b61931737e662dd293b40578ccornelius * the status is set to U_INVALID_FORMAT_ERROR.
15159d709d503bab6e2b61931737e662dd293b40578ccornelius * @param fmt the UFormattable object
15259d709d503bab6e2b61931737e662dd293b40578ccornelius * @param status the error code - any conversion or format errors
15359d709d503bab6e2b61931737e662dd293b40578ccornelius * @return the value
154f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
15559d709d503bab6e2b61931737e662dd293b40578ccornelius * @see icu::Formattable::getDouble(UErrorCode&) const
15659d709d503bab6e2b61931737e662dd293b40578ccornelius */
157f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusU_STABLE double U_EXPORT2
15859d709d503bab6e2b61931737e662dd293b40578ccorneliusufmt_getDouble(UFormattable* fmt, UErrorCode *status);
15959d709d503bab6e2b61931737e662dd293b40578ccornelius
16059d709d503bab6e2b61931737e662dd293b40578ccornelius/**
16159d709d503bab6e2b61931737e662dd293b40578ccornelius * Gets the long (int32_t) value of this object. If the magnitude is too
16259d709d503bab6e2b61931737e662dd293b40578ccornelius * large to fit in a long, then the maximum or minimum long value,
16359d709d503bab6e2b61931737e662dd293b40578ccornelius * as appropriate, is returned and the status is set to
16459d709d503bab6e2b61931737e662dd293b40578ccornelius * U_INVALID_FORMAT_ERROR.  If this object is of type UFMT_INT64 and
16559d709d503bab6e2b61931737e662dd293b40578ccornelius * it fits within a long, then no precision is lost.  If it is of
16659d709d503bab6e2b61931737e662dd293b40578ccornelius * type kDouble or kDecimalNumber, then a conversion is peformed, with
16759d709d503bab6e2b61931737e662dd293b40578ccornelius * truncation of any fractional part.  If the type is UFMT_OBJECT and
16859d709d503bab6e2b61931737e662dd293b40578ccornelius * the object is a Measure, then the result of
16959d709d503bab6e2b61931737e662dd293b40578ccornelius * getNumber().getLong(status) is returned.  If this object is
17059d709d503bab6e2b61931737e662dd293b40578ccornelius * neither a numeric type nor a Measure, then 0 is returned and
17159d709d503bab6e2b61931737e662dd293b40578ccornelius * the status is set to U_INVALID_FORMAT_ERROR.
17259d709d503bab6e2b61931737e662dd293b40578ccornelius * @param fmt the UFormattable object
17359d709d503bab6e2b61931737e662dd293b40578ccornelius * @param status the error code - any conversion or format errors
17459d709d503bab6e2b61931737e662dd293b40578ccornelius * @return the value
175f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
17659d709d503bab6e2b61931737e662dd293b40578ccornelius * @see icu::Formattable::getLong(UErrorCode&) const
17759d709d503bab6e2b61931737e662dd293b40578ccornelius */
178f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusU_STABLE int32_t U_EXPORT2
17959d709d503bab6e2b61931737e662dd293b40578ccorneliusufmt_getLong(UFormattable* fmt, UErrorCode *status);
18059d709d503bab6e2b61931737e662dd293b40578ccornelius
18159d709d503bab6e2b61931737e662dd293b40578ccornelius
18259d709d503bab6e2b61931737e662dd293b40578ccornelius/**
18359d709d503bab6e2b61931737e662dd293b40578ccornelius * Gets the int64_t value of this object. If this object is of a numeric
18459d709d503bab6e2b61931737e662dd293b40578ccornelius * type and the magnitude is too large to fit in an int64, then
18559d709d503bab6e2b61931737e662dd293b40578ccornelius * the maximum or minimum int64 value, as appropriate, is returned
18659d709d503bab6e2b61931737e662dd293b40578ccornelius * and the status is set to U_INVALID_FORMAT_ERROR.  If the
18759d709d503bab6e2b61931737e662dd293b40578ccornelius * magnitude fits in an int64, then a casting conversion is
18859d709d503bab6e2b61931737e662dd293b40578ccornelius * peformed, with truncation of any fractional part.  If the type
18959d709d503bab6e2b61931737e662dd293b40578ccornelius * is UFMT_OBJECT and the object is a Measure, then the result of
19059d709d503bab6e2b61931737e662dd293b40578ccornelius * getNumber().getDouble(status) is returned.  If this object is
19159d709d503bab6e2b61931737e662dd293b40578ccornelius * neither a numeric type nor a Measure, then 0 is returned and
19259d709d503bab6e2b61931737e662dd293b40578ccornelius * the status is set to U_INVALID_FORMAT_ERROR.
19359d709d503bab6e2b61931737e662dd293b40578ccornelius * @param fmt the UFormattable object
19459d709d503bab6e2b61931737e662dd293b40578ccornelius * @param status the error code - any conversion or format errors
19559d709d503bab6e2b61931737e662dd293b40578ccornelius * @return the value
196f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
19759d709d503bab6e2b61931737e662dd293b40578ccornelius * @see icu::Formattable::getInt64(UErrorCode&) const
19859d709d503bab6e2b61931737e662dd293b40578ccornelius */
199f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusU_STABLE int64_t U_EXPORT2
20059d709d503bab6e2b61931737e662dd293b40578ccorneliusufmt_getInt64(UFormattable* fmt, UErrorCode *status);
20159d709d503bab6e2b61931737e662dd293b40578ccornelius
20259d709d503bab6e2b61931737e662dd293b40578ccornelius/**
20359d709d503bab6e2b61931737e662dd293b40578ccornelius * Returns a pointer to the UObject contained within this
20459d709d503bab6e2b61931737e662dd293b40578ccornelius * formattable (as a const void*), or NULL if this object
20559d709d503bab6e2b61931737e662dd293b40578ccornelius * is not of type UFMT_OBJECT.
20659d709d503bab6e2b61931737e662dd293b40578ccornelius * @param fmt the UFormattable object
20759d709d503bab6e2b61931737e662dd293b40578ccornelius * @param status the error code - any conversion or format errors
20859d709d503bab6e2b61931737e662dd293b40578ccornelius * @return the value as a const void*. It is a polymorphic C++ object.
209f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
21059d709d503bab6e2b61931737e662dd293b40578ccornelius * @see icu::Formattable::getObject() const
21159d709d503bab6e2b61931737e662dd293b40578ccornelius */
212f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusU_STABLE const void *U_EXPORT2
21359d709d503bab6e2b61931737e662dd293b40578ccorneliusufmt_getObject(const UFormattable* fmt, UErrorCode *status);
21459d709d503bab6e2b61931737e662dd293b40578ccornelius
21559d709d503bab6e2b61931737e662dd293b40578ccornelius/**
21659d709d503bab6e2b61931737e662dd293b40578ccornelius * Gets the string value of this object as a UChar string. If the type is not a
21759d709d503bab6e2b61931737e662dd293b40578ccornelius * string, status is set to U_INVALID_FORMAT_ERROR and a NULL pointer is returned.
21859d709d503bab6e2b61931737e662dd293b40578ccornelius * This function is not thread safe and may modify the UFormattable if need be to terminate the string.
21959d709d503bab6e2b61931737e662dd293b40578ccornelius * The returned pointer is not valid if any other functions are called on this UFormattable, or if the UFormattable is closed.
22059d709d503bab6e2b61931737e662dd293b40578ccornelius * @param fmt the UFormattable object
22159d709d503bab6e2b61931737e662dd293b40578ccornelius * @param status the error code - any conversion or format errors
22259d709d503bab6e2b61931737e662dd293b40578ccornelius * @param len if non null, contains the string length on return
22359d709d503bab6e2b61931737e662dd293b40578ccornelius * @return the null terminated string value - must not be referenced after any other functions are called on this UFormattable.
224f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
22559d709d503bab6e2b61931737e662dd293b40578ccornelius * @see icu::Formattable::getString(UnicodeString&)const
22659d709d503bab6e2b61931737e662dd293b40578ccornelius */
227f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusU_STABLE const UChar* U_EXPORT2
22859d709d503bab6e2b61931737e662dd293b40578ccorneliusufmt_getUChars(UFormattable* fmt, int32_t *len, UErrorCode *status);
22959d709d503bab6e2b61931737e662dd293b40578ccornelius
23059d709d503bab6e2b61931737e662dd293b40578ccornelius/**
23159d709d503bab6e2b61931737e662dd293b40578ccornelius * Get the number of array objects contained, if an array type UFMT_ARRAY
23259d709d503bab6e2b61931737e662dd293b40578ccornelius * @param fmt the UFormattable object
23359d709d503bab6e2b61931737e662dd293b40578ccornelius * @param status the error code - any conversion or format errors. U_ILLEGAL_ARGUMENT_ERROR if not an array type.
23459d709d503bab6e2b61931737e662dd293b40578ccornelius * @return the number of array objects or undefined if not an array type
235f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
23659d709d503bab6e2b61931737e662dd293b40578ccornelius * @see ufmt_getArrayItemByIndex
23759d709d503bab6e2b61931737e662dd293b40578ccornelius */
238f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusU_STABLE int32_t U_EXPORT2
23959d709d503bab6e2b61931737e662dd293b40578ccorneliusufmt_getArrayLength(const UFormattable* fmt, UErrorCode *status);
24059d709d503bab6e2b61931737e662dd293b40578ccornelius
24159d709d503bab6e2b61931737e662dd293b40578ccornelius/**
24259d709d503bab6e2b61931737e662dd293b40578ccornelius * Get the specified value from the array of UFormattables. Invalid if the object is not an array type UFMT_ARRAY
24359d709d503bab6e2b61931737e662dd293b40578ccornelius * @param fmt the UFormattable object
24459d709d503bab6e2b61931737e662dd293b40578ccornelius * @param n the number of the array to return (0 based).
24559d709d503bab6e2b61931737e662dd293b40578ccornelius * @param status the error code - any conversion or format errors. Returns an error if n is out of bounds.
24659d709d503bab6e2b61931737e662dd293b40578ccornelius * @return the nth array value, only valid while the containing UFormattable is valid. NULL if not an array.
247f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
24859d709d503bab6e2b61931737e662dd293b40578ccornelius * @see icu::Formattable::getArray(int32_t&, UErrorCode&) const
24959d709d503bab6e2b61931737e662dd293b40578ccornelius */
250f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusU_STABLE UFormattable * U_EXPORT2
25159d709d503bab6e2b61931737e662dd293b40578ccorneliusufmt_getArrayItemByIndex(UFormattable* fmt, int32_t n, UErrorCode *status);
25259d709d503bab6e2b61931737e662dd293b40578ccornelius
25359d709d503bab6e2b61931737e662dd293b40578ccornelius/**
25459d709d503bab6e2b61931737e662dd293b40578ccornelius * Returns a numeric string representation of the number contained within this
25559d709d503bab6e2b61931737e662dd293b40578ccornelius * formattable, or NULL if this object does not contain numeric type.
25659d709d503bab6e2b61931737e662dd293b40578ccornelius * For values obtained by parsing, the returned decimal number retains
25759d709d503bab6e2b61931737e662dd293b40578ccornelius * the full precision and range of the original input, unconstrained by
25859d709d503bab6e2b61931737e662dd293b40578ccornelius * the limits of a double floating point or a 64 bit int.
25959d709d503bab6e2b61931737e662dd293b40578ccornelius *
26059d709d503bab6e2b61931737e662dd293b40578ccornelius * This function is not thread safe, and therfore is not declared const,
26159d709d503bab6e2b61931737e662dd293b40578ccornelius * even though it is logically const.
26259d709d503bab6e2b61931737e662dd293b40578ccornelius * The resulting buffer is owned by the UFormattable and is invalid if any other functions are
26359d709d503bab6e2b61931737e662dd293b40578ccornelius * called on the UFormattable.
26459d709d503bab6e2b61931737e662dd293b40578ccornelius *
26559d709d503bab6e2b61931737e662dd293b40578ccornelius * Possible errors include U_MEMORY_ALLOCATION_ERROR, and
26659d709d503bab6e2b61931737e662dd293b40578ccornelius * U_INVALID_STATE if the formattable object has not been set to
26759d709d503bab6e2b61931737e662dd293b40578ccornelius * a numeric type.
26859d709d503bab6e2b61931737e662dd293b40578ccornelius * @param fmt the UFormattable object
26959d709d503bab6e2b61931737e662dd293b40578ccornelius * @param len if non-null, on exit contains the string length (not including the terminating null)
27059d709d503bab6e2b61931737e662dd293b40578ccornelius * @param status the error code
27159d709d503bab6e2b61931737e662dd293b40578ccornelius * @return the character buffer as a NULL terminated string, which is owned by the object and must not be accessed if any other functions are called on this object.
272f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * @stable ICU 52
27359d709d503bab6e2b61931737e662dd293b40578ccornelius * @see icu::Formattable::getDecimalNumber(UErrorCode&)
27459d709d503bab6e2b61931737e662dd293b40578ccornelius */
275f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusU_STABLE const char * U_EXPORT2
27659d709d503bab6e2b61931737e662dd293b40578ccorneliusufmt_getDecNumChars(UFormattable *fmt, int32_t *len, UErrorCode *status);
27759d709d503bab6e2b61931737e662dd293b40578ccornelius
27859d709d503bab6e2b61931737e662dd293b40578ccornelius#endif
27959d709d503bab6e2b61931737e662dd293b40578ccornelius
28059d709d503bab6e2b61931737e662dd293b40578ccornelius#endif
281