/src/icu/source/i18n/number_output.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
20 | | UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumber) |
21 | | |
22 | | #define UPRV_NOARG |
23 | | |
24 | 0 | void FormattedNumber::toDecimalNumber(ByteSink& sink, UErrorCode& status) const { |
25 | 0 | UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG) |
26 | 0 | impl::DecNum decnum; |
27 | 0 | fData->quantity.toDecNum(decnum, status); |
28 | 0 | decnum.toString(sink, status); |
29 | 0 | } |
30 | | |
31 | | void FormattedNumber::getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih, |
32 | 0 | UErrorCode& status) const { |
33 | 0 | UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG) |
34 | 0 | fData->getAllFieldPositions(fpih, status); |
35 | 0 | } |
36 | | |
37 | 0 | MeasureUnit FormattedNumber::getOutputUnit(UErrorCode& status) const { |
38 | 0 | UPRV_FORMATTED_VALUE_METHOD_GUARD(MeasureUnit()) |
39 | 0 | return fData->outputUnit; |
40 | 0 | } |
41 | | |
42 | 0 | const char *FormattedNumber::getGender(UErrorCode &status) const { |
43 | 0 | UPRV_FORMATTED_VALUE_METHOD_GUARD("") |
44 | 0 | return fData->gender; |
45 | 0 | } |
46 | | |
47 | 0 | void FormattedNumber::getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const { |
48 | 0 | UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG) |
49 | 0 | output = fData->quantity; |
50 | 0 | } |
51 | | |
52 | | |
53 | 0 | impl::UFormattedNumberData::~UFormattedNumberData() = default; |
54 | | |
55 | | |
56 | | UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumberRange) |
57 | | |
58 | | #define UPRV_NOARG |
59 | | |
60 | 0 | void FormattedNumberRange::getDecimalNumbers(ByteSink& sink1, ByteSink& sink2, UErrorCode& status) const { |
61 | 0 | UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG) |
62 | 0 | impl::DecNum decnum1; |
63 | 0 | impl::DecNum decnum2; |
64 | 0 | fData->quantity1.toDecNum(decnum1, status).toString(sink1, status); |
65 | 0 | fData->quantity2.toDecNum(decnum2, status).toString(sink2, status); |
66 | 0 | } |
67 | | |
68 | 0 | UNumberRangeIdentityResult FormattedNumberRange::getIdentityResult(UErrorCode& status) const { |
69 | 0 | UPRV_FORMATTED_VALUE_METHOD_GUARD(UNUM_IDENTITY_RESULT_NOT_EQUAL) |
70 | 0 | return fData->identityResult; |
71 | 0 | } |
72 | | |
73 | 0 | const impl::UFormattedNumberRangeData* FormattedNumberRange::getData(UErrorCode& status) const { |
74 | 0 | UPRV_FORMATTED_VALUE_METHOD_GUARD(nullptr) |
75 | 0 | return fData; |
76 | 0 | } |
77 | | |
78 | | |
79 | 0 | impl::UFormattedNumberRangeData::~UFormattedNumberRangeData() = default; |
80 | | |
81 | | |
82 | | } // namespace number |
83 | | U_NAMESPACE_END |
84 | | |
85 | | #endif /* #if !UCONFIG_NO_FORMATTING */ |