aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/i18n/number_asformat.cpp
diff options
context:
space:
mode:
authormcheshkov <mcheshkov@yandex-team.ru>2022-02-10 16:46:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:15 +0300
commite9d19cec64684c9c1e6b0c98297e5b895cf904fe (patch)
tree2768b1223e96a8a0610a93d18425d9647c1123c8 /contrib/libs/icu/i18n/number_asformat.cpp
parent60040c91ffe701a84689b2c6310ff845e65cff42 (diff)
downloadydb-e9d19cec64684c9c1e6b0c98297e5b895cf904fe.tar.gz
Restoring authorship annotation for <mcheshkov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/icu/i18n/number_asformat.cpp')
-rw-r--r--contrib/libs/icu/i18n/number_asformat.cpp234
1 files changed, 117 insertions, 117 deletions
diff --git a/contrib/libs/icu/i18n/number_asformat.cpp b/contrib/libs/icu/i18n/number_asformat.cpp
index 9d10d1f558..31df5740b7 100644
--- a/contrib/libs/icu/i18n/number_asformat.cpp
+++ b/contrib/libs/icu/i18n/number_asformat.cpp
@@ -1,117 +1,117 @@
-// © 2018 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-// Allow implicit conversion from char16_t* to UnicodeString for this file:
-// Helpful in toString methods and elsewhere.
-#define UNISTR_FROM_STRING_EXPLICIT
-
-#include <stdlib.h>
-#include <cmath>
-#include "number_asformat.h"
-#include "number_types.h"
-#include "number_utils.h"
-#include "fphdlimp.h"
-#include "number_utypes.h"
-
-using namespace icu;
-using namespace icu::number;
-using namespace icu::number::impl;
-
-UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LocalizedNumberFormatterAsFormat)
-
-LocalizedNumberFormatterAsFormat::LocalizedNumberFormatterAsFormat(
- const LocalizedNumberFormatter& formatter, const Locale& locale)
- : fFormatter(formatter), fLocale(locale) {
- const char* localeName = locale.getName();
- setLocaleIDs(localeName, localeName);
-}
-
-LocalizedNumberFormatterAsFormat::~LocalizedNumberFormatterAsFormat() = default;
-
-UBool LocalizedNumberFormatterAsFormat::operator==(const Format& other) const {
- auto* _other = dynamic_cast<const LocalizedNumberFormatterAsFormat*>(&other);
- if (_other == nullptr) {
- return false;
- }
- // TODO: Change this to use LocalizedNumberFormatter::operator== if it is ever proposed.
- // This implementation is fine, but not particularly efficient.
- UErrorCode localStatus = U_ZERO_ERROR;
- return fFormatter.toSkeleton(localStatus) == _other->fFormatter.toSkeleton(localStatus);
-}
-
-LocalizedNumberFormatterAsFormat* LocalizedNumberFormatterAsFormat::clone() const {
- return new LocalizedNumberFormatterAsFormat(*this);
-}
-
-UnicodeString& LocalizedNumberFormatterAsFormat::format(const Formattable& obj, UnicodeString& appendTo,
- FieldPosition& pos, UErrorCode& status) const {
- if (U_FAILURE(status)) { return appendTo; }
- UFormattedNumberData data;
- obj.populateDecimalQuantity(data.quantity, status);
- if (U_FAILURE(status)) {
- return appendTo;
- }
- fFormatter.formatImpl(&data, status);
- if (U_FAILURE(status)) {
- return appendTo;
- }
- // always return first occurrence:
- pos.setBeginIndex(0);
- pos.setEndIndex(0);
- bool found = data.nextFieldPosition(pos, status);
- if (found && appendTo.length() != 0) {
- pos.setBeginIndex(pos.getBeginIndex() + appendTo.length());
- pos.setEndIndex(pos.getEndIndex() + appendTo.length());
- }
- appendTo.append(data.toTempString(status));
- return appendTo;
-}
-
-UnicodeString& LocalizedNumberFormatterAsFormat::format(const Formattable& obj, UnicodeString& appendTo,
- FieldPositionIterator* posIter,
- UErrorCode& status) const {
- if (U_FAILURE(status)) { return appendTo; }
- UFormattedNumberData data;
- obj.populateDecimalQuantity(data.quantity, status);
- if (U_FAILURE(status)) {
- return appendTo;
- }
- fFormatter.formatImpl(&data, status);
- if (U_FAILURE(status)) {
- return appendTo;
- }
- appendTo.append(data.toTempString(status));
- if (posIter != nullptr) {
- FieldPositionIteratorHandler fpih(posIter, status);
- data.getAllFieldPositions(fpih, status);
- }
- return appendTo;
-}
-
-void LocalizedNumberFormatterAsFormat::parseObject(const UnicodeString&, Formattable&,
- ParsePosition& parse_pos) const {
- // Not supported.
- parse_pos.setErrorIndex(0);
-}
-
-const LocalizedNumberFormatter& LocalizedNumberFormatterAsFormat::getNumberFormatter() const {
- return fFormatter;
-}
-
-
-// Definitions of public API methods (put here for dependency disentanglement)
-
-Format* LocalizedNumberFormatter::toFormat(UErrorCode& status) const {
- if (U_FAILURE(status)) {
- return nullptr;
- }
- LocalPointer<LocalizedNumberFormatterAsFormat> retval(
- new LocalizedNumberFormatterAsFormat(*this, fMacros.locale), status);
- return retval.orphan();
-}
-
-#endif /* #if !UCONFIG_NO_FORMATTING */
+// © 2018 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+// Allow implicit conversion from char16_t* to UnicodeString for this file:
+// Helpful in toString methods and elsewhere.
+#define UNISTR_FROM_STRING_EXPLICIT
+
+#include <stdlib.h>
+#include <cmath>
+#include "number_asformat.h"
+#include "number_types.h"
+#include "number_utils.h"
+#include "fphdlimp.h"
+#include "number_utypes.h"
+
+using namespace icu;
+using namespace icu::number;
+using namespace icu::number::impl;
+
+UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LocalizedNumberFormatterAsFormat)
+
+LocalizedNumberFormatterAsFormat::LocalizedNumberFormatterAsFormat(
+ const LocalizedNumberFormatter& formatter, const Locale& locale)
+ : fFormatter(formatter), fLocale(locale) {
+ const char* localeName = locale.getName();
+ setLocaleIDs(localeName, localeName);
+}
+
+LocalizedNumberFormatterAsFormat::~LocalizedNumberFormatterAsFormat() = default;
+
+UBool LocalizedNumberFormatterAsFormat::operator==(const Format& other) const {
+ auto* _other = dynamic_cast<const LocalizedNumberFormatterAsFormat*>(&other);
+ if (_other == nullptr) {
+ return false;
+ }
+ // TODO: Change this to use LocalizedNumberFormatter::operator== if it is ever proposed.
+ // This implementation is fine, but not particularly efficient.
+ UErrorCode localStatus = U_ZERO_ERROR;
+ return fFormatter.toSkeleton(localStatus) == _other->fFormatter.toSkeleton(localStatus);
+}
+
+LocalizedNumberFormatterAsFormat* LocalizedNumberFormatterAsFormat::clone() const {
+ return new LocalizedNumberFormatterAsFormat(*this);
+}
+
+UnicodeString& LocalizedNumberFormatterAsFormat::format(const Formattable& obj, UnicodeString& appendTo,
+ FieldPosition& pos, UErrorCode& status) const {
+ if (U_FAILURE(status)) { return appendTo; }
+ UFormattedNumberData data;
+ obj.populateDecimalQuantity(data.quantity, status);
+ if (U_FAILURE(status)) {
+ return appendTo;
+ }
+ fFormatter.formatImpl(&data, status);
+ if (U_FAILURE(status)) {
+ return appendTo;
+ }
+ // always return first occurrence:
+ pos.setBeginIndex(0);
+ pos.setEndIndex(0);
+ bool found = data.nextFieldPosition(pos, status);
+ if (found && appendTo.length() != 0) {
+ pos.setBeginIndex(pos.getBeginIndex() + appendTo.length());
+ pos.setEndIndex(pos.getEndIndex() + appendTo.length());
+ }
+ appendTo.append(data.toTempString(status));
+ return appendTo;
+}
+
+UnicodeString& LocalizedNumberFormatterAsFormat::format(const Formattable& obj, UnicodeString& appendTo,
+ FieldPositionIterator* posIter,
+ UErrorCode& status) const {
+ if (U_FAILURE(status)) { return appendTo; }
+ UFormattedNumberData data;
+ obj.populateDecimalQuantity(data.quantity, status);
+ if (U_FAILURE(status)) {
+ return appendTo;
+ }
+ fFormatter.formatImpl(&data, status);
+ if (U_FAILURE(status)) {
+ return appendTo;
+ }
+ appendTo.append(data.toTempString(status));
+ if (posIter != nullptr) {
+ FieldPositionIteratorHandler fpih(posIter, status);
+ data.getAllFieldPositions(fpih, status);
+ }
+ return appendTo;
+}
+
+void LocalizedNumberFormatterAsFormat::parseObject(const UnicodeString&, Formattable&,
+ ParsePosition& parse_pos) const {
+ // Not supported.
+ parse_pos.setErrorIndex(0);
+}
+
+const LocalizedNumberFormatter& LocalizedNumberFormatterAsFormat::getNumberFormatter() const {
+ return fFormatter;
+}
+
+
+// Definitions of public API methods (put here for dependency disentanglement)
+
+Format* LocalizedNumberFormatter::toFormat(UErrorCode& status) const {
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+ LocalPointer<LocalizedNumberFormatterAsFormat> retval(
+ new LocalizedNumberFormatterAsFormat(*this, fMacros.locale), status);
+ return retval.orphan();
+}
+
+#endif /* #if !UCONFIG_NO_FORMATTING */