/src/icu/source/i18n/number_fluent.cpp
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | // © 2017 and later: Unicode, Inc. and others.  | 
2  |  | // License & terms of use: http://www.unicode.org/copyright.html  | 
3  |  |  | 
4  |  | #include "unicode/utypes.h"  | 
5  |  |  | 
6  |  | #if !UCONFIG_NO_FORMATTING  | 
7  |  |  | 
8  |  | #include "uassert.h"  | 
9  |  | #include "unicode/numberformatter.h"  | 
10  |  | #include "number_decimalquantity.h"  | 
11  |  | #include "number_formatimpl.h"  | 
12  |  | #include "umutex.h"  | 
13  |  | #include "number_asformat.h"  | 
14  |  | #include "number_utils.h"  | 
15  |  | #include "number_utypes.h"  | 
16  |  | #include "number_mapper.h"  | 
17  |  | #include "util.h"  | 
18  |  | #include "fphdlimp.h"  | 
19  |  |  | 
20  |  | using namespace icu;  | 
21  |  | using namespace icu::number;  | 
22  |  | using namespace icu::number::impl;  | 
23  |  |  | 
24  |  | #if (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN) && defined(_MSC_VER)  | 
25  |  | // Ignore MSVC warning 4661. This is generated for NumberFormatterSettings<>::toSkeleton() as this method  | 
26  |  | // is defined elsewhere (in number_skeletons.cpp). The compiler is warning that the explicit template instantiation  | 
27  |  | // inside this single translation unit (CPP file) is incomplete, and thus it isn't sure if the template class is  | 
28  |  | // fully defined. However, since each translation unit explicitly instantiates all the necessary template classes,  | 
29  |  | // they will all be passed to the linker, and the linker will still find and export all the class members.  | 
30  |  | #pragma warning(push)  | 
31  |  | #pragma warning(disable: 4661)  | 
32  |  | #endif  | 
33  |  |  | 
34  |  | template<typename Derived>  | 
35  | 0  | Derived NumberFormatterSettings<Derived>::notation(const Notation& notation) const& { | 
36  | 0  |     Derived copy(*this);  | 
37  |  |     // NOTE: Slicing is OK.  | 
38  | 0  |     copy.fMacros.notation = notation;  | 
39  | 0  |     return copy;  | 
40  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::notation(icu_70::number::Notation const&) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::notation(icu_70::number::Notation const&) const &  | 
41  |  |  | 
42  |  | template<typename Derived>  | 
43  | 0  | Derived NumberFormatterSettings<Derived>::notation(const Notation& notation)&& { | 
44  | 0  |     Derived move(std::move(*this));  | 
45  |  |     // NOTE: Slicing is OK.  | 
46  | 0  |     move.fMacros.notation = notation;  | 
47  | 0  |     return move;  | 
48  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::notation(icu_70::number::Notation const&) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::notation(icu_70::number::Notation const&) &&  | 
49  |  |  | 
50  |  | template<typename Derived>  | 
51  | 0  | Derived NumberFormatterSettings<Derived>::unit(const icu::MeasureUnit& unit) const& { | 
52  | 0  |     Derived copy(*this);  | 
53  |  |     // NOTE: Slicing occurs here. However, CurrencyUnit can be restored from MeasureUnit.  | 
54  |  |     // TimeUnit may be affected, but TimeUnit is not as relevant to number formatting.  | 
55  | 0  |     copy.fMacros.unit = unit;  | 
56  | 0  |     return copy;  | 
57  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::unit(icu_70::MeasureUnit const&) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::unit(icu_70::MeasureUnit const&) const &  | 
58  |  |  | 
59  |  | template<typename Derived>  | 
60  | 0  | Derived NumberFormatterSettings<Derived>::unit(const icu::MeasureUnit& unit)&& { | 
61  | 0  |     Derived move(std::move(*this));  | 
62  |  |     // See comments above about slicing.  | 
63  | 0  |     move.fMacros.unit = unit;  | 
64  | 0  |     return move;  | 
65  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::unit(icu_70::MeasureUnit const&) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::unit(icu_70::MeasureUnit const&) &&  | 
66  |  |  | 
67  |  | template<typename Derived>  | 
68  | 0  | Derived NumberFormatterSettings<Derived>::adoptUnit(icu::MeasureUnit* unit) const& { | 
69  | 0  |     Derived copy(*this);  | 
70  |  |     // Just move the unit into the MacroProps by value, and delete it since we have ownership.  | 
71  |  |     // NOTE: Slicing occurs here. However, CurrencyUnit can be restored from MeasureUnit.  | 
72  |  |     // TimeUnit may be affected, but TimeUnit is not as relevant to number formatting.  | 
73  | 0  |     if (unit != nullptr) { | 
74  |  |         // TODO: On nullptr, reset to default value?  | 
75  | 0  |         copy.fMacros.unit = std::move(*unit);  | 
76  | 0  |         delete unit;  | 
77  | 0  |     }  | 
78  | 0  |     return copy;  | 
79  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::adoptUnit(icu_70::MeasureUnit*) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::adoptUnit(icu_70::MeasureUnit*) const &  | 
80  |  |  | 
81  |  | template<typename Derived>  | 
82  | 0  | Derived NumberFormatterSettings<Derived>::adoptUnit(icu::MeasureUnit* unit)&& { | 
83  | 0  |     Derived move(std::move(*this));  | 
84  |  |     // See comments above about slicing and ownership.  | 
85  | 0  |     if (unit != nullptr) { | 
86  |  |         // TODO: On nullptr, reset to default value?  | 
87  | 0  |         move.fMacros.unit = std::move(*unit);  | 
88  | 0  |         delete unit;  | 
89  | 0  |     }  | 
90  | 0  |     return move;  | 
91  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::adoptUnit(icu_70::MeasureUnit*) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::adoptUnit(icu_70::MeasureUnit*) &&  | 
92  |  |  | 
93  |  | template<typename Derived>  | 
94  | 0  | Derived NumberFormatterSettings<Derived>::perUnit(const icu::MeasureUnit& perUnit) const& { | 
95  | 0  |     Derived copy(*this);  | 
96  |  |     // See comments above about slicing.  | 
97  | 0  |     copy.fMacros.perUnit = perUnit;  | 
98  | 0  |     return copy;  | 
99  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::perUnit(icu_70::MeasureUnit const&) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::perUnit(icu_70::MeasureUnit const&) const &  | 
100  |  |  | 
101  |  | template<typename Derived>  | 
102  | 0  | Derived NumberFormatterSettings<Derived>::perUnit(const icu::MeasureUnit& perUnit)&& { | 
103  | 0  |     Derived move(std::move(*this));  | 
104  |  |     // See comments above about slicing.  | 
105  | 0  |     move.fMacros.perUnit = perUnit;  | 
106  | 0  |     return move;  | 
107  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::perUnit(icu_70::MeasureUnit const&) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::perUnit(icu_70::MeasureUnit const&) &&  | 
108  |  |  | 
109  |  | template<typename Derived>  | 
110  | 0  | Derived NumberFormatterSettings<Derived>::adoptPerUnit(icu::MeasureUnit* perUnit) const& { | 
111  | 0  |     Derived copy(*this);  | 
112  |  |     // See comments above about slicing and ownership.  | 
113  | 0  |     if (perUnit != nullptr) { | 
114  |  |         // TODO: On nullptr, reset to default value?  | 
115  | 0  |         copy.fMacros.perUnit = std::move(*perUnit);  | 
116  | 0  |         delete perUnit;  | 
117  | 0  |     }  | 
118  | 0  |     return copy;  | 
119  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::adoptPerUnit(icu_70::MeasureUnit*) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::adoptPerUnit(icu_70::MeasureUnit*) const &  | 
120  |  |  | 
121  |  | template<typename Derived>  | 
122  | 0  | Derived NumberFormatterSettings<Derived>::adoptPerUnit(icu::MeasureUnit* perUnit)&& { | 
123  | 0  |     Derived move(std::move(*this));  | 
124  |  |     // See comments above about slicing and ownership.  | 
125  | 0  |     if (perUnit != nullptr) { | 
126  |  |         // TODO: On nullptr, reset to default value?  | 
127  | 0  |         move.fMacros.perUnit = std::move(*perUnit);  | 
128  | 0  |         delete perUnit;  | 
129  | 0  |     }  | 
130  | 0  |     return move;  | 
131  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::adoptPerUnit(icu_70::MeasureUnit*) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::adoptPerUnit(icu_70::MeasureUnit*) &&  | 
132  |  |  | 
133  |  | template<typename Derived>  | 
134  | 0  | Derived NumberFormatterSettings<Derived>::precision(const Precision& precision) const& { | 
135  | 0  |     Derived copy(*this);  | 
136  |  |     // NOTE: Slicing is OK.  | 
137  | 0  |     copy.fMacros.precision = precision;  | 
138  | 0  |     return copy;  | 
139  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::precision(icu_70::number::Precision const&) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::precision(icu_70::number::Precision const&) const &  | 
140  |  |  | 
141  |  | template<typename Derived>  | 
142  | 0  | Derived NumberFormatterSettings<Derived>::precision(const Precision& precision)&& { | 
143  | 0  |     Derived move(std::move(*this));  | 
144  |  |     // NOTE: Slicing is OK.  | 
145  | 0  |     move.fMacros.precision = precision;  | 
146  | 0  |     return move;  | 
147  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::precision(icu_70::number::Precision const&) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::precision(icu_70::number::Precision const&) &&  | 
148  |  |  | 
149  |  | template<typename Derived>  | 
150  | 0  | Derived NumberFormatterSettings<Derived>::roundingMode(UNumberFormatRoundingMode roundingMode) const& { | 
151  | 0  |     Derived copy(*this);  | 
152  | 0  |     copy.fMacros.roundingMode = roundingMode;  | 
153  | 0  |     return copy;  | 
154  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::roundingMode(UNumberFormatRoundingMode) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::roundingMode(UNumberFormatRoundingMode) const &  | 
155  |  |  | 
156  |  | template<typename Derived>  | 
157  | 0  | Derived NumberFormatterSettings<Derived>::roundingMode(UNumberFormatRoundingMode roundingMode)&& { | 
158  | 0  |     Derived move(std::move(*this));  | 
159  | 0  |     move.fMacros.roundingMode = roundingMode;  | 
160  | 0  |     return move;  | 
161  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::roundingMode(UNumberFormatRoundingMode) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::roundingMode(UNumberFormatRoundingMode) &&  | 
162  |  |  | 
163  |  | template<typename Derived>  | 
164  | 0  | Derived NumberFormatterSettings<Derived>::grouping(UNumberGroupingStrategy strategy) const& { | 
165  | 0  |     Derived copy(*this);  | 
166  |  |     // NOTE: This is slightly different than how the setting is stored in Java  | 
167  |  |     // because we want to put it on the stack.  | 
168  | 0  |     copy.fMacros.grouper = Grouper::forStrategy(strategy);  | 
169  | 0  |     return copy;  | 
170  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::grouping(UNumberGroupingStrategy) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::grouping(UNumberGroupingStrategy) const &  | 
171  |  |  | 
172  |  | template<typename Derived>  | 
173  | 0  | Derived NumberFormatterSettings<Derived>::grouping(UNumberGroupingStrategy strategy)&& { | 
174  | 0  |     Derived move(std::move(*this));  | 
175  | 0  |     move.fMacros.grouper = Grouper::forStrategy(strategy);  | 
176  | 0  |     return move;  | 
177  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::grouping(UNumberGroupingStrategy) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::grouping(UNumberGroupingStrategy) &&  | 
178  |  |  | 
179  |  | template<typename Derived>  | 
180  | 0  | Derived NumberFormatterSettings<Derived>::integerWidth(const IntegerWidth& style) const& { | 
181  | 0  |     Derived copy(*this);  | 
182  | 0  |     copy.fMacros.integerWidth = style;  | 
183  | 0  |     return copy;  | 
184  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::integerWidth(icu_70::number::IntegerWidth const&) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::integerWidth(icu_70::number::IntegerWidth const&) const &  | 
185  |  |  | 
186  |  | template<typename Derived>  | 
187  | 0  | Derived NumberFormatterSettings<Derived>::integerWidth(const IntegerWidth& style)&& { | 
188  | 0  |     Derived move(std::move(*this));  | 
189  | 0  |     move.fMacros.integerWidth = style;  | 
190  | 0  |     return move;  | 
191  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::integerWidth(icu_70::number::IntegerWidth const&) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::integerWidth(icu_70::number::IntegerWidth const&) &&  | 
192  |  |  | 
193  |  | template<typename Derived>  | 
194  | 0  | Derived NumberFormatterSettings<Derived>::symbols(const DecimalFormatSymbols& symbols) const& { | 
195  | 0  |     Derived copy(*this);  | 
196  | 0  |     copy.fMacros.symbols.setTo(symbols);  | 
197  | 0  |     return copy;  | 
198  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::symbols(icu_70::DecimalFormatSymbols const&) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::symbols(icu_70::DecimalFormatSymbols const&) const &  | 
199  |  |  | 
200  |  | template<typename Derived>  | 
201  | 0  | Derived NumberFormatterSettings<Derived>::symbols(const DecimalFormatSymbols& symbols)&& { | 
202  | 0  |     Derived move(std::move(*this));  | 
203  | 0  |     move.fMacros.symbols.setTo(symbols);  | 
204  | 0  |     return move;  | 
205  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::symbols(icu_70::DecimalFormatSymbols const&) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::symbols(icu_70::DecimalFormatSymbols const&) &&  | 
206  |  |  | 
207  |  | template<typename Derived>  | 
208  | 0  | Derived NumberFormatterSettings<Derived>::adoptSymbols(NumberingSystem* ns) const& { | 
209  | 0  |     Derived copy(*this);  | 
210  | 0  |     copy.fMacros.symbols.setTo(ns);  | 
211  | 0  |     return copy;  | 
212  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::adoptSymbols(icu_70::NumberingSystem*) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::adoptSymbols(icu_70::NumberingSystem*) const &  | 
213  |  |  | 
214  |  | template<typename Derived>  | 
215  | 0  | Derived NumberFormatterSettings<Derived>::adoptSymbols(NumberingSystem* ns)&& { | 
216  | 0  |     Derived move(std::move(*this));  | 
217  | 0  |     move.fMacros.symbols.setTo(ns);  | 
218  | 0  |     return move;  | 
219  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::adoptSymbols(icu_70::NumberingSystem*) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::adoptSymbols(icu_70::NumberingSystem*) &&  | 
220  |  |  | 
221  |  | template<typename Derived>  | 
222  | 0  | Derived NumberFormatterSettings<Derived>::unitWidth(UNumberUnitWidth width) const& { | 
223  | 0  |     Derived copy(*this);  | 
224  | 0  |     copy.fMacros.unitWidth = width;  | 
225  | 0  |     return copy;  | 
226  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::unitWidth(UNumberUnitWidth) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::unitWidth(UNumberUnitWidth) const &  | 
227  |  |  | 
228  |  | template<typename Derived>  | 
229  | 0  | Derived NumberFormatterSettings<Derived>::unitWidth(UNumberUnitWidth width)&& { | 
230  | 0  |     Derived move(std::move(*this));  | 
231  | 0  |     move.fMacros.unitWidth = width;  | 
232  | 0  |     return move;  | 
233  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::unitWidth(UNumberUnitWidth) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::unitWidth(UNumberUnitWidth) &&  | 
234  |  |  | 
235  |  | template<typename Derived>  | 
236  | 0  | Derived NumberFormatterSettings<Derived>::sign(UNumberSignDisplay style) const& { | 
237  | 0  |     Derived copy(*this);  | 
238  | 0  |     copy.fMacros.sign = style;  | 
239  | 0  |     return copy;  | 
240  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::sign(UNumberSignDisplay) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::sign(UNumberSignDisplay) const &  | 
241  |  |  | 
242  |  | template<typename Derived>  | 
243  | 0  | Derived NumberFormatterSettings<Derived>::sign(UNumberSignDisplay style)&& { | 
244  | 0  |     Derived move(std::move(*this));  | 
245  | 0  |     move.fMacros.sign = style;  | 
246  | 0  |     return move;  | 
247  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::sign(UNumberSignDisplay) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::sign(UNumberSignDisplay) &&  | 
248  |  |  | 
249  |  | template<typename Derived>  | 
250  | 0  | Derived NumberFormatterSettings<Derived>::decimal(UNumberDecimalSeparatorDisplay style) const& { | 
251  | 0  |     Derived copy(*this);  | 
252  | 0  |     copy.fMacros.decimal = style;  | 
253  | 0  |     return copy;  | 
254  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::decimal(UNumberDecimalSeparatorDisplay) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::decimal(UNumberDecimalSeparatorDisplay) const &  | 
255  |  |  | 
256  |  | template<typename Derived>  | 
257  | 0  | Derived NumberFormatterSettings<Derived>::decimal(UNumberDecimalSeparatorDisplay style)&& { | 
258  | 0  |     Derived move(std::move(*this));  | 
259  | 0  |     move.fMacros.decimal = style;  | 
260  | 0  |     return move;  | 
261  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::decimal(UNumberDecimalSeparatorDisplay) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::decimal(UNumberDecimalSeparatorDisplay) &&  | 
262  |  |  | 
263  |  | template<typename Derived>  | 
264  | 0  | Derived NumberFormatterSettings<Derived>::scale(const Scale& scale) const& { | 
265  | 0  |     Derived copy(*this);  | 
266  | 0  |     copy.fMacros.scale = scale;  | 
267  | 0  |     return copy;  | 
268  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::scale(icu_70::number::Scale const&) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::scale(icu_70::number::Scale const&) const &  | 
269  |  |  | 
270  |  | template<typename Derived>  | 
271  | 0  | Derived NumberFormatterSettings<Derived>::scale(const Scale& scale)&& { | 
272  | 0  |     Derived move(std::move(*this));  | 
273  | 0  |     move.fMacros.scale = scale;  | 
274  | 0  |     return move;  | 
275  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::scale(icu_70::number::Scale const&) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::scale(icu_70::number::Scale const&) &&  | 
276  |  |  | 
277  |  | template<typename Derived>  | 
278  | 0  | Derived NumberFormatterSettings<Derived>::usage(const StringPiece usage) const& { | 
279  | 0  |     Derived copy(*this);  | 
280  | 0  |     copy.fMacros.usage.set(usage);  | 
281  | 0  |     return copy;  | 
282  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::usage(icu_70::StringPiece) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::usage(icu_70::StringPiece) const &  | 
283  |  |  | 
284  |  | template<typename Derived>  | 
285  | 0  | Derived NumberFormatterSettings<Derived>::usage(const StringPiece usage)&& { | 
286  | 0  |     Derived move(std::move(*this));  | 
287  | 0  |     move.fMacros.usage.set(usage);  | 
288  | 0  |     return move;  | 
289  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::usage(icu_70::StringPiece) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::usage(icu_70::StringPiece) &&  | 
290  |  |  | 
291  |  | template<typename Derived>  | 
292  | 0  | Derived NumberFormatterSettings<Derived>::unitDisplayCase(const StringPiece unitDisplayCase) const& { | 
293  | 0  |     Derived copy(*this);  | 
294  | 0  |     copy.fMacros.unitDisplayCase.set(unitDisplayCase);  | 
295  | 0  |     return copy;  | 
296  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::unitDisplayCase(icu_70::StringPiece) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::unitDisplayCase(icu_70::StringPiece) const &  | 
297  |  |  | 
298  |  | template<typename Derived>  | 
299  | 0  | Derived NumberFormatterSettings<Derived>::unitDisplayCase(const StringPiece unitDisplayCase)&& { | 
300  | 0  |     Derived move(std::move(*this));  | 
301  | 0  |     move.fMacros.unitDisplayCase.set(unitDisplayCase);  | 
302  | 0  |     return move;  | 
303  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::unitDisplayCase(icu_70::StringPiece) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::unitDisplayCase(icu_70::StringPiece) &&  | 
304  |  |  | 
305  |  | template<typename Derived>  | 
306  | 0  | Derived NumberFormatterSettings<Derived>::padding(const Padder& padder) const& { | 
307  | 0  |     Derived copy(*this);  | 
308  | 0  |     copy.fMacros.padder = padder;  | 
309  | 0  |     return copy;  | 
310  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::padding(icu_70::number::impl::Padder const&) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::padding(icu_70::number::impl::Padder const&) const &  | 
311  |  |  | 
312  |  | template<typename Derived>  | 
313  | 0  | Derived NumberFormatterSettings<Derived>::padding(const Padder& padder)&& { | 
314  | 0  |     Derived move(std::move(*this));  | 
315  | 0  |     move.fMacros.padder = padder;  | 
316  | 0  |     return move;  | 
317  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::padding(icu_70::number::impl::Padder const&) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::padding(icu_70::number::impl::Padder const&) &&  | 
318  |  |  | 
319  |  | template<typename Derived>  | 
320  | 0  | Derived NumberFormatterSettings<Derived>::threshold(int32_t threshold) const& { | 
321  | 0  |     Derived copy(*this);  | 
322  | 0  |     copy.fMacros.threshold = threshold;  | 
323  | 0  |     return copy;  | 
324  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::threshold(int) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::threshold(int) const &  | 
325  |  |  | 
326  |  | template<typename Derived>  | 
327  | 0  | Derived NumberFormatterSettings<Derived>::threshold(int32_t threshold)&& { | 
328  | 0  |     Derived move(std::move(*this));  | 
329  | 0  |     move.fMacros.threshold = threshold;  | 
330  | 0  |     return move;  | 
331  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::threshold(int) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::threshold(int) &&  | 
332  |  |  | 
333  |  | template<typename Derived>  | 
334  | 0  | Derived NumberFormatterSettings<Derived>::macros(const impl::MacroProps& macros) const& { | 
335  | 0  |     Derived copy(*this);  | 
336  | 0  |     copy.fMacros = macros;  | 
337  | 0  |     return copy;  | 
338  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::macros(icu_70::number::impl::MacroProps const&) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::macros(icu_70::number::impl::MacroProps const&) const &  | 
339  |  |  | 
340  |  | template<typename Derived>  | 
341  | 0  | Derived NumberFormatterSettings<Derived>::macros(const impl::MacroProps& macros)&& { | 
342  | 0  |     Derived move(std::move(*this));  | 
343  | 0  |     move.fMacros = macros;  | 
344  | 0  |     return move;  | 
345  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::macros(icu_70::number::impl::MacroProps const&) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::macros(icu_70::number::impl::MacroProps const&) &&  | 
346  |  |  | 
347  |  | template<typename Derived>  | 
348  | 0  | Derived NumberFormatterSettings<Derived>::macros(impl::MacroProps&& macros) const& { | 
349  | 0  |     Derived copy(*this);  | 
350  | 0  |     copy.fMacros = std::move(macros);  | 
351  | 0  |     return copy;  | 
352  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::macros(icu_70::number::impl::MacroProps&&) const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::macros(icu_70::number::impl::MacroProps&&) const &  | 
353  |  |  | 
354  |  | template<typename Derived>  | 
355  | 0  | Derived NumberFormatterSettings<Derived>::macros(impl::MacroProps&& macros)&& { | 
356  | 0  |     Derived move(std::move(*this));  | 
357  | 0  |     move.fMacros = std::move(macros);  | 
358  | 0  |     return move;  | 
359  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::macros(icu_70::number::impl::MacroProps&&) && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::macros(icu_70::number::impl::MacroProps&&) &&  | 
360  |  |  | 
361  |  | // Note: toSkeleton defined in number_skeletons.cpp  | 
362  |  |  | 
363  |  | template<typename Derived>  | 
364  | 0  | LocalPointer<Derived> NumberFormatterSettings<Derived>::clone() const & { | 
365  | 0  |     return LocalPointer<Derived>(new Derived(*this));  | 
366  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::clone() const & Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::clone() const &  | 
367  |  |  | 
368  |  | template<typename Derived>  | 
369  | 0  | LocalPointer<Derived> NumberFormatterSettings<Derived>::clone() && { | 
370  | 0  |     return LocalPointer<Derived>(new Derived(std::move(*this)));  | 
371  | 0  | } Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::UnlocalizedNumberFormatter>::clone() && Unexecuted instantiation: icu_70::number::NumberFormatterSettings<icu_70::number::LocalizedNumberFormatter>::clone() &&  | 
372  |  |  | 
373  |  | // Declare all classes that implement NumberFormatterSettings  | 
374  |  | // See https://stackoverflow.com/a/495056/1407170  | 
375  |  | template  | 
376  |  | class icu::number::NumberFormatterSettings<icu::number::UnlocalizedNumberFormatter>;  | 
377  |  | template  | 
378  |  | class icu::number::NumberFormatterSettings<icu::number::LocalizedNumberFormatter>;  | 
379  |  |  | 
380  |  |  | 
381  | 0  | UnlocalizedNumberFormatter NumberFormatter::with() { | 
382  | 0  |     UnlocalizedNumberFormatter result;  | 
383  | 0  |     return result;  | 
384  | 0  | }  | 
385  |  |  | 
386  | 0  | LocalizedNumberFormatter NumberFormatter::withLocale(const Locale& locale) { | 
387  | 0  |     return with().locale(locale);  | 
388  | 0  | }  | 
389  |  |  | 
390  |  | // Note: forSkeleton defined in number_skeletons.cpp  | 
391  |  |  | 
392  |  |  | 
393  |  | template<typename T> using NFS = NumberFormatterSettings<T>;  | 
394  |  | using LNF = LocalizedNumberFormatter;  | 
395  |  | using UNF = UnlocalizedNumberFormatter;  | 
396  |  |  | 
397  |  | UnlocalizedNumberFormatter::UnlocalizedNumberFormatter(const UNF& other)  | 
398  | 0  |         : UNF(static_cast<const NFS<UNF>&>(other)) {} | 
399  |  |  | 
400  |  | UnlocalizedNumberFormatter::UnlocalizedNumberFormatter(const NFS<UNF>& other)  | 
401  | 0  |         : NFS<UNF>(other) { | 
402  |  |     // No additional fields to assign  | 
403  | 0  | }  | 
404  |  |  | 
405  |  | // Make default copy constructor call the NumberFormatterSettings copy constructor.  | 
406  |  | UnlocalizedNumberFormatter::UnlocalizedNumberFormatter(UNF&& src) U_NOEXCEPT  | 
407  | 0  |         : UNF(static_cast<NFS<UNF>&&>(src)) {} | 
408  |  |  | 
409  |  | UnlocalizedNumberFormatter::UnlocalizedNumberFormatter(NFS<UNF>&& src) U_NOEXCEPT  | 
410  | 0  |         : NFS<UNF>(std::move(src)) { | 
411  |  |     // No additional fields to assign  | 
412  | 0  | }  | 
413  |  |  | 
414  | 0  | UnlocalizedNumberFormatter& UnlocalizedNumberFormatter::operator=(const UNF& other) { | 
415  | 0  |     NFS<UNF>::operator=(static_cast<const NFS<UNF>&>(other));  | 
416  |  |     // No additional fields to assign  | 
417  | 0  |     return *this;  | 
418  | 0  | }  | 
419  |  |  | 
420  | 0  | UnlocalizedNumberFormatter& UnlocalizedNumberFormatter::operator=(UNF&& src) U_NOEXCEPT { | 
421  | 0  |     NFS<UNF>::operator=(static_cast<NFS<UNF>&&>(src));  | 
422  |  |     // No additional fields to assign  | 
423  | 0  |     return *this;  | 
424  | 0  | }  | 
425  |  |  | 
426  |  | // Make default copy constructor call the NumberFormatterSettings copy constructor.  | 
427  |  | LocalizedNumberFormatter::LocalizedNumberFormatter(const LNF& other)  | 
428  | 0  |         : LNF(static_cast<const NFS<LNF>&>(other)) {} | 
429  |  |  | 
430  |  | LocalizedNumberFormatter::LocalizedNumberFormatter(const NFS<LNF>& other)  | 
431  | 0  |         : NFS<LNF>(other) { | 
432  | 0  |     UErrorCode localStatus = U_ZERO_ERROR; // Can't bubble up the error  | 
433  | 0  |     lnfCopyHelper(static_cast<const LNF&>(other), localStatus);  | 
434  | 0  | }  | 
435  |  |  | 
436  |  | LocalizedNumberFormatter::LocalizedNumberFormatter(LocalizedNumberFormatter&& src) U_NOEXCEPT  | 
437  | 0  |         : LNF(static_cast<NFS<LNF>&&>(src)) {} | 
438  |  |  | 
439  |  | LocalizedNumberFormatter::LocalizedNumberFormatter(NFS<LNF>&& src) U_NOEXCEPT  | 
440  | 0  |         : NFS<LNF>(std::move(src)) { | 
441  | 0  |     lnfMoveHelper(std::move(static_cast<LNF&&>(src)));  | 
442  | 0  | }  | 
443  |  |  | 
444  | 0  | LocalizedNumberFormatter& LocalizedNumberFormatter::operator=(const LNF& other) { | 
445  | 0  |     if (this == &other) { return *this; }  // self-assignment: no-op | 
446  | 0  |     NFS<LNF>::operator=(static_cast<const NFS<LNF>&>(other));  | 
447  | 0  |     UErrorCode localStatus = U_ZERO_ERROR; // Can't bubble up the error  | 
448  | 0  |     lnfCopyHelper(other, localStatus);  | 
449  | 0  |     return *this;  | 
450  | 0  | }  | 
451  |  |  | 
452  | 0  | LocalizedNumberFormatter& LocalizedNumberFormatter::operator=(LNF&& src) U_NOEXCEPT { | 
453  | 0  |     NFS<LNF>::operator=(static_cast<NFS<LNF>&&>(src));  | 
454  | 0  |     lnfMoveHelper(std::move(src));  | 
455  | 0  |     return *this;  | 
456  | 0  | }  | 
457  |  |  | 
458  | 0  | void LocalizedNumberFormatter::resetCompiled() { | 
459  | 0  |     auto* callCount = reinterpret_cast<u_atomic_int32_t*>(fUnsafeCallCount);  | 
460  | 0  |     umtx_storeRelease(*callCount, 0);  | 
461  | 0  |     fCompiled = nullptr;  | 
462  | 0  | }  | 
463  |  |  | 
464  | 0  | void LocalizedNumberFormatter::lnfMoveHelper(LNF&& src) { | 
465  |  |     // Copy over the compiled formatter and set call count to INT32_MIN as in computeCompiled().  | 
466  |  |     // Don't copy the call count directly because doing so requires a loadAcquire/storeRelease.  | 
467  |  |     // The bits themselves appear to be platform-dependent, so copying them might not be safe.  | 
468  | 0  |     delete fCompiled;  | 
469  | 0  |     if (src.fCompiled != nullptr) { | 
470  | 0  |         auto* callCount = reinterpret_cast<u_atomic_int32_t*>(fUnsafeCallCount);  | 
471  | 0  |         umtx_storeRelease(*callCount, INT32_MIN);  | 
472  | 0  |         fCompiled = src.fCompiled;  | 
473  |  |         // Reset the source object to leave it in a safe state.  | 
474  | 0  |         src.resetCompiled();  | 
475  | 0  |     } else { | 
476  | 0  |         resetCompiled();  | 
477  | 0  |     }  | 
478  |  |  | 
479  |  |     // Unconditionally move the warehouse  | 
480  | 0  |     delete fWarehouse;  | 
481  | 0  |     fWarehouse = src.fWarehouse;  | 
482  | 0  |     src.fWarehouse = nullptr;  | 
483  | 0  | }  | 
484  |  |  | 
485  | 0  | void LocalizedNumberFormatter::lnfCopyHelper(const LNF&, UErrorCode& status) { | 
486  |  |     // When copying, always reset the compiled formatter.  | 
487  | 0  |     delete fCompiled;  | 
488  | 0  |     resetCompiled();  | 
489  |  |  | 
490  |  |     // If MacroProps has a reference to AffixPatternProvider, we need to copy it.  | 
491  |  |     // If MacroProps has a reference to PluralRules, copy that one, too.  | 
492  | 0  |     delete fWarehouse;  | 
493  | 0  |     if (fMacros.affixProvider || fMacros.rules) { | 
494  | 0  |         LocalPointer<DecimalFormatWarehouse> warehouse(new DecimalFormatWarehouse(), status);  | 
495  | 0  |         if (U_FAILURE(status)) { | 
496  | 0  |             fWarehouse = nullptr;  | 
497  | 0  |             return;  | 
498  | 0  |         }  | 
499  | 0  |         if (fMacros.affixProvider) { | 
500  | 0  |             warehouse->affixProvider.setTo(fMacros.affixProvider, status);  | 
501  | 0  |             fMacros.affixProvider = &warehouse->affixProvider.get();  | 
502  | 0  |         }  | 
503  | 0  |         if (fMacros.rules) { | 
504  | 0  |             warehouse->rules.adoptInsteadAndCheckErrorCode(  | 
505  | 0  |                 new PluralRules(*fMacros.rules), status);  | 
506  | 0  |             fMacros.rules = warehouse->rules.getAlias();  | 
507  | 0  |         }  | 
508  | 0  |         fWarehouse = warehouse.orphan();  | 
509  | 0  |     } else { | 
510  | 0  |         fWarehouse = nullptr;  | 
511  | 0  |     }  | 
512  | 0  | }  | 
513  |  |  | 
514  |  |  | 
515  | 0  | LocalizedNumberFormatter::~LocalizedNumberFormatter() { | 
516  | 0  |     delete fCompiled;  | 
517  | 0  |     delete fWarehouse;  | 
518  | 0  | }  | 
519  |  |  | 
520  | 0  | LocalizedNumberFormatter::LocalizedNumberFormatter(const MacroProps& macros, const Locale& locale) { | 
521  | 0  |     fMacros = macros;  | 
522  | 0  |     fMacros.locale = locale;  | 
523  | 0  | }  | 
524  |  |  | 
525  | 0  | LocalizedNumberFormatter::LocalizedNumberFormatter(MacroProps&& macros, const Locale& locale) { | 
526  | 0  |     fMacros = std::move(macros);  | 
527  | 0  |     fMacros.locale = locale;  | 
528  | 0  | }  | 
529  |  |  | 
530  | 0  | LocalizedNumberFormatter UnlocalizedNumberFormatter::locale(const Locale& locale) const& { | 
531  | 0  |     return LocalizedNumberFormatter(fMacros, locale);  | 
532  | 0  | }  | 
533  |  |  | 
534  | 0  | LocalizedNumberFormatter UnlocalizedNumberFormatter::locale(const Locale& locale)&& { | 
535  | 0  |     return LocalizedNumberFormatter(std::move(fMacros), locale);  | 
536  | 0  | }  | 
537  |  |  | 
538  | 0  | FormattedNumber LocalizedNumberFormatter::formatInt(int64_t value, UErrorCode& status) const { | 
539  | 0  |     if (U_FAILURE(status)) { return FormattedNumber(U_ILLEGAL_ARGUMENT_ERROR); } | 
540  | 0  |     auto results = new UFormattedNumberData();  | 
541  | 0  |     if (results == nullptr) { | 
542  | 0  |         status = U_MEMORY_ALLOCATION_ERROR;  | 
543  | 0  |         return FormattedNumber(status);  | 
544  | 0  |     }  | 
545  | 0  |     results->quantity.setToLong(value);  | 
546  | 0  |     formatImpl(results, status);  | 
547  |  |  | 
548  |  |     // Do not save the results object if we encountered a failure.  | 
549  | 0  |     if (U_SUCCESS(status)) { | 
550  | 0  |         return FormattedNumber(results);  | 
551  | 0  |     } else { | 
552  | 0  |         delete results;  | 
553  | 0  |         return FormattedNumber(status);  | 
554  | 0  |     }  | 
555  | 0  | }  | 
556  |  |  | 
557  | 0  | FormattedNumber LocalizedNumberFormatter::formatDouble(double value, UErrorCode& status) const { | 
558  | 0  |     if (U_FAILURE(status)) { return FormattedNumber(U_ILLEGAL_ARGUMENT_ERROR); } | 
559  | 0  |     auto results = new UFormattedNumberData();  | 
560  | 0  |     if (results == nullptr) { | 
561  | 0  |         status = U_MEMORY_ALLOCATION_ERROR;  | 
562  | 0  |         return FormattedNumber(status);  | 
563  | 0  |     }  | 
564  | 0  |     results->quantity.setToDouble(value);  | 
565  | 0  |     formatImpl(results, status);  | 
566  |  |  | 
567  |  |     // Do not save the results object if we encountered a failure.  | 
568  | 0  |     if (U_SUCCESS(status)) { | 
569  | 0  |         return FormattedNumber(results);  | 
570  | 0  |     } else { | 
571  | 0  |         delete results;  | 
572  | 0  |         return FormattedNumber(status);  | 
573  | 0  |     }  | 
574  | 0  | }  | 
575  |  |  | 
576  | 0  | FormattedNumber LocalizedNumberFormatter::formatDecimal(StringPiece value, UErrorCode& status) const { | 
577  | 0  |     if (U_FAILURE(status)) { return FormattedNumber(U_ILLEGAL_ARGUMENT_ERROR); } | 
578  | 0  |     auto results = new UFormattedNumberData();  | 
579  | 0  |     if (results == nullptr) { | 
580  | 0  |         status = U_MEMORY_ALLOCATION_ERROR;  | 
581  | 0  |         return FormattedNumber(status);  | 
582  | 0  |     }  | 
583  | 0  |     results->quantity.setToDecNumber(value, status);  | 
584  | 0  |     formatImpl(results, status);  | 
585  |  |  | 
586  |  |     // Do not save the results object if we encountered a failure.  | 
587  | 0  |     if (U_SUCCESS(status)) { | 
588  | 0  |         return FormattedNumber(results);  | 
589  | 0  |     } else { | 
590  | 0  |         delete results;  | 
591  | 0  |         return FormattedNumber(status);  | 
592  | 0  |     }  | 
593  | 0  | }  | 
594  |  |  | 
595  |  | FormattedNumber  | 
596  | 0  | LocalizedNumberFormatter::formatDecimalQuantity(const DecimalQuantity& dq, UErrorCode& status) const { | 
597  | 0  |     if (U_FAILURE(status)) { return FormattedNumber(U_ILLEGAL_ARGUMENT_ERROR); } | 
598  | 0  |     auto results = new UFormattedNumberData();  | 
599  | 0  |     if (results == nullptr) { | 
600  | 0  |         status = U_MEMORY_ALLOCATION_ERROR;  | 
601  | 0  |         return FormattedNumber(status);  | 
602  | 0  |     }  | 
603  | 0  |     results->quantity = dq;  | 
604  | 0  |     formatImpl(results, status);  | 
605  |  |  | 
606  |  |     // Do not save the results object if we encountered a failure.  | 
607  | 0  |     if (U_SUCCESS(status)) { | 
608  | 0  |         return FormattedNumber(results);  | 
609  | 0  |     } else { | 
610  | 0  |         delete results;  | 
611  | 0  |         return FormattedNumber(status);  | 
612  | 0  |     }  | 
613  | 0  | }  | 
614  |  |  | 
615  | 0  | void LocalizedNumberFormatter::formatImpl(impl::UFormattedNumberData* results, UErrorCode& status) const { | 
616  | 0  |     if (computeCompiled(status)) { | 
617  | 0  |         fCompiled->format(results, status);  | 
618  | 0  |     } else { | 
619  | 0  |         NumberFormatterImpl::formatStatic(fMacros, results, status);  | 
620  | 0  |     }  | 
621  | 0  |     if (U_FAILURE(status)) { | 
622  | 0  |         return;  | 
623  | 0  |     }  | 
624  | 0  |     results->getStringRef().writeTerminator(status);  | 
625  | 0  | }  | 
626  |  |  | 
627  |  | void LocalizedNumberFormatter::getAffixImpl(bool isPrefix, bool isNegative, UnicodeString& result,  | 
628  | 0  |                                             UErrorCode& status) const { | 
629  | 0  |     FormattedStringBuilder string;  | 
630  | 0  |     auto signum = static_cast<Signum>(isNegative ? SIGNUM_NEG : SIGNUM_POS);  | 
631  |  |     // Always return affixes for plural form OTHER.  | 
632  | 0  |     static const StandardPlural::Form plural = StandardPlural::OTHER;  | 
633  | 0  |     int32_t prefixLength;  | 
634  | 0  |     if (computeCompiled(status)) { | 
635  | 0  |         prefixLength = fCompiled->getPrefixSuffix(signum, plural, string, status);  | 
636  | 0  |     } else { | 
637  | 0  |         prefixLength = NumberFormatterImpl::getPrefixSuffixStatic(fMacros, signum, plural, string, status);  | 
638  | 0  |     }  | 
639  | 0  |     result.remove();  | 
640  | 0  |     if (isPrefix) { | 
641  | 0  |         result.append(string.toTempUnicodeString().tempSubStringBetween(0, prefixLength));  | 
642  | 0  |     } else { | 
643  | 0  |         result.append(string.toTempUnicodeString().tempSubStringBetween(prefixLength, string.length()));  | 
644  | 0  |     }  | 
645  | 0  | }  | 
646  |  |  | 
647  | 0  | bool LocalizedNumberFormatter::computeCompiled(UErrorCode& status) const { | 
648  |  |     // fUnsafeCallCount contains memory to be interpreted as an atomic int, most commonly  | 
649  |  |     // std::atomic<int32_t>.  Since the type of atomic int is platform-dependent, we cast the  | 
650  |  |     // bytes in fUnsafeCallCount to u_atomic_int32_t, a typedef for the platform-dependent  | 
651  |  |     // atomic int type defined in umutex.h.  | 
652  | 0  |     static_assert(  | 
653  | 0  |             sizeof(u_atomic_int32_t) <= sizeof(fUnsafeCallCount),  | 
654  | 0  |             "Atomic integer size on this platform exceeds the size allocated by fUnsafeCallCount");  | 
655  | 0  |     auto* callCount = reinterpret_cast<u_atomic_int32_t*>(  | 
656  | 0  |             const_cast<LocalizedNumberFormatter*>(this)->fUnsafeCallCount);  | 
657  |  |  | 
658  |  |     // A positive value in the atomic int indicates that the data structure is not yet ready;  | 
659  |  |     // a negative value indicates that it is ready. If, after the increment, the atomic int  | 
660  |  |     // is exactly threshold, then it is the current thread's job to build the data structure.  | 
661  |  |     // Note: We set the callCount to INT32_MIN so that if another thread proceeds to increment  | 
662  |  |     // the atomic int, the value remains below zero.  | 
663  | 0  |     int32_t currentCount = umtx_loadAcquire(*callCount);  | 
664  | 0  |     if (0 <= currentCount && currentCount <= fMacros.threshold && fMacros.threshold > 0) { | 
665  | 0  |         currentCount = umtx_atomic_inc(callCount);  | 
666  | 0  |     }  | 
667  |  | 
  | 
668  | 0  |     if (currentCount == fMacros.threshold && fMacros.threshold > 0) { | 
669  |  |         // Build the data structure and then use it (slow to fast path).  | 
670  | 0  |         const NumberFormatterImpl* compiled = new NumberFormatterImpl(fMacros, status);  | 
671  | 0  |         if (compiled == nullptr) { | 
672  | 0  |             status = U_MEMORY_ALLOCATION_ERROR;  | 
673  | 0  |             return false;  | 
674  | 0  |         }  | 
675  | 0  |         U_ASSERT(fCompiled == nullptr);  | 
676  | 0  |         const_cast<LocalizedNumberFormatter*>(this)->fCompiled = compiled;  | 
677  | 0  |         umtx_storeRelease(*callCount, INT32_MIN);  | 
678  | 0  |         return true;  | 
679  | 0  |     } else if (currentCount < 0) { | 
680  |  |         // The data structure is already built; use it (fast path).  | 
681  | 0  |         U_ASSERT(fCompiled != nullptr);  | 
682  | 0  |         return true;  | 
683  | 0  |     } else { | 
684  |  |         // Format the number without building the data structure (slow path).  | 
685  | 0  |         return false;  | 
686  | 0  |     }  | 
687  | 0  | }  | 
688  |  |  | 
689  | 0  | const impl::NumberFormatterImpl* LocalizedNumberFormatter::getCompiled() const { | 
690  | 0  |     return fCompiled;  | 
691  | 0  | }  | 
692  |  |  | 
693  | 0  | int32_t LocalizedNumberFormatter::getCallCount() const { | 
694  | 0  |     auto* callCount = reinterpret_cast<u_atomic_int32_t*>(  | 
695  | 0  |             const_cast<LocalizedNumberFormatter*>(this)->fUnsafeCallCount);  | 
696  | 0  |     return umtx_loadAcquire(*callCount);  | 
697  | 0  | }  | 
698  |  |  | 
699  |  | // Note: toFormat defined in number_asformat.cpp  | 
700  |  |  | 
701  | 0  | const DecimalFormatSymbols* LocalizedNumberFormatter::getDecimalFormatSymbols() const { | 
702  | 0  |     return fMacros.symbols.getDecimalFormatSymbols();  | 
703  | 0  | }  | 
704  |  |  | 
705  |  | #if (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN) && defined(_MSC_VER)  | 
706  |  | // Warning 4661.  | 
707  |  | #pragma warning(pop)  | 
708  |  | #endif  | 
709  |  |  | 
710  |  | #endif /* #if !UCONFIG_NO_FORMATTING */  |