summaryrefslogtreecommitdiffstats
path: root/intl/icu/source/i18n/number_output.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /intl/icu/source/i18n/number_output.cpp
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'intl/icu/source/i18n/number_output.cpp')
-rw-r--r--intl/icu/source/i18n/number_output.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/intl/icu/source/i18n/number_output.cpp b/intl/icu/source/i18n/number_output.cpp
new file mode 100644
index 0000000000..729a2cd5e6
--- /dev/null
+++ b/intl/icu/source/i18n/number_output.cpp
@@ -0,0 +1,86 @@
+// © 2019 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/measunit.h"
+#include "unicode/numberformatter.h"
+#include "number_utypes.h"
+#include "util.h"
+#include "number_decimalquantity.h"
+#include "number_decnum.h"
+#include "numrange_impl.h"
+
+U_NAMESPACE_BEGIN
+namespace number {
+
+
+UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumber)
+
+#define UPRV_NOARG
+
+void FormattedNumber::toDecimalNumber(ByteSink& sink, UErrorCode& status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
+ impl::DecNum decnum;
+ fData->quantity.toDecNum(decnum, status);
+ decnum.toString(sink, status);
+}
+
+void FormattedNumber::getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih,
+ UErrorCode& status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
+ fData->getAllFieldPositions(fpih, status);
+}
+
+MeasureUnit FormattedNumber::getOutputUnit(UErrorCode& status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(MeasureUnit())
+ return fData->outputUnit;
+}
+
+UDisplayOptionsNounClass FormattedNumber::getNounClass(UErrorCode &status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(UDISPOPT_NOUN_CLASS_UNDEFINED);
+ const char *nounClass = fData->gender;
+ return udispopt_fromNounClassIdentifier(nounClass);
+}
+
+void FormattedNumber::getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
+ output = fData->quantity;
+}
+
+
+impl::UFormattedNumberData::~UFormattedNumberData() = default;
+
+
+UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumberRange)
+
+#define UPRV_NOARG
+
+void FormattedNumberRange::getDecimalNumbers(ByteSink& sink1, ByteSink& sink2, UErrorCode& status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
+ impl::DecNum decnum1;
+ impl::DecNum decnum2;
+ fData->quantity1.toDecNum(decnum1, status).toString(sink1, status);
+ fData->quantity2.toDecNum(decnum2, status).toString(sink2, status);
+}
+
+UNumberRangeIdentityResult FormattedNumberRange::getIdentityResult(UErrorCode& status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(UNUM_IDENTITY_RESULT_NOT_EQUAL)
+ return fData->identityResult;
+}
+
+const impl::UFormattedNumberRangeData* FormattedNumberRange::getData(UErrorCode& status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(nullptr)
+ return fData;
+}
+
+
+impl::UFormattedNumberRangeData::~UFormattedNumberRangeData() = default;
+
+
+} // namespace number
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */