]> granicus.if.org Git - icu/commitdiff
ICU-7912 more review comments
authorSteven R. Loomis <srl@icu-project.org>
Fri, 20 Sep 2013 21:17:16 +0000 (21:17 +0000)
committerSteven R. Loomis <srl@icu-project.org>
Fri, 20 Sep 2013 21:17:16 +0000 (21:17 +0000)
X-SVN-Rev: 34428

icu4c/source/i18n/fmtable.cpp
icu4c/source/i18n/unicode/fmtable.h
icu4c/source/i18n/unicode/unum.h
icu4c/source/test/cintltst/cnumtst.c

index 2454337f2b6663b054e941ea51199360e60ce197..87d6a4ca30b387118cb4f9c4ed842e8e57c19bb9 100644 (file)
@@ -922,7 +922,7 @@ ufmt_close(UFormattable *fmt) {
 U_INTERNAL UFormattableType U_EXPORT2
 ufmt_getType(const UFormattable *fmt, UErrorCode *status) {
   if(U_FAILURE(*status)) {
-    return (UFormattableType)-1;
+    return (UFormattableType)UFMT_COUNT;
   }
   const Formattable *obj = Formattable::fromUFormattable(fmt);
   return (UFormattableType)obj->getType();
index e4a11c0cee30dad568329a7520e2bee65c473aad..9a9d5b56b30ad3c67ad4dcb635db521b5c77cedd 100644 (file)
@@ -624,6 +624,14 @@ public:
      */
     inline UFormattable *toUFormattable();
 
+    /**
+     * Convert this object pointer to a UFormattable.
+     * @return this object as a UFormattable pointer.   This is an alias to this object,
+     * and so is only valid while this object remains in scope.
+     * @draft ICU 52
+     */
+    inline const UFormattable *toUFormattable() const;
+
 #ifndef U_HIDE_DEPRECATED_API
     /**
      * Deprecated variant of getLong(UErrorCode&).
@@ -732,6 +740,10 @@ inline UFormattable* Formattable::toUFormattable() {
   return reinterpret_cast<UFormattable*>(this);
 }
 
+inline const UFormattable* Formattable::toUFormattable() const {
+  return reinterpret_cast<const UFormattable*>(this);
+}
+
 inline Formattable* Formattable::fromUFormattable(UFormattable *fmt) {
   return reinterpret_cast<Formattable *>(fmt);
 }
index 5efb555b0d46fee51d660f6d2b596f9a763521f6..2635b6dfc9e9be0483201d345dc61e0a98fff843 100644 (file)
@@ -596,8 +596,8 @@ unum_formatUFormattable(const UNumberFormat* fmt,
 * @param fmt The formatter to use.
 * @param text The text to parse.
 * @param textLength The length of text, or -1 if null-terminated.
-* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which
-* to begin parsing.  If not 0, on output the offset at which parsing ended.
+* @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which
+* to begin parsing.  If not NULL, on output the offset at which parsing ended.
 * @param status A pointer to an UErrorCode to receive any errors
 * @return The value of the parsed integer
 * @see unum_parseInt64
@@ -620,8 +620,8 @@ unum_parse(    const   UNumberFormat*  fmt,
 * @param fmt The formatter to use.
 * @param text The text to parse.
 * @param textLength The length of text, or -1 if null-terminated.
-* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which
-* to begin parsing.  If not 0, on output the offset at which parsing ended.
+* @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which
+* to begin parsing.  If not NULL, on output the offset at which parsing ended.
 * @param status A pointer to an UErrorCode to receive any errors
 * @return The value of the parsed integer
 * @see unum_parse
@@ -644,8 +644,8 @@ unum_parseInt64(const UNumberFormat*  fmt,
 * @param fmt The formatter to use.
 * @param text The text to parse.
 * @param textLength The length of text, or -1 if null-terminated.
-* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which
-* to begin parsing.  If not 0, on output the offset at which parsing ended.
+* @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which
+* to begin parsing.  If not NULL, on output the offset at which parsing ended.
 * @param status A pointer to an UErrorCode to receive any errors
 * @return The value of the parsed double
 * @see unum_parse
@@ -672,8 +672,8 @@ unum_parseDouble(    const   UNumberFormat*  fmt,
 * @param fmt The formatter to use.
 * @param text The text to parse.
 * @param textLength The length of text, or -1 if null-terminated.
-* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which
-*                 to begin parsing.  If not 0, on output the offset at which parsing ended.
+* @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which
+*                 to begin parsing.  If not NULL, on output the offset at which parsing ended.
 * @param outBuf A (char *) buffer to receive the parsed number as a string.  The output string
 *               will be nul-terminated if there is sufficient space.
 * @param outBufLength The size of the output buffer.  May be zero, in which case
@@ -705,7 +705,7 @@ unum_parseDecimal(const   UNumberFormat*  fmt,
  * @param textLength the length of text, or -1 if null-terminated
  * @param parsePos a pointer to an offset index into text at which to
  * begin parsing. On output, *parsePos will point after the last
- * parsed character.  This parameter may be 0, in which case parsing
+ * parsed character.  This parameter may be NULL, in which case parsing
  * begins at offset 0.
  * @param currency a pointer to the buffer to receive the parsed null-
  * terminated currency.  This buffer must have a capacity of at least
@@ -734,7 +734,7 @@ unum_parseDoubleCurrency(const UNumberFormat* fmt,
  * @param textLength the length of text, or -1 if null-terminated
  * @param parsePos a pointer to an offset index into text at which to
  * begin parsing. On output, *parsePos will point after the last
- * parsed character.  This parameter may be 0, in which case parsing
+ * parsed character.  This parameter may be NULL in which case parsing
  * begins at offset 0.
  * @param status a pointer to an input-output UErrorCode
  * @return the UFormattable.  Will be ==result unless NULL was passed in for result, in which case it will be the newly opened UFormattable.
index 23671c554c1c45d9b3fe5645947c5a593d5db8f1..4a8f366d1db672973078681fabef3ee980fdb131 100644 (file)
@@ -2219,7 +2219,7 @@ static void TestUFormattable(void) {
       log_verbose("-- pattern: %s\n", pattern);
       u_uastrcpy(buffer, pattern);
       unum_parseToUFormattable(unum, ufmt, buffer, -1, NULL, &status);
-      if(assertSuccess("unum_parseToUFormattable[31337]", &status)) {
+      if(assertSuccess("unum_parseToUFormattable(31337)", &status)) {
         assertTrue("ufmt_getLong()=31337", ufmt_getLong(ufmt, &status) == 31337);
         assertTrue("ufmt_getType()=UFMT_LONG", ufmt_getType(ufmt, &status) == UFMT_LONG);
         log_verbose("long = %d\n", ufmt_getLong(ufmt, &status));
@@ -2234,7 +2234,7 @@ static void TestUFormattable(void) {
       log_verbose("-- pattern: %s\n", pattern);
       u_uastrcpy(buffer, pattern);
       unum_parseToUFormattable(unum, ufmt, buffer, -1, NULL, &status);
-      if(assertSuccess("unum_parseToUFormattable[3.14159]", &status)) {
+      if(assertSuccess("unum_parseToUFormattable(3.14159)", &status)) {
         assertTrue("ufmt_getDouble()==3.14159", withinErr(ufmt_getDouble(ufmt, &status), 3.14159, 1e-15));
         assertSuccess("ufmt_getDouble()", &status);
         assertTrue("ufmt_getType()=UFMT_DOUBLE", ufmt_getType(ufmt, &status) == UFMT_DOUBLE);