ICU-7912 add parse/format functions, other UFormattable API improvements

X-SVN-Rev: 33894
This commit is contained in:
Steven R. Loomis 2013-07-09 00:47:46 +00:00
parent dd57b2dc24
commit 06dcb5d4a6
4 changed files with 25 additions and 24 deletions

View file

@ -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<Formattable *>(fmt);
}
inline const Formattable* Formattable::fromUFormattable(const UFormattable *fmt) {
return reinterpret_cast<const Formattable *>(fmt);
}
U_NAMESPACE_END

View file

@ -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.

View file

@ -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

View file

@ -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 */