1 // © 2019 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 "unicode/measunit.h"
9 #include "unicode/numberformatter.h"
10 #include "number_utypes.h"
11 #include "util.h"
12 #include "number_decimalquantity.h"
13 #include "number_decnum.h"
14 #include "numrange_impl.h"
15 
16 U_NAMESPACE_BEGIN
17 namespace number {
18 
19 
UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumber)20 UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumber)
21 
22 #define UPRV_NOARG
23 
24 void FormattedNumber::toDecimalNumber(ByteSink& sink, UErrorCode& status) const {
25     UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
26     impl::DecNum decnum;
27     fData->quantity.toDecNum(decnum, status);
28     decnum.toString(sink, status);
29 }
30 
getAllFieldPositionsImpl(FieldPositionIteratorHandler & fpih,UErrorCode & status) const31 void FormattedNumber::getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih,
32                                                UErrorCode& status) const {
33     UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
34     fData->getAllFieldPositions(fpih, status);
35 }
36 
getOutputUnit(UErrorCode & status) const37 MeasureUnit FormattedNumber::getOutputUnit(UErrorCode& status) const {
38     UPRV_FORMATTED_VALUE_METHOD_GUARD(MeasureUnit())
39     return fData->outputUnit;
40 }
41 
getDecimalQuantity(impl::DecimalQuantity & output,UErrorCode & status) const42 void FormattedNumber::getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const {
43     UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
44     output = fData->quantity;
45 }
46 
47 
48 impl::UFormattedNumberData::~UFormattedNumberData() = default;
49 
50 
UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumberRange)51 UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumberRange)
52 
53 #define UPRV_NOARG
54 
55 UnicodeString FormattedNumberRange::getFirstDecimal(UErrorCode& status) const {
56     UPRV_FORMATTED_VALUE_METHOD_GUARD(ICU_Utility::makeBogusString())
57     return fData->quantity1.toScientificString();
58 }
59 
getSecondDecimal(UErrorCode & status) const60 UnicodeString FormattedNumberRange::getSecondDecimal(UErrorCode& status) const {
61     UPRV_FORMATTED_VALUE_METHOD_GUARD(ICU_Utility::makeBogusString())
62     return fData->quantity2.toScientificString();
63 }
64 
getDecimalNumbers(ByteSink & sink1,ByteSink & sink2,UErrorCode & status) const65 void FormattedNumberRange::getDecimalNumbers(ByteSink& sink1, ByteSink& sink2, UErrorCode& status) const {
66     UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
67     impl::DecNum decnum1;
68     impl::DecNum decnum2;
69     fData->quantity1.toDecNum(decnum1, status).toString(sink1, status);
70     fData->quantity2.toDecNum(decnum2, status).toString(sink2, status);
71 }
72 
getIdentityResult(UErrorCode & status) const73 UNumberRangeIdentityResult FormattedNumberRange::getIdentityResult(UErrorCode& status) const {
74     UPRV_FORMATTED_VALUE_METHOD_GUARD(UNUM_IDENTITY_RESULT_NOT_EQUAL)
75     return fData->identityResult;
76 }
77 
getData(UErrorCode & status) const78 const impl::UFormattedNumberRangeData* FormattedNumberRange::getData(UErrorCode& status) const {
79     UPRV_FORMATTED_VALUE_METHOD_GUARD(nullptr)
80     return fData;
81 }
82 
83 
84 impl::UFormattedNumberRangeData::~UFormattedNumberRangeData() = default;
85 
86 
87 } // namespace number
88 U_NAMESPACE_END
89 
90 #endif /* #if !UCONFIG_NO_FORMATTING */
91