summaryrefslogtreecommitdiff
path: root/deps/icu-small/source/i18n/number_decimfmtprops.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/icu-small/source/i18n/number_decimfmtprops.h')
-rw-r--r--deps/icu-small/source/i18n/number_decimfmtprops.h79
1 files changed, 67 insertions, 12 deletions
diff --git a/deps/icu-small/source/i18n/number_decimfmtprops.h b/deps/icu-small/source/i18n/number_decimfmtprops.h
index 96356cad45..f288b6e0d9 100644
--- a/deps/icu-small/source/i18n/number_decimfmtprops.h
+++ b/deps/icu-small/source/i18n/number_decimfmtprops.h
@@ -3,7 +3,7 @@
#include "unicode/utypes.h"
-#if !UCONFIG_NO_FORMATTING && !UPRV_INCOMPLETE_CPP11_SUPPORT
+#if !UCONFIG_NO_FORMATTING
#ifndef __NUMBER_DECIMFMTPROPS_H__
#define __NUMBER_DECIMFMTPROPS_H__
@@ -30,21 +30,65 @@ template class U_I18N_API LocalPointer<CurrencyPluralInfo>;
namespace number {
namespace impl {
-// TODO: Figure out a nicer way to deal with CurrencyPluralInfo.
// Exported as U_I18N_API because it is a public member field of exported DecimalFormatProperties
-struct U_I18N_API CurrencyPluralInfoWrapper {
+// Using this wrapper is rather unfortunate, but is needed on Windows platforms in order to allow
+// for DLL-exporting an fully specified template instantiation.
+class U_I18N_API CurrencyPluralInfoWrapper {
+public:
LocalPointer<CurrencyPluralInfo> fPtr;
- CurrencyPluralInfoWrapper() {}
+ CurrencyPluralInfoWrapper() = default;
+
CurrencyPluralInfoWrapper(const CurrencyPluralInfoWrapper& other) {
if (!other.fPtr.isNull()) {
fPtr.adoptInstead(new CurrencyPluralInfo(*other.fPtr));
}
}
+
+ CurrencyPluralInfoWrapper& operator=(const CurrencyPluralInfoWrapper& other) {
+ if (!other.fPtr.isNull()) {
+ fPtr.adoptInstead(new CurrencyPluralInfo(*other.fPtr));
+ }
+ return *this;
+ }
+};
+
+/** Controls the set of rules for parsing a string from the old DecimalFormat API. */
+enum ParseMode {
+ /**
+ * Lenient mode should be used if you want to accept malformed user input. It will use heuristics
+ * to attempt to parse through typographical errors in the string.
+ */
+ PARSE_MODE_LENIENT,
+
+ /**
+ * Strict mode should be used if you want to require that the input is well-formed. More
+ * specifically, it differs from lenient mode in the following ways:
+ *
+ * <ul>
+ * <li>Grouping widths must match the grouping settings. For example, "12,3,45" will fail if the
+ * grouping width is 3, as in the pattern "#,##0".
+ * <li>The string must contain a complete prefix and suffix. For example, if the pattern is
+ * "{#};(#)", then "{123}" or "(123)" would match, but "{123", "123}", and "123" would all fail.
+ * (The latter strings would be accepted in lenient mode.)
+ * <li>Whitespace may not appear at arbitrary places in the string. In lenient mode, whitespace
+ * is allowed to occur arbitrarily before and after prefixes and exponent separators.
+ * <li>Leading grouping separators are not allowed, as in ",123".
+ * <li>Minus and plus signs can only appear if specified in the pattern. In lenient mode, a plus
+ * or minus sign can always precede a number.
+ * <li>The set of characters that can be interpreted as a decimal or grouping separator is
+ * smaller.
+ * <li><strong>If currency parsing is enabled,</strong> currencies must only appear where
+ * specified in either the current pattern string or in a valid pattern string for the current
+ * locale. For example, if the pattern is "ยค0.00", then "$1.23" would match, but "1.23$" would
+ * fail to match.
+ * </ul>
+ */
+ PARSE_MODE_STRICT,
};
// Exported as U_I18N_API because it is needed for the unit test PatternStringTest
-struct U_I18N_API DecimalFormatProperties {
+struct U_I18N_API DecimalFormatProperties : public UMemory {
public:
NullableValue<UNumberCompactStyle> compactStyle;
@@ -54,9 +98,11 @@ struct U_I18N_API DecimalFormatProperties {
bool decimalPatternMatchRequired;
bool decimalSeparatorAlwaysShown;
bool exponentSignAlwaysShown;
+ bool formatFailIfMoreThanMaxDigits; // ICU4C-only
int32_t formatWidth;
int32_t groupingSize;
- int32_t magnitudeMultiplier;
+ bool groupingUsed;
+ int32_t magnitudeMultiplier; // internal field like multiplierScale but separate to avoid conflict
int32_t maximumFractionDigits;
int32_t maximumIntegerDigits;
int32_t maximumSignificantDigits;
@@ -66,6 +112,7 @@ struct U_I18N_API DecimalFormatProperties {
int32_t minimumIntegerDigits;
int32_t minimumSignificantDigits;
int32_t multiplier;
+ int32_t multiplierScale; // ICU4C-only
UnicodeString negativePrefix;
UnicodeString negativePrefixPattern;
UnicodeString negativeSuffix;
@@ -74,9 +121,10 @@ struct U_I18N_API DecimalFormatProperties {
UnicodeString padString;
bool parseCaseSensitive;
bool parseIntegerOnly;
- bool parseLenient;
+ NullableValue<ParseMode> parseMode;
bool parseNoExponent;
- bool parseToBigDecimal;
+ bool parseToBigDecimal; // TODO: Not needed in ICU4C?
+ UNumberFormatAttributeValue parseAllInput; // ICU4C-only
//PluralRules pluralRules;
UnicodeString positivePrefix;
UnicodeString positivePrefixPattern;
@@ -89,13 +137,20 @@ struct U_I18N_API DecimalFormatProperties {
DecimalFormatProperties();
- //DecimalFormatProperties(const DecimalFormatProperties &other) = default;
+ inline bool operator==(const DecimalFormatProperties& other) const {
+ return _equals(other, false);
+ }
- DecimalFormatProperties &operator=(const DecimalFormatProperties &other) = default;
+ void clear();
- bool operator==(const DecimalFormatProperties &other) const;
+ /**
+ * Checks for equality to the default DecimalFormatProperties, but ignores the prescribed set of
+ * options for fast-path formatting.
+ */
+ bool equalsDefaultExceptFastFormat() const;
- void clear();
+ private:
+ bool _equals(const DecimalFormatProperties& other, bool ignoreForFastFormat) const;
};
} // namespace impl