aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/i18n/number_roundingutils.h
diff options
context:
space:
mode:
authorromankoshelev <romankoshelev@yandex-team.com>2023-08-09 20:07:20 +0300
committerromankoshelev <romankoshelev@yandex-team.com>2023-08-09 20:59:13 +0300
commitfd82fb12fb45e71a02c628e45b12c50c0dd0d308 (patch)
treef582b79f9002ab1d083e9acda600dfb3551c47b6 /contrib/libs/icu/i18n/number_roundingutils.h
parentbf862ddf5c6178e1bb5e4fb3f7c61015deebe284 (diff)
downloadydb-fd82fb12fb45e71a02c628e45b12c50c0dd0d308.tar.gz
Update ICU to 70.1
Diffstat (limited to 'contrib/libs/icu/i18n/number_roundingutils.h')
-rw-r--r--contrib/libs/icu/i18n/number_roundingutils.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/contrib/libs/icu/i18n/number_roundingutils.h b/contrib/libs/icu/i18n/number_roundingutils.h
index 3e37f31954..06fadd29fd 100644
--- a/contrib/libs/icu/i18n/number_roundingutils.h
+++ b/contrib/libs/icu/i18n/number_roundingutils.h
@@ -8,6 +8,7 @@
#define __NUMBER_ROUNDINGUTILS_H__
#include "number_types.h"
+#include "string_segment.h"
U_NAMESPACE_BEGIN
namespace number {
@@ -44,6 +45,9 @@ enum Section {
inline bool
getRoundingDirection(bool isEven, bool isNegative, Section section, RoundingMode roundingMode,
UErrorCode &status) {
+ if (U_FAILURE(status)) {
+ return false;
+ }
switch (roundingMode) {
case RoundingMode::UNUM_ROUND_UP:
// round away from zero
@@ -100,6 +104,45 @@ getRoundingDirection(bool isEven, bool isNegative, Section section, RoundingMode
}
break;
+ case RoundingMode::UNUM_ROUND_HALF_ODD:
+ switch (section) {
+ case SECTION_MIDPOINT:
+ return !isEven;
+ case SECTION_LOWER:
+ return true;
+ case SECTION_UPPER:
+ return false;
+ default:
+ break;
+ }
+ break;
+
+ case RoundingMode::UNUM_ROUND_HALF_CEILING:
+ switch (section) {
+ case SECTION_MIDPOINT:
+ return isNegative;
+ case SECTION_LOWER:
+ return true;
+ case SECTION_UPPER:
+ return false;
+ default:
+ break;
+ }
+ break;
+
+ case RoundingMode::UNUM_ROUND_HALF_FLOOR:
+ switch (section) {
+ case SECTION_MIDPOINT:
+ return !isNegative;
+ case SECTION_LOWER:
+ return true;
+ case SECTION_UPPER:
+ return false;
+ default:
+ break;
+ }
+ break;
+
default:
break;
}
@@ -187,8 +230,22 @@ class RoundingImpl {
Precision fPrecision;
UNumberFormatRoundingMode fRoundingMode;
bool fPassThrough = true; // default value
+
+ // Permits access to fPrecision.
+ friend class units::UnitsRouter;
+
+ // Permits access to fPrecision.
+ friend class UnitConversionHandler;
};
+/**
+ * Parses Precision-related skeleton strings without knowledge of MacroProps
+ * - see blueprint_helpers::parseIncrementOption().
+ *
+ * Referencing MacroProps means needing to pull in the .o files that have the
+ * destructors for the SymbolsWrapper, StringProp, and Scale classes.
+ */
+void parseIncrementOption(const StringSegment &segment, Precision &outPrecision, UErrorCode &status);
} // namespace impl
} // namespace number