]> granicus.if.org Git - icu/commitdiff
ICU-7912 add parse/format functions, other UFormattable API improvements
authorSteven R. Loomis <srl@icu-project.org>
Tue, 9 Jul 2013 00:47:46 +0000 (00:47 +0000)
committerSteven R. Loomis <srl@icu-project.org>
Tue, 9 Jul 2013 00:47:46 +0000 (00:47 +0000)
X-SVN-Rev: 33894

icu4c/source/i18n/unicode/fmtable.h
icu4c/source/i18n/unicode/uformattable.h
icu4c/source/i18n/unicode/unum.h
icu4c/source/i18n/unum.cpp

index d4cfccc76f29510ea08376bb3da47b5a291275c5..80d27add9446693ed39834689d59fb56cdbc7368 100644 (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
 
index 5027057b4990e6c82b3cf230993c267a598e0d18..19b92a06847a9a76b7456aa03742069fdd73f253 100644 (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.
index a3e4c578456619bc81f65a64977944c20205fbce..db84ac5c1bb09c4211f041746a3a3a0c97ead4a1 100644 (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
index 079a6b9b05c878bef1731b84154c7d1c494016f2..f65081b1445c77b2b9fc776f5a51b111e3723d2f 100644 (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 */