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/numberformatter.h"
9 #include "number_utypes.h"
10 #include "util.h"
11 #include "number_decimalquantity.h"
12 #include "number_decnum.h"
13
14 U_NAMESPACE_BEGIN
15 namespace number {
16
17
UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumber)18 UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumber)
19
20 #define UPRV_NOARG
21
22 UBool FormattedNumber::nextFieldPosition(FieldPosition& fieldPosition, UErrorCode& status) const {
23 UPRV_FORMATTED_VALUE_METHOD_GUARD(FALSE)
24 return fData->nextFieldPosition(fieldPosition, status);
25 }
26
getAllFieldPositions(FieldPositionIterator & iterator,UErrorCode & status) const27 void FormattedNumber::getAllFieldPositions(FieldPositionIterator& iterator, UErrorCode& status) const {
28 FieldPositionIteratorHandler fpih(&iterator, status);
29 getAllFieldPositionsImpl(fpih, status);
30 }
31
toDecimalNumber(ByteSink & sink,UErrorCode & status) const32 void FormattedNumber::toDecimalNumber(ByteSink& sink, UErrorCode& status) const {
33 UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
34 impl::DecNum decnum;
35 fData->quantity.toDecNum(decnum, status);
36 decnum.toString(sink, status);
37 }
38
getAllFieldPositionsImpl(FieldPositionIteratorHandler & fpih,UErrorCode & status) const39 void FormattedNumber::getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih,
40 UErrorCode& status) const {
41 UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
42 fData->getAllFieldPositions(fpih, status);
43 }
44
getDecimalQuantity(impl::DecimalQuantity & output,UErrorCode & status) const45 void FormattedNumber::getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const {
46 UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
47 output = fData->quantity;
48 }
49
50
51 impl::UFormattedNumberData::~UFormattedNumberData() = default;
52
53
54 } // namespace number
55 U_NAMESPACE_END
56
57 #endif /* #if !UCONFIG_NO_FORMATTING */
58