LEFT | RIGHT |
(no file at all) | |
1 // © 2017 and later: Unicode, Inc. and others. | 1 // © 2017 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html | 2 // License & terms of use: http://www.unicode.org/copyright.html |
3 | 3 |
4 #include "unicode/utypes.h" | 4 #include "unicode/utypes.h" |
5 | 5 |
6 #if !UCONFIG_NO_FORMATTING && !UPRV_INCOMPLETE_CPP11_SUPPORT | 6 #if !UCONFIG_NO_FORMATTING && !UPRV_INCOMPLETE_CPP11_SUPPORT |
7 | 7 |
8 #include "uassert.h" | 8 #include "uassert.h" |
9 #include "unicode/numberformatter.h" | 9 #include "unicode/numberformatter.h" |
10 #include "number_decimalquantity.h" | 10 #include "number_decimalquantity.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 template<typename Derived> | 35 template<typename Derived> |
36 Derived NumberFormatterSettings<Derived>::adoptUnit(const icu::MeasureUnit *unit
) const { | 36 Derived NumberFormatterSettings<Derived>::adoptUnit(const icu::MeasureUnit *unit
) const { |
37 Derived copy(*this); | 37 Derived copy(*this); |
38 // Just copy the unit into the MacroProps by value, and delete it since we h
ave ownership. | 38 // Just copy the unit into the MacroProps by value, and delete it since we h
ave ownership. |
39 // NOTE: Slicing occurs here. However, CurrencyUnit can be restored from Mea
sureUnit. | 39 // NOTE: Slicing occurs here. However, CurrencyUnit can be restored from Mea
sureUnit. |
40 // TimeUnit may be affected, but TimeUnit is not as relevant to number forma
tting. | 40 // TimeUnit may be affected, but TimeUnit is not as relevant to number forma
tting. |
41 if (unit != nullptr) { | 41 if (unit != nullptr) { |
42 copy.fMacros.unit = *unit; | 42 copy.fMacros.unit = *unit; |
43 delete unit; | 43 delete unit; |
| 44 } |
| 45 return copy; |
| 46 } |
| 47 |
| 48 template<typename Derived> |
| 49 Derived NumberFormatterSettings<Derived>::perUnit(const icu::MeasureUnit &perUni
t) const { |
| 50 Derived copy(*this); |
| 51 // See comments above about slicing. |
| 52 copy.fMacros.perUnit = perUnit; |
| 53 return copy; |
| 54 } |
| 55 |
| 56 template<typename Derived> |
| 57 Derived NumberFormatterSettings<Derived>::adoptPerUnit(const icu::MeasureUnit *p
erUnit) const { |
| 58 Derived copy(*this); |
| 59 // See comments above about slicing and ownership. |
| 60 if (perUnit != nullptr) { |
| 61 copy.fMacros.perUnit = *perUnit; |
| 62 delete perUnit; |
44 } | 63 } |
45 return copy; | 64 return copy; |
46 } | 65 } |
47 | 66 |
48 template<typename Derived> | 67 template<typename Derived> |
49 Derived NumberFormatterSettings<Derived>::rounding(const Rounder &rounder) const
{ | 68 Derived NumberFormatterSettings<Derived>::rounding(const Rounder &rounder) const
{ |
50 Derived copy(*this); | 69 Derived copy(*this); |
51 // NOTE: Slicing is OK. | 70 // NOTE: Slicing is OK. |
52 copy.fMacros.rounder = rounder; | 71 copy.fMacros.rounder = rounder; |
53 return copy; | 72 return copy; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 return; | 379 return; |
361 } | 380 } |
362 fResults->string.populateFieldPositionIterator(iterator, status); | 381 fResults->string.populateFieldPositionIterator(iterator, status); |
363 } | 382 } |
364 | 383 |
365 FormattedNumber::~FormattedNumber() { | 384 FormattedNumber::~FormattedNumber() { |
366 delete fResults; | 385 delete fResults; |
367 } | 386 } |
368 | 387 |
369 #endif /* #if !UCONFIG_NO_FORMATTING */ | 388 #endif /* #if !UCONFIG_NO_FORMATTING */ |
LEFT | RIGHT |