| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************** | 2 ******************************************************************************** |
| 3 * Copyright (C) 2005-2014, International Business Machines | 3 * Copyright (C) 2005-2014, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
| 5 ******************************************************************************** | 5 ******************************************************************************** |
| 6 * | 6 * |
| 7 * File WINNMFMT.CPP | 7 * File WINNMFMT.CPP |
| 8 * | 8 * |
| 9 ******************************************************************************** | 9 ******************************************************************************** |
| 10 */ | 10 */ |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 return *this; | 202 return *this; |
| 203 } | 203 } |
| 204 | 204 |
| 205 Format *Win32NumberFormat::clone(void) const | 205 Format *Win32NumberFormat::clone(void) const |
| 206 { | 206 { |
| 207 return new Win32NumberFormat(*this); | 207 return new Win32NumberFormat(*this); |
| 208 } | 208 } |
| 209 | 209 |
| 210 UnicodeString& Win32NumberFormat::format(double number, UnicodeString& appendTo,
FieldPosition& pos) const | 210 UnicodeString& Win32NumberFormat::format(double number, UnicodeString& appendTo,
FieldPosition& pos) const |
| 211 { | 211 { |
| 212 return format(getMaximumFractionDigits(), appendTo, L"%.16f", number); | 212 return variadicFormat(getMaximumFractionDigits(), appendTo, L"%.16f", number
); |
| 213 } | 213 } |
| 214 | 214 |
| 215 UnicodeString& Win32NumberFormat::format(int32_t number, UnicodeString& appendTo
, FieldPosition& pos) const | 215 UnicodeString& Win32NumberFormat::format(int32_t number, UnicodeString& appendTo
, FieldPosition& pos) const |
| 216 { | 216 { |
| 217 return format(getMinimumFractionDigits(), appendTo, L"%I32d", number); | 217 return variadicFormat(getMinimumFractionDigits(), appendTo, L"%I32d", number
); |
| 218 } | 218 } |
| 219 | 219 |
| 220 UnicodeString& Win32NumberFormat::format(int64_t number, UnicodeString& appendTo
, FieldPosition& pos) const | 220 UnicodeString& Win32NumberFormat::format(int64_t number, UnicodeString& appendTo
, FieldPosition& pos) const |
| 221 { | 221 { |
| 222 return format(getMinimumFractionDigits(), appendTo, L"%I64d", number); | 222 return variadicFormat(getMinimumFractionDigits(), appendTo, L"%I64d", number
); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void Win32NumberFormat::parse(const UnicodeString& text, Formattable& result, Pa
rsePosition& parsePosition) const | 225 void Win32NumberFormat::parse(const UnicodeString& text, Formattable& result, Pa
rsePosition& parsePosition) const |
| 226 { | 226 { |
| 227 UErrorCode status = U_ZERO_ERROR; | 227 UErrorCode status = U_ZERO_ERROR; |
| 228 NumberFormat *nf = fCurrency? NumberFormat::createCurrencyInstance(fLocale,
status) : NumberFormat::createInstance(fLocale, status); | 228 NumberFormat *nf = fCurrency? NumberFormat::createCurrencyInstance(fLocale,
status) : NumberFormat::createInstance(fLocale, status); |
| 229 | 229 |
| 230 nf->parse(text, result, parsePosition); | 230 nf->parse(text, result, parsePosition); |
| 231 delete nf; | 231 delete nf; |
| 232 } | 232 } |
| 233 void Win32NumberFormat::setMaximumFractionDigits(int32_t newValue) | 233 void Win32NumberFormat::setMaximumFractionDigits(int32_t newValue) |
| 234 { | 234 { |
| 235 fFractionDigitsSet = TRUE; | 235 fFractionDigitsSet = TRUE; |
| 236 NumberFormat::setMaximumFractionDigits(newValue); | 236 NumberFormat::setMaximumFractionDigits(newValue); |
| 237 } | 237 } |
| 238 | 238 |
| 239 void Win32NumberFormat::setMinimumFractionDigits(int32_t newValue) | 239 void Win32NumberFormat::setMinimumFractionDigits(int32_t newValue) |
| 240 { | 240 { |
| 241 fFractionDigitsSet = TRUE; | 241 fFractionDigitsSet = TRUE; |
| 242 NumberFormat::setMinimumFractionDigits(newValue); | 242 NumberFormat::setMinimumFractionDigits(newValue); |
| 243 } | 243 } |
| 244 | 244 |
| 245 UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen
dTo, const wchar_t *fmt, ...) const | 245 UnicodeString &Win32NumberFormat::variadicFormat(int32_t numDigits, UnicodeStrin
g &appendTo, const wchar_t *fmt, ...) const |
| 246 { | 246 { |
| 247 wchar_t nStackBuffer[STACK_BUFFER_SIZE]; | 247 wchar_t nStackBuffer[STACK_BUFFER_SIZE]; |
| 248 wchar_t *nBuffer = nStackBuffer; | 248 wchar_t *nBuffer = nStackBuffer; |
| 249 va_list args; | 249 va_list args; |
| 250 int result; | 250 int result; |
| 251 | 251 |
| 252 nBuffer[0] = 0x0000; | 252 nBuffer[0] = 0x0000; |
| 253 | 253 |
| 254 /* Due to the arguments causing a result to be <= 23 characters (+2 for NULL
and minus), | 254 /* Due to the arguments causing a result to be <= 23 characters (+2 for NULL
and minus), |
| 255 we don't need to reallocate the buffer. */ | 255 we don't need to reallocate the buffer. */ |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 }*/ | 352 }*/ |
| 353 | 353 |
| 354 return appendTo; | 354 return appendTo; |
| 355 } | 355 } |
| 356 | 356 |
| 357 U_NAMESPACE_END | 357 U_NAMESPACE_END |
| 358 | 358 |
| 359 #endif /* #if !UCONFIG_NO_FORMATTING */ | 359 #endif /* #if !UCONFIG_NO_FORMATTING */ |
| 360 | 360 |
| 361 #endif // U_PLATFORM_USES_ONLY_WIN32_API | 361 #endif // U_PLATFORM_USES_ONLY_WIN32_API |
| OLD | NEW |