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
getGender(UErrorCode & status) const42 const char *FormattedNumber::getGender(UErrorCode &status) const {
43 UPRV_FORMATTED_VALUE_METHOD_GUARD("")
44 return fData->gender;
45 }
46
getDecimalQuantity(impl::DecimalQuantity & output,UErrorCode & status) const47 void FormattedNumber::getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const {
48 UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
49 output = fData->quantity;
50 }
51
52
53 impl::UFormattedNumberData::~UFormattedNumberData() = default;
54
55
UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumberRange)56 UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumberRange)
57
58 #define UPRV_NOARG
59
60 void FormattedNumberRange::getDecimalNumbers(ByteSink& sink1, ByteSink& sink2, UErrorCode& status) const {
61 UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
62 impl::DecNum decnum1;
63 impl::DecNum decnum2;
64 fData->quantity1.toDecNum(decnum1, status).toString(sink1, status);
65 fData->quantity2.toDecNum(decnum2, status).toString(sink2, status);
66 }
67
getIdentityResult(UErrorCode & status) const68 UNumberRangeIdentityResult FormattedNumberRange::getIdentityResult(UErrorCode& status) const {
69 UPRV_FORMATTED_VALUE_METHOD_GUARD(UNUM_IDENTITY_RESULT_NOT_EQUAL)
70 return fData->identityResult;
71 }
72
getData(UErrorCode & status) const73 const impl::UFormattedNumberRangeData* FormattedNumberRange::getData(UErrorCode& status) const {
74 UPRV_FORMATTED_VALUE_METHOD_GUARD(nullptr)
75 return fData;
76 }
77
78
79 impl::UFormattedNumberRangeData::~UFormattedNumberRangeData() = default;
80
81
82 } // namespace number
83 U_NAMESPACE_END
84
85 #endif /* #if !UCONFIG_NO_FORMATTING */
86