X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..ef6cf650f4a75c3f97de06b51fa104f2069b9ea2:/icuSources/samples/numfmt/main.cpp?ds=sidebyside diff --git a/icuSources/samples/numfmt/main.cpp b/icuSources/samples/numfmt/main.cpp index b57a57c0..ee375ff7 100644 --- a/icuSources/samples/numfmt/main.cpp +++ b/icuSources/samples/numfmt/main.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1999-2003, International Business Machines Corporation and + * Copyright (c) 1999-2014, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -16,8 +16,6 @@ #include #include -#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) - extern "C" void capi(); void cppapi(); @@ -113,7 +111,8 @@ setNumberFormatCurrency_2_4(NumberFormat &nf, const char *currency, UErrorCode & // check that the formatter is a DecimalFormat instance // necessary because we will cast to the DecimalFormat subclass to set // the currency symbol - if(nf.getDynamicClassID()!=DecimalFormat::getStaticClassID()) { + DecimalFormat *dnf=dynamic_cast(&nf); + if(dnf==NULL) { errorCode=U_ILLEGAL_ARGUMENT_ERROR; return; } @@ -152,12 +151,12 @@ setNumberFormatCurrency_2_4(NumberFormat &nf, const char *currency, UErrorCode & int32_t i; - for(i=0; isetRoundingIncrement(currencyMap[i].roundingIncrement); - DecimalFormatSymbols symbols(*dnf.getDecimalFormatSymbols()); + DecimalFormatSymbols symbols(*dnf->getDecimalFormatSymbols()); symbols.setSymbol(DecimalFormatSymbols::kCurrencySymbol, currencyMap[i].symbol); - dnf.setDecimalFormatSymbols(symbols); // do not adopt symbols: Jitterbug 2889 + dnf->setDecimalFormatSymbols(symbols); // do not adopt symbols: Jitterbug 2889 } /* @@ -203,7 +201,12 @@ setNumberFormatCurrency_2_6(NumberFormat &nf, const char *currency, UErrorCode & u_charsToUChars(currency, uCurrency, 4); // set the currency + // in ICU 3.0 this API (which was @draft ICU 2.6) gained a UErrorCode& argument +#if (U_ICU_VERSION_MAJOR_NUM < 3) nf.setCurrency(uCurrency); +#else + nf.setCurrency(uCurrency, errorCode); +#endif } static const char *const @@ -230,7 +233,7 @@ showCurrencyFormatting(UBool useICU26API) { // TODO: Using printf() here assumes that the runtime encoding is ASCII-friendly // and can therefore be mixed with UTF-8 - for(i=0; i