From: Steven R. Loomis Date: Tue, 9 Jul 2013 00:47:46 +0000 (+0000) Subject: ICU-7912 add parse/format functions, other UFormattable API improvements X-Git-Tag: milestone-59-0-1~2788 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=06dcb5d4a6114c8b685233b0e5e2ef4fa6abf20d;p=icu ICU-7912 add parse/format functions, other UFormattable API improvements X-SVN-Rev: 33894 --- diff --git a/icu4c/source/i18n/unicode/fmtable.h b/icu4c/source/i18n/unicode/fmtable.h index d4cfccc76f2..80d27add944 100644 --- a/icu4c/source/i18n/unicode/fmtable.h +++ b/icu4c/source/i18n/unicode/fmtable.h @@ -607,6 +607,15 @@ public: */ static inline Formattable *fromUFormattable(UFormattable *fmt); + /** + * Convert the UFormattable to a Formattable. Internally, this is a reinterpret_cast. + * @param fmt a valid UFormattable + * @return the UFormattable as a Formattable object pointer. This is an alias to the original + * UFormattable, and so is only valid while the original argument remains in scope. + * @draft ICU 52 + */ + static inline const Formattable *fromUFormattable(const UFormattable *fmt); + /** * Convert this object pointer to a UFormattable. * @return this object as a UFormattable pointer. This is an alias to the original UFormattable, @@ -723,6 +732,10 @@ inline Formattable* Formattable::fromUFormattable(UFormattable *fmt) { return reinterpret_cast(fmt); } +inline const Formattable* Formattable::fromUFormattable(const UFormattable *fmt) { + return reinterpret_cast(fmt); +} + U_NAMESPACE_END diff --git a/icu4c/source/i18n/unicode/uformattable.h b/icu4c/source/i18n/unicode/uformattable.h index 5027057b499..19b92a06847 100644 --- a/icu4c/source/i18n/unicode/uformattable.h +++ b/icu4c/source/i18n/unicode/uformattable.h @@ -1,9 +1,3 @@ -/* -TODO -* copy C++ apidoc concerning error codes to appropriate wrapper functions -*/ - - /* ******************************************************************************** * Copyright (C) 2013, International Business Machines Corporation and others. @@ -15,7 +9,7 @@ TODO * Modification History: * * Date Name Description -* 2013 Jul 7 srl New +* 2013 Jun 7 srl New ******************************************************************************** */ @@ -101,27 +95,25 @@ U_NAMESPACE_END #endif -#ifndef U_HIDE_INTERNAL_API /** * Return the type of this object * @param fmt the UFormattable object * @status status code - U_ILLEGAL_ARGUMENT_ERROR is returned if the UFormattable contains data not supported by * the API * @return the value as a UFormattableType - * @internal + * @draft ICU 52 */ -U_INTERNAL UFormattableType U_EXPORT2 +U_DRAFT UFormattableType U_EXPORT2 ufmt_getType(UFormattable* fmt, UErrorCode *status); /** - * Return the type of this object + * Return whether the object is numeric. * @param fmt the UFormattable object * @return true if the object is a double, long, or int64 value. - * @internal + * @draft ICU 52 */ -U_INTERNAL UBool U_EXPORT2 +U_DRAFT UBool U_EXPORT2 ufmt_isNumeric(UFormattable* fmt); -#endif /** * Get the value as a date, converting if need be. diff --git a/icu4c/source/i18n/unicode/unum.h b/icu4c/source/i18n/unicode/unum.h index a3e4c578456..db84ac5c1bb 100644 --- a/icu4c/source/i18n/unicode/unum.h +++ b/icu4c/source/i18n/unicode/unum.h @@ -561,19 +561,17 @@ unum_formatDoubleCurrency(const UNumberFormat* fmt, UFieldPosition* pos, /* ignored if 0 */ UErrorCode* status); -#ifndef U_HIDE_INTERNAL_API /** * Format a UFormattable into a string - * @internal + * @draft ICU 52 */ -U_INTERNAL int32_t U_EXPORT2 +U_DRAFT int32_t U_EXPORT2 unum_formatUFormattable(const UNumberFormat* fmt, - UFormattable *number, + const UFormattable *number, UChar *result, int32_t resultLength, UFieldPosition *pos, /* ignored if 0 */ UErrorCode *status); -#endif /** * Parse a string into an integer using a UNumberFormat. @@ -709,20 +707,18 @@ unum_parseDoubleCurrency(const UNumberFormat* fmt, UChar* currency, UErrorCode* status); -#ifndef U_HIDE_INTERNAL_API /** * Parse into a UFormattable. * @param result - result formattable. Will be allocated with ufmt_open() first if NULL is passed in. - * @internal + * @draft ICU 52 */ -U_INTERNAL UFormattable* U_EXPORT2 +U_DRAFT UFormattable* U_EXPORT2 unum_parseToUFormattable(const UNumberFormat* fmt, UFormattable *result, const UChar* text, int32_t textLength, int32_t* parsePos, /* 0 = start */ UErrorCode* status); -#endif /** * Set the pattern used by a UNumberFormat. This can only be used diff --git a/icu4c/source/i18n/unum.cpp b/icu4c/source/i18n/unum.cpp index 079a6b9b05c..f65081b1445 100644 --- a/icu4c/source/i18n/unum.cpp +++ b/icu4c/source/i18n/unum.cpp @@ -802,7 +802,7 @@ unum_parseToUFormattable(const UNumberFormat* fmt, U_INTERNAL int32_t U_EXPORT2 unum_formatUFormattable(const UNumberFormat* fmt, - UFormattable *number, + const UFormattable *number, UChar *result, int32_t resultLength, UFieldPosition *pos, /* ignored if 0 */