summaryrefslogtreecommitdiff
path: root/deps/icu-small/source/i18n/unicode/decimfmt.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/icu-small/source/i18n/unicode/decimfmt.h')
-rw-r--r--deps/icu-small/source/i18n/unicode/decimfmt.h180
1 files changed, 114 insertions, 66 deletions
diff --git a/deps/icu-small/source/i18n/unicode/decimfmt.h b/deps/icu-small/source/i18n/unicode/decimfmt.h
index b3a5cc0495..097a38fb88 100644
--- a/deps/icu-small/source/i18n/unicode/decimfmt.h
+++ b/deps/icu-small/source/i18n/unicode/decimfmt.h
@@ -64,18 +64,6 @@ class NumberParserImpl;
}
/**
- * \cond
- * explicit template instantiation. see digitlst.h
- * (When building DLLs for Windows this is required.)
- */
-#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN && !defined(U_IN_DOXYGEN)
-template class U_I18N_API EnumSet<UNumberFormatAttribute,
- UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1,
- UNUM_LIMIT_BOOLEAN_ATTRIBUTE>;
-#endif
-/** \endcond */
-
-/**
* **IMPORTANT:** New users are strongly encouraged to see if
* numberformatter.h fits their use case. Although not deprecated, this header
* is provided for backwards compatibility only.
@@ -288,7 +276,7 @@ template class U_I18N_API EnumSet<UNumberFormatAttribute,
* <td>Pad escape, precedes pad character
* </table>
*
- * <p>A DecimalFormat pattern contains a postive and negative
+ * <p>A DecimalFormat pattern contains a positive and negative
* subpattern, for example, "#,##0.00;(#,##0.00)". Each subpattern has a
* prefix, a numeric part, and a suffix. If there is no explicit negative
* subpattern, the negative subpattern is the localized minus sign prefixed to the
@@ -423,7 +411,7 @@ template class U_I18N_API EnumSet<UNumberFormatAttribute,
*
* <li>If the number of actual fraction digits is less than the
* <em>minimum fraction digits</em>, then trailing zeros are added.
- * For example, 0.125 is formatted as "0.1250" if the mimimum fraction
+ * For example, 0.125 is formatted as "0.1250" if the minimum fraction
* digits is set to 4.
*
* <li>Trailing fractional zeros are not displayed if they occur
@@ -588,9 +576,9 @@ template class U_I18N_API EnumSet<UNumberFormatAttribute,
* count of <code>getMaximumSignificantDigits() - 1</code>. For example, the
* pattern <code>"@@###E0"</code> is equivalent to <code>"0.0###E0"</code>.
*
- * <li>If signficant digits are in use, then the integer and fraction
+ * <li>If significant digits are in use, then the integer and fraction
* digit counts, as set via the API, are ignored. If significant
- * digits are not in use, then the signficant digit counts, as set via
+ * digits are not in use, then the significant digit counts, as set via
* the API, are ignored.
*
* </ul>
@@ -644,7 +632,7 @@ template class U_I18N_API EnumSet<UNumberFormatAttribute,
* increment in the pattern itself. "#,#50" specifies a rounding increment of
* 50. "#,##0.05" specifies a rounding increment of 0.05.
*
- * <p>In the absense of an explicit rounding increment numbers are
+ * <p>In the absence of an explicit rounding increment numbers are
* rounded to their formatted width.
*
* <ul>
@@ -849,7 +837,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* @param pattern a non-localized pattern string
* @param symbolsToAdopt the set of symbols to be used. The caller should not
* delete this object after making this call.
- * @param parseError Output param to receive errors occured during parsing
+ * @param parseError Output param to receive errors occurred during parsing
* @param status Output param set to success/failure code. If the
* pattern is invalid this will be set to a failure code.
* @stable ICU 2.0
@@ -1127,7 +1115,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* does string comparisons to try to find an optimal match.
* If no object can be parsed, index is unchanged, and NULL is
* returned. The result is returned as the most parsimonious
- * type of Formattable that will accomodate all of the
+ * type of Formattable that will accommodate all of the
* necessary precision. For example, if the result is exactly 12,
* it will be returned as a long. However, if it is 1.5, it will
* be returned as a double.
@@ -1292,20 +1280,27 @@ class U_I18N_API DecimalFormat : public NumberFormat {
*/
virtual void setNegativeSuffix(const UnicodeString& newValue);
-#ifndef U_HIDE_INTERNAL_API
+#ifndef U_HIDE_DRAFT_API
/**
* Whether to show the plus sign on positive (non-negative) numbers; for example, "+12"
- * @internal Technical Preview
+ *
+ * For more control over sign display, use NumberFormatter.
+ *
+ * @return Whether the sign is shown on positive numbers and zero.
+ * @draft ICU 64
*/
UBool isSignAlwaysShown() const;
-#endif /* U_HIDE_INTERNAL_API */
/**
- * Set whether to show the plus sign on positive (non-negative) numbers; for example, "+12"
- * @param value The new setting for whether to show plus sign on positive numbers
- * @internal Technical Preview
+ * Set whether to show the plus sign on positive (non-negative) numbers; for example, "+12".
+ *
+ * For more control over sign display, use NumberFormatter.
+ *
+ * @param value true to always show a sign; false to hide the sign on positive numbers and zero.
+ * @draft ICU 64
*/
- virtual void setSignAlwaysShown(UBool value);
+ void setSignAlwaysShown(UBool value);
+#endif /* U_HIDE_DRAFT_API */
/**
* Get the multiplier for use in percent, permill, etc.
@@ -1350,7 +1345,6 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* @draft ICU 62
*/
int32_t getMultiplierScale(void) const;
-#endif /* U_HIDE_DRAFT_API */
/**
* Sets a power of ten by which number should be multiplied before formatting, which
@@ -1371,7 +1365,8 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* @param newValue the new value of the power-of-ten multiplier.
* @draft ICU 62
*/
- virtual void setMultiplierScale(int32_t newValue);
+ void setMultiplierScale(int32_t newValue);
+#endif /* U_HIDE_DRAFT_API */
/**
* Get the rounding increment.
@@ -1464,8 +1459,8 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* Set the character used to pad to the format width. If padding
* is not enabled, then this will take effect if padding is later
* enabled.
- * @param padChar a string containing the pad charcter. If the string
- * has length 0, then the pad characer is set to ' '. Otherwise
+ * @param padChar a string containing the pad character. If the string
+ * has length 0, then the pad character is set to ' '. Otherwise
* padChar.char32At(0) will be used as the pad character.
* @see #setFormatWidth
* @see #getFormatWidth
@@ -1654,8 +1649,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
*/
virtual void setSecondaryGroupingSize(int32_t newValue);
-#ifndef U_HIDE_INTERNAL_API
-
+#ifndef U_HIDE_DRAFT_API
/**
* Returns the minimum number of grouping digits.
* Grouping separators are output if there are at least this many
@@ -1666,31 +1660,33 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* For example, if this value is 2, and the grouping size is 3, then
* 9999 -> "9999" and 10000 -> "10,000"
*
- * This is a technology preview. This API may change behavior or may be removed.
- *
* The default value for this attribute is 0.
* A value of 1, 0, or lower, means that the use of grouping separators
* only depends on the grouping size (and on isGroupingUsed()).
- * Currently, the corresponding CLDR data is not used; this is likely to change.
+ *
+ * NOTE: The CLDR data is used in NumberFormatter but not in DecimalFormat.
+ * This is for backwards compatibility reasons.
+ *
+ * For more control over grouping strategies, use NumberFormatter.
*
* @see setMinimumGroupingDigits
* @see getGroupingSize
- * @internal technology preview
+ * @draft ICU 64
*/
int32_t getMinimumGroupingDigits() const;
-#endif /* U_HIDE_INTERNAL_API */
-
- /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following draft method since it is virtual. */
/**
* Sets the minimum grouping digits. Setting to a value less than or
* equal to 1 turns off minimum grouping digits.
*
+ * For more control over grouping strategies, use NumberFormatter.
+ *
* @param newValue the new value of minimum grouping digits.
* @see getMinimumGroupingDigits
- * @internal technology preview
+ * @draft ICU 64
*/
- virtual void setMinimumGroupingDigits(int32_t newValue);
+ void setMinimumGroupingDigits(int32_t newValue);
+#endif /* U_HIDE_DRAFT_API */
/**
@@ -1732,13 +1728,15 @@ class U_I18N_API DecimalFormat : public NumberFormat {
*/
virtual void setDecimalPatternMatchRequired(UBool newValue);
+#ifndef U_HIDE_DRAFT_API
/**
* Returns whether to ignore exponents when parsing.
*
+ * @return Whether to ignore exponents when parsing.
* @see #setParseNoExponent
- * @internal This API is a technical preview. It may change in an upcoming release.
+ * @draft ICU 64
*/
- virtual UBool isParseNoExponent() const;
+ UBool isParseNoExponent() const;
/**
* Specifies whether to stop parsing when an exponent separator is encountered. For
@@ -1746,17 +1744,18 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* 5).
*
* @param value true to prevent exponents from being parsed; false to allow them to be parsed.
- * @internal This API is a technical preview. It may change in an upcoming release.
+ * @draft ICU 64
*/
- virtual void setParseNoExponent(UBool value);
+ void setParseNoExponent(UBool value);
/**
* Returns whether parsing is sensitive to case (lowercase/uppercase).
*
+ * @return Whether parsing is case-sensitive.
* @see #setParseCaseSensitive
- * @internal This API is a technical preview. It may change in an upcoming release.
+ * @draft ICU 64
*/
- virtual UBool isParseCaseSensitive() const;
+ UBool isParseCaseSensitive() const;
/**
* Whether to pay attention to case when parsing; default is to ignore case (perform
@@ -1765,26 +1764,31 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* Currency symbols are never case-folded. For example, "us$1.00" will not parse in case-insensitive
* mode, even though "US$1.00" parses.
*
- * @internal This API is a technical preview. It may change in an upcoming release.
+ * @param value true to enable case-sensitive parsing (the default); false to force
+ * case-sensitive parsing behavior.
+ * @draft ICU 64
*/
- virtual void setParseCaseSensitive(UBool value);
+ void setParseCaseSensitive(UBool value);
/**
* Returns whether truncation of high-order integer digits should result in an error.
* By default, setMaximumIntegerDigits truncates high-order digits silently.
*
+ * @return Whether an error code is set if high-order digits are truncated.
* @see setFormatFailIfMoreThanMaxDigits
- * @internal This API is a technical preview. It may change in an upcoming release.
+ * @draft ICU 64
*/
- virtual UBool isFormatFailIfMoreThanMaxDigits() const;
+ UBool isFormatFailIfMoreThanMaxDigits() const;
/**
* Sets whether truncation of high-order integer digits should result in an error.
* By default, setMaximumIntegerDigits truncates high-order digits silently.
*
- * @internal This API is a technical preview. It may change in an upcoming release.
+ * @param value Whether to set an error code if high-order digits are truncated.
+ * @draft ICU 64
*/
- virtual void setFormatFailIfMoreThanMaxDigits(UBool value);
+ void setFormatFailIfMoreThanMaxDigits(UBool value);
+#endif /* U_HIDE_DRAFT_API */
/**
@@ -2062,8 +2066,32 @@ class U_I18N_API DecimalFormat : public NumberFormat {
#ifndef U_HIDE_DRAFT_API
/**
- * Converts this DecimalFormat to a NumberFormatter. Starting in ICU 60,
- * NumberFormatter is the recommended way to format numbers.
+ * Converts this DecimalFormat to a (Localized)NumberFormatter. Starting
+ * in ICU 60, NumberFormatter is the recommended way to format numbers.
+ * You can use the returned LocalizedNumberFormatter to format numbers and
+ * get a FormattedNumber, which contains a string as well as additional
+ * annotations about the formatted value.
+ *
+ * If a memory allocation failure occurs, the return value of this method
+ * might be null. If you are concerned about correct recovery from
+ * out-of-memory situations, use this pattern:
+ *
+ * <pre>
+ * FormattedNumber result;
+ * if (auto* ptr = df->toNumberFormatter(status)) {
+ * result = ptr->formatDouble(123, status);
+ * }
+ * </pre>
+ *
+ * If you are not concerned about out-of-memory situations, or if your
+ * environment throws exceptions when memory allocation failure occurs,
+ * you can chain the methods, like this:
+ *
+ * <pre>
+ * FormattedNumber result = df
+ * ->toNumberFormatter(status)
+ * ->formatDouble(123, status);
+ * </pre>
*
* NOTE: The returned LocalizedNumberFormatter is owned by this DecimalFormat.
* If a non-const method is called on the DecimalFormat, or if the DecimalFormat
@@ -2071,20 +2099,35 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* beyond the lifetime of the DecimalFormat, copy it to a local variable:
*
* <pre>
- * LocalizedNumberFormatter f = df->toNumberFormatter();
+ * LocalizedNumberFormatter lnf;
+ * if (auto* ptr = df->toNumberFormatter(status)) {
+ * lnf = *ptr;
+ * }
* </pre>
*
- * It is, however, safe to use the return value for chaining:
+ * @param status Set on failure, like U_MEMORY_ALLOCATION_ERROR.
+ * @return A pointer to an internal object, or nullptr on failure.
+ * Do not delete the return value!
+ * @draft ICU 64
+ */
+ const number::LocalizedNumberFormatter* toNumberFormatter(UErrorCode& status) const;
+#endif /* U_HIDE_DRAFT_API */
+
+#ifndef U_HIDE_DEPRECATED_API
+ /**
+ * Deprecated: Like {@link #toNumberFormatter(UErrorCode&) const},
+ * but does not take an error code.
*
- * <pre>
- * FormattedNumber result = df->toNumberFormatter().formatDouble(123, status);
- * </pre>
+ * The new signature should be used in case an error occurs while returning the
+ * LocalizedNumberFormatter.
*
- * @return The output variable, for chaining.
- * @draft ICU 62
+ * This old signature will be removed in ICU 65.
+ *
+ * @return A reference to an internal object.
+ * @deprecated ICU 64
*/
const number::LocalizedNumberFormatter& toNumberFormatter() const;
-#endif /* U_HIDE_DRAFT_API */
+#endif /* U_HIDE_DEPRECATED_API */
/**
* Return the class ID for this class. This is useful only for
@@ -2117,7 +2160,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
/** Rebuilds the formatter object from the property bag. */
void touch(UErrorCode& status);
- /** Rebuilds the formatter object, hiding the error code. */
+ /** Rebuilds the formatter object, ignoring any error code. */
void touchNoError();
/**
@@ -2156,12 +2199,17 @@ class U_I18N_API DecimalFormat : public NumberFormat {
// INSTANCE FIELDS //
//=====================================================================================//
- // Only one instance field: keep all fields inside of an implementation class defined in number_mapper.h
- number::impl::DecimalFormatFields* fields;
+
+ // One instance field for the implementation, keep all fields inside of an implementation
+ // class defined in number_mapper.h
+ number::impl::DecimalFormatFields* fields = nullptr;
// Allow child class CompactDecimalFormat to access fProperties:
friend class CompactDecimalFormat;
+ // Allow MeasureFormat to use fieldPositionHelper:
+ friend class MeasureFormat;
+
};
U_NAMESPACE_END