diff options
author | mcheshkov <mcheshkov@yandex-team.ru> | 2022-02-10 16:46:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:15 +0300 |
commit | e9d19cec64684c9c1e6b0c98297e5b895cf904fe (patch) | |
tree | 2768b1223e96a8a0610a93d18425d9647c1123c8 /contrib/libs/icu/i18n/number_decnum.h | |
parent | 60040c91ffe701a84689b2c6310ff845e65cff42 (diff) | |
download | ydb-e9d19cec64684c9c1e6b0c98297e5b895cf904fe.tar.gz |
Restoring authorship annotation for <mcheshkov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/icu/i18n/number_decnum.h')
-rw-r--r-- | contrib/libs/icu/i18n/number_decnum.h | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/contrib/libs/icu/i18n/number_decnum.h b/contrib/libs/icu/i18n/number_decnum.h index 0c7399dbdd..bf953d6194 100644 --- a/contrib/libs/icu/i18n/number_decnum.h +++ b/contrib/libs/icu/i18n/number_decnum.h @@ -1,79 +1,79 @@ -// © 2017 and later: Unicode, Inc. and others. -// License & terms of use: http://www.unicode.org/copyright.html - -#include "unicode/utypes.h" - -#if !UCONFIG_NO_FORMATTING -#ifndef __NUMBER_DECNUM_H__ -#define __NUMBER_DECNUM_H__ - -#include "decNumber.h" -#include "charstr.h" - -U_NAMESPACE_BEGIN - -#define DECNUM_INITIAL_CAPACITY 34 - -// Export an explicit template instantiation of the MaybeStackHeaderAndArray that is used as a data member of DecNum. -// When building DLLs for Windows this is required even though no direct access to the MaybeStackHeaderAndArray leaks out of the i18n library. -// (See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples.) -#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN -template class U_I18N_API MaybeStackHeaderAndArray<decNumber, char, DECNUM_INITIAL_CAPACITY>; -#endif - -namespace number { -namespace impl { - -/** A very thin C++ wrapper around decNumber.h */ -// Exported as U_I18N_API for tests -class U_I18N_API DecNum : public UMemory { - public: - DecNum(); // leaves object in valid but undefined state - - // Copy-like constructor; use the default move operators. - DecNum(const DecNum& other, UErrorCode& status); - - /** Sets the decNumber to the StringPiece. */ - void setTo(StringPiece str, UErrorCode& status); - - /** Sets the decNumber to the NUL-terminated char string. */ - void setTo(const char* str, UErrorCode& status); - - /** Uses double_conversion to set this decNumber to the given double. */ - void setTo(double d, UErrorCode& status); - - /** Sets the decNumber to the BCD representation. */ - void setTo(const uint8_t* bcd, int32_t length, int32_t scale, bool isNegative, UErrorCode& status); - - void normalize(); - - void multiplyBy(const DecNum& rhs, UErrorCode& status); - - void divideBy(const DecNum& rhs, UErrorCode& status); - - bool isNegative() const; - - bool isZero() const; - - void toString(ByteSink& output, UErrorCode& status) const; - - inline const decNumber* getRawDecNumber() const { - return fData.getAlias(); - } - - private: - static constexpr int32_t kDefaultDigits = DECNUM_INITIAL_CAPACITY; - MaybeStackHeaderAndArray<decNumber, char, kDefaultDigits> fData; - decContext fContext; - - void _setTo(const char* str, int32_t maxDigits, UErrorCode& status); -}; - -} // namespace impl -} // namespace number - -U_NAMESPACE_END - -#endif // __NUMBER_DECNUM_H__ - -#endif /* #if !UCONFIG_NO_FORMATTING */ +// © 2017 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html + +#include "unicode/utypes.h" + +#if !UCONFIG_NO_FORMATTING +#ifndef __NUMBER_DECNUM_H__ +#define __NUMBER_DECNUM_H__ + +#include "decNumber.h" +#include "charstr.h" + +U_NAMESPACE_BEGIN + +#define DECNUM_INITIAL_CAPACITY 34 + +// Export an explicit template instantiation of the MaybeStackHeaderAndArray that is used as a data member of DecNum. +// When building DLLs for Windows this is required even though no direct access to the MaybeStackHeaderAndArray leaks out of the i18n library. +// (See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples.) +#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN +template class U_I18N_API MaybeStackHeaderAndArray<decNumber, char, DECNUM_INITIAL_CAPACITY>; +#endif + +namespace number { +namespace impl { + +/** A very thin C++ wrapper around decNumber.h */ +// Exported as U_I18N_API for tests +class U_I18N_API DecNum : public UMemory { + public: + DecNum(); // leaves object in valid but undefined state + + // Copy-like constructor; use the default move operators. + DecNum(const DecNum& other, UErrorCode& status); + + /** Sets the decNumber to the StringPiece. */ + void setTo(StringPiece str, UErrorCode& status); + + /** Sets the decNumber to the NUL-terminated char string. */ + void setTo(const char* str, UErrorCode& status); + + /** Uses double_conversion to set this decNumber to the given double. */ + void setTo(double d, UErrorCode& status); + + /** Sets the decNumber to the BCD representation. */ + void setTo(const uint8_t* bcd, int32_t length, int32_t scale, bool isNegative, UErrorCode& status); + + void normalize(); + + void multiplyBy(const DecNum& rhs, UErrorCode& status); + + void divideBy(const DecNum& rhs, UErrorCode& status); + + bool isNegative() const; + + bool isZero() const; + + void toString(ByteSink& output, UErrorCode& status) const; + + inline const decNumber* getRawDecNumber() const { + return fData.getAlias(); + } + + private: + static constexpr int32_t kDefaultDigits = DECNUM_INITIAL_CAPACITY; + MaybeStackHeaderAndArray<decNumber, char, kDefaultDigits> fData; + decContext fContext; + + void _setTo(const char* str, int32_t maxDigits, UErrorCode& status); +}; + +} // namespace impl +} // namespace number + +U_NAMESPACE_END + +#endif // __NUMBER_DECNUM_H__ + +#endif /* #if !UCONFIG_NO_FORMATTING */ |