ICU-13597 Replying to UNumberFormatter code recatew comments.
X-SVN-Rev: 41321
This commit is contained in:
parent
23bacf40c8
commit
a52fcd20f2
@ -9,8 +9,8 @@
|
|||||||
// Helpful in toString methods and elsewhere.
|
// Helpful in toString methods and elsewhere.
|
||||||
#define UNISTR_FROM_STRING_EXPLICIT
|
#define UNISTR_FROM_STRING_EXPLICIT
|
||||||
|
|
||||||
#include "numparse_types.h"
|
|
||||||
#include "number_utypes.h"
|
#include "number_utypes.h"
|
||||||
|
#include "numparse_types.h"
|
||||||
#include "unicode/numberformatter.h"
|
#include "unicode/numberformatter.h"
|
||||||
#include "unicode/unumberformatter.h"
|
#include "unicode/unumberformatter.h"
|
||||||
|
|
||||||
@ -159,14 +159,14 @@ unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t buf
|
|||||||
|
|
||||||
U_CAPI UBool U_EXPORT2
|
U_CAPI UBool U_EXPORT2
|
||||||
unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* ufpos, UErrorCode* ec) {
|
unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* ufpos, UErrorCode* ec) {
|
||||||
|
const UFormattedNumberData* result = UFormattedNumberData::validate(uresult, *ec);
|
||||||
|
if (U_FAILURE(*ec)) { return FALSE; }
|
||||||
|
|
||||||
if (ufpos == nullptr) {
|
if (ufpos == nullptr) {
|
||||||
*ec = U_ILLEGAL_ARGUMENT_ERROR;
|
*ec = U_ILLEGAL_ARGUMENT_ERROR;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const UFormattedNumberData* result = UFormattedNumberData::validate(uresult, *ec);
|
|
||||||
if (U_FAILURE(*ec)) { return FALSE; }
|
|
||||||
|
|
||||||
FieldPosition fp;
|
FieldPosition fp;
|
||||||
fp.setField(ufpos->field);
|
fp.setField(ufpos->field);
|
||||||
fp.setBeginIndex(ufpos->beginIndex);
|
fp.setBeginIndex(ufpos->beginIndex);
|
||||||
@ -181,14 +181,14 @@ unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* u
|
|||||||
U_CAPI void U_EXPORT2
|
U_CAPI void U_EXPORT2
|
||||||
unumf_resultGetAllFieldPositions(const UFormattedNumber* uresult, UFieldPositionIterator* ufpositer,
|
unumf_resultGetAllFieldPositions(const UFormattedNumber* uresult, UFieldPositionIterator* ufpositer,
|
||||||
UErrorCode* ec) {
|
UErrorCode* ec) {
|
||||||
|
const UFormattedNumberData* result = UFormattedNumberData::validate(uresult, *ec);
|
||||||
|
if (U_FAILURE(*ec)) { return; }
|
||||||
|
|
||||||
if (ufpositer == nullptr) {
|
if (ufpositer == nullptr) {
|
||||||
*ec = U_ILLEGAL_ARGUMENT_ERROR;
|
*ec = U_ILLEGAL_ARGUMENT_ERROR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const UFormattedNumberData* result = UFormattedNumberData::validate(uresult, *ec);
|
|
||||||
if (U_FAILURE(*ec)) { return; }
|
|
||||||
|
|
||||||
auto* helper = reinterpret_cast<FieldPositionIterator*>(ufpositer);
|
auto* helper = reinterpret_cast<FieldPositionIterator*>(ufpositer);
|
||||||
result->string.getAllFieldPositions(*helper, *ec);
|
result->string.getAllFieldPositions(*helper, *ec);
|
||||||
}
|
}
|
||||||
@ -197,7 +197,6 @@ U_CAPI void U_EXPORT2
|
|||||||
unumf_closeResult(UFormattedNumber* uresult) {
|
unumf_closeResult(UFormattedNumber* uresult) {
|
||||||
UErrorCode localStatus = U_ZERO_ERROR;
|
UErrorCode localStatus = U_ZERO_ERROR;
|
||||||
const UFormattedNumberData* impl = UFormattedNumberData::validate(uresult, localStatus);
|
const UFormattedNumberData* impl = UFormattedNumberData::validate(uresult, localStatus);
|
||||||
if (U_FAILURE(localStatus)) { return; }
|
|
||||||
delete impl;
|
delete impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +204,6 @@ U_CAPI void U_EXPORT2
|
|||||||
unumf_close(UNumberFormatter* f) {
|
unumf_close(UNumberFormatter* f) {
|
||||||
UErrorCode localStatus = U_ZERO_ERROR;
|
UErrorCode localStatus = U_ZERO_ERROR;
|
||||||
const UNumberFormatterData* impl = UNumberFormatterData::validate(f, localStatus);
|
const UNumberFormatterData* impl = UNumberFormatterData::validate(f, localStatus);
|
||||||
if (U_FAILURE(localStatus)) { return; }
|
|
||||||
delete impl;
|
delete impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ static const UChar LOW_W = ((UChar) 0x0077);
|
|||||||
static const UChar LOW_Y = ((UChar) 0x0079);
|
static const UChar LOW_Y = ((UChar) 0x0079);
|
||||||
static const UChar LOW_Z = ((UChar) 0x007A);
|
static const UChar LOW_Z = ((UChar) 0x007A);
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
static const int32_t PLURAL_RANGE_HIGH = 0x7fffffff;
|
static const int32_t PLURAL_RANGE_HIGH = 0x7fffffff;
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
#include "unicode/fieldpos.h"
|
#include "unicode/fieldpos.h"
|
||||||
#include "unicode/fpositer.h"
|
#include "unicode/fpositer.h"
|
||||||
#include "unicode/measunit.h"
|
#include "unicode/measunit.h"
|
||||||
#include "unicode/unumberformatter.h"
|
|
||||||
#include "unicode/nounit.h"
|
#include "unicode/nounit.h"
|
||||||
#include "unicode/plurrule.h"
|
#include "unicode/plurrule.h"
|
||||||
#include "unicode/ucurr.h"
|
#include "unicode/ucurr.h"
|
||||||
#include "unicode/unum.h"
|
#include "unicode/unum.h"
|
||||||
|
#include "unicode/unumberformatter.h"
|
||||||
#include "unicode/uobject.h"
|
#include "unicode/uobject.h"
|
||||||
|
|
||||||
#ifndef U_HIDE_DRAFT_API
|
#ifndef U_HIDE_DRAFT_API
|
||||||
|
@ -76,7 +76,8 @@ static void TestSkeletonFormatToFields() {
|
|||||||
// setup:
|
// setup:
|
||||||
UNumberFormatter* uformatter = unumf_openFromSkeletonAndLocale(
|
UNumberFormatter* uformatter = unumf_openFromSkeletonAndLocale(
|
||||||
u".00 measure-unit/length-meter sign-always", -1, "en", &ec);
|
u".00 measure-unit/length-meter sign-always", -1, "en", &ec);
|
||||||
assertSuccess("Should create without error", &ec);
|
assertSuccessCheck("Should create without error", &ec, TRUE);
|
||||||
|
if (U_FAILURE(ec)) { return; }
|
||||||
UFormattedNumber* uresult = unumf_openResult(&ec);
|
UFormattedNumber* uresult = unumf_openResult(&ec);
|
||||||
assertSuccess("Should create result without error", &ec);
|
assertSuccess("Should create result without error", &ec);
|
||||||
unumf_formatInt(uformatter, 9876543210L, uresult, &ec); // "+9,876,543,210.00 m"
|
unumf_formatInt(uformatter, 9876543210L, uresult, &ec); // "+9,876,543,210.00 m"
|
||||||
@ -154,7 +155,8 @@ static void TestExampleCode() {
|
|||||||
UErrorCode ec = U_ZERO_ERROR;
|
UErrorCode ec = U_ZERO_ERROR;
|
||||||
UNumberFormatter* uformatter = unumf_openFromSkeletonAndLocale(u"round-integer", -1, "en", &ec);
|
UNumberFormatter* uformatter = unumf_openFromSkeletonAndLocale(u"round-integer", -1, "en", &ec);
|
||||||
UFormattedNumber* uresult = unumf_openResult(&ec);
|
UFormattedNumber* uresult = unumf_openResult(&ec);
|
||||||
assertSuccess("There should not be a failure in the example code", &ec);
|
assertSuccessCheck("There should not be a failure in the example code", &ec, TRUE);
|
||||||
|
if (U_FAILURE(ec)) { return; }
|
||||||
|
|
||||||
// Format a double:
|
// Format a double:
|
||||||
unumf_formatDouble(uformatter, 5142.3, uresult, &ec);
|
unumf_formatDouble(uformatter, 5142.3, uresult, &ec);
|
||||||
|
@ -2374,7 +2374,8 @@ void NumberFormatterApiTest::localPointerCAPI() {
|
|||||||
// Setup:
|
// Setup:
|
||||||
LocalUNumberFormatterPointer uformatter(unumf_openFromSkeletonAndLocale(u"percent", -1, "en", &ec));
|
LocalUNumberFormatterPointer uformatter(unumf_openFromSkeletonAndLocale(u"percent", -1, "en", &ec));
|
||||||
LocalUFormattedNumberPointer uresult(unumf_openResult(&ec));
|
LocalUFormattedNumberPointer uresult(unumf_openResult(&ec));
|
||||||
assertSuccess("", ec);
|
assertSuccess("", ec, TRUE);
|
||||||
|
if (U_FAILURE(ec)) { return; }
|
||||||
|
|
||||||
// Format a decimal number:
|
// Format a decimal number:
|
||||||
unumf_formatDecimal(uformatter.getAlias(), "9.87E-3", -1, uresult.getAlias(), &ec);
|
unumf_formatDecimal(uformatter.getAlias(), "9.87E-3", -1, uresult.getAlias(), &ec);
|
||||||
|
Loading…
Reference in New Issue
Block a user