diff options
author | Steven R. Loomis <srloomis@us.ibm.com> | 2018-10-17 09:43:52 -0700 |
---|---|---|
committer | Steven R. Loomis <srloomis@us.ibm.com> | 2018-10-24 08:27:36 -0700 |
commit | 6786ff4d3688512d8b717ec24188818ac5493d0b (patch) | |
tree | ab18b7a66afee52420fe0bedf7b38eb93f671373 /deps/icu-small/source/i18n/unicode | |
parent | d8f2d2726143ecfbf99b90b7bbbc6f41b3cd95fc (diff) | |
download | android-node-v8-6786ff4d3688512d8b717ec24188818ac5493d0b.tar.gz android-node-v8-6786ff4d3688512d8b717ec24188818ac5493d0b.tar.bz2 android-node-v8-6786ff4d3688512d8b717ec24188818ac5493d0b.zip |
deps: icu 63.1 bump (CLDR 34)
- Full release notes: http://site.icu-project.org/download/63
Fixes: https://github.com/nodejs/node/issues/22344
PR-URL: https://github.com/nodejs/node/pull/23715
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'deps/icu-small/source/i18n/unicode')
34 files changed, 1892 insertions, 304 deletions
diff --git a/deps/icu-small/source/i18n/unicode/alphaindex.h b/deps/icu-small/source/i18n/unicode/alphaindex.h index 54bd29ff88..4ebdf1cc56 100644 --- a/deps/icu-small/source/i18n/unicode/alphaindex.h +++ b/deps/icu-small/source/i18n/unicode/alphaindex.h @@ -266,6 +266,8 @@ public: * Use getBucket() to get the bucket's properties. * * @param name the string to be sorted into an index bucket + * @param errorCode Error code, will be set with the reason if the + * operation fails. * @return the bucket number for the name * @stable ICU 51 */ @@ -377,9 +379,10 @@ public: /** - * Get the default label used for abbreviated buckets <i>between</i> other index characters. - * For example, consider the labels when Latin and Greek are used: - * X Y Z ... Α Β Γ. + * Get the default label used for abbreviated buckets *between* other index characters. + * For example, consider the labels when Latin (X Y Z) and Greek (Α Β Γ) are used: + * + * X Y Z ... Α Β Γ. * * @return inflow label * @stable ICU 4.8 @@ -700,6 +703,7 @@ public: /** * A (name, data) pair, to be sorted by name into one of the index buckets. * The user data is not used by the index implementation. + * \cond * @internal */ struct Record: public UMemory { @@ -708,6 +712,7 @@ public: Record(const UnicodeString &name, const void *data); ~Record(); }; + /** \endcond */ #endif /* U_HIDE_INTERNAL_API */ private: diff --git a/deps/icu-small/source/i18n/unicode/calendar.h b/deps/icu-small/source/i18n/unicode/calendar.h index 48021534b4..023cf053f2 100644 --- a/deps/icu-small/source/i18n/unicode/calendar.h +++ b/deps/icu-small/source/i18n/unicode/calendar.h @@ -52,83 +52,64 @@ typedef int32_t UFieldResolutionTable[12][8]; class BasicTimeZone; /** - * <code>Calendar</code> is an abstract base class for converting between - * a <code>UDate</code> object and a set of integer fields such as - * <code>YEAR</code>, <code>MONTH</code>, <code>DAY</code>, <code>HOUR</code>, - * and so on. (A <code>UDate</code> object represents a specific instant in + * `Calendar` is an abstract base class for converting between + * a `UDate` object and a set of integer fields such as + * `YEAR`, `MONTH`, `DAY`, `HOUR`, and so on. + * (A `UDate` object represents a specific instant in * time with millisecond precision. See UDate - * for information about the <code>UDate</code> class.) + * for information about the `UDate` class.) * - * <p> - * Subclasses of <code>Calendar</code> interpret a <code>UDate</code> + * Subclasses of `Calendar` interpret a `UDate` * according to the rules of a specific calendar system. - * The most commonly used subclass of <code>Calendar</code> is - * <code>GregorianCalendar</code>. Other subclasses could represent + * The most commonly used subclass of `Calendar` is + * `GregorianCalendar`. Other subclasses could represent * the various types of lunar calendars in use in many parts of the world. * - * <p> - * <b>NOTE</b>: (ICU 2.6) The subclass interface should be considered unstable - * - it WILL change. + * **NOTE**: (ICU 2.6) The subclass interface should be considered unstable - + * it WILL change. * - * <p> - * Like other locale-sensitive classes, <code>Calendar</code> provides a - * static method, <code>createInstance</code>, for getting a generally useful - * object of this type. <code>Calendar</code>'s <code>createInstance</code> method - * returns the appropriate <code>Calendar</code> subclass whose + * Like other locale-sensitive classes, `Calendar` provides a + * static method, `createInstance`, for getting a generally useful + * object of this type. `Calendar`'s `createInstance` method + * returns the appropriate `Calendar` subclass whose * time fields have been initialized with the current date and time: - * \htmlonly<blockquote>\endhtmlonly - * <pre> - * Calendar *rightNow = Calendar::createInstance(errCode); - * </pre> - * \htmlonly</blockquote>\endhtmlonly * - * <p> - * A <code>Calendar</code> object can produce all the time field values + * Calendar *rightNow = Calendar::createInstance(errCode); + * + * A `Calendar` object can produce all the time field values * needed to implement the date-time formatting for a particular language * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional). * - * <p> - * When computing a <code>UDate</code> from time fields, some special circumstances + * When computing a `UDate` from time fields, some special circumstances * may arise: there may be insufficient information to compute the - * <code>UDate</code> (such as only year and month but no day in the month), + * `UDate` (such as only year and month but no day in the month), * there may be inconsistent information (such as "Tuesday, July 15, 1996" * -- July 15, 1996 is actually a Monday), or the input time might be ambiguous * because of time zone transition. * - * <p> - * <strong>Insufficient information.</strong> The calendar will use default + * **Insufficient information.** The calendar will use default * information to specify the missing fields. This may vary by calendar; for * the Gregorian calendar, the default for a field is the same as that of the * start of the epoch: i.e., YEAR = 1970, MONTH = JANUARY, DATE = 1, etc. * - * <p> - * <strong>Inconsistent information.</strong> If fields conflict, the calendar + * **Inconsistent information.** If fields conflict, the calendar * will give preference to fields set more recently. For example, when * determining the day, the calendar will look for one of the following * combinations of fields. The most recent combination, as determined by the * most recently set single field, will be used. * - * \htmlonly<blockquote>\endhtmlonly - * <pre> - * MONTH + DAY_OF_MONTH - * MONTH + WEEK_OF_MONTH + DAY_OF_WEEK - * MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK - * DAY_OF_YEAR - * DAY_OF_WEEK + WEEK_OF_YEAR - * </pre> - * \htmlonly</blockquote>\endhtmlonly + * MONTH + DAY_OF_MONTH + * MONTH + WEEK_OF_MONTH + DAY_OF_WEEK + * MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK + * DAY_OF_YEAR + * DAY_OF_WEEK + WEEK_OF_YEAR * * For the time of day: * - * \htmlonly<blockquote>\endhtmlonly - * <pre> - * HOUR_OF_DAY - * AM_PM + HOUR - * </pre> - * \htmlonly</blockquote>\endhtmlonly + * HOUR_OF_DAY + * AM_PM + HOUR * - * <p> - * <strong>Ambiguous Wall Clock Time.</strong> When time offset from UTC has + * **Ambiguous Wall Clock Time.** When time offset from UTC has * changed, it produces an ambiguous time slot around the transition. For example, * many US locations observe daylight saving time. On the date switching to daylight * saving time in US, wall clock time jumps from 12:59 AM (standard) to 2:00 AM @@ -138,64 +119,66 @@ class BasicTimeZone; * In this example, 1:30 AM is interpreted as 1:30 AM standard time (non-exist), * so the final result will be 2:30 AM daylight time. * - * <p>On the date switching back to standard time, wall clock time is moved back one + * On the date switching back to standard time, wall clock time is moved back one * hour at 2:00 AM. So wall clock time from 1:00 AM to 1:59 AM occur twice. In this * case, the ICU Calendar resolves the time using the UTC offset after the transition * by default. For example, 1:30 AM on the date is resolved as 1:30 AM standard time. * - * <p>Ambiguous wall clock time resolution behaviors can be customized by Calendar APIs + * Ambiguous wall clock time resolution behaviors can be customized by Calendar APIs * {@link #setRepeatedWallTimeOption} and {@link #setSkippedWallTimeOption}. * These methods are available in ICU 49 or later versions. * - * <p> - * <strong>Note:</strong> for some non-Gregorian calendars, different + * **Note:** for some non-Gregorian calendars, different * fields may be necessary for complete disambiguation. For example, a full - * specification of the historial Arabic astronomical calendar requires year, - * month, day-of-month <em>and</em> day-of-week in some cases. + * specification of the historical Arabic astronomical calendar requires year, + * month, day-of-month *and* day-of-week in some cases. * - * <p> - * <strong>Note:</strong> There are certain possible ambiguities in + * **Note:** There are certain possible ambiguities in * interpretation of certain singular times, which are resolved in the * following ways: - * <ol> - * <li> 24:00:00 "belongs" to the following day. That is, - * 23:59 on Dec 31, 1969 < 24:00 on Jan 1, 1970 < 24:01:00 on Jan 1, 1970 * - * <li> Although historically not precise, midnight also belongs to "am", - * and noon belongs to "pm", so on the same day, - * 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm - * </ol> + * 1. 24:00:00 "belongs" to the following day. That is, + * 23:59 on Dec 31, 1969 < 24:00 on Jan 1, 1970 < 24:01:00 on Jan 1, 1970 + * 2. Although historically not precise, midnight also belongs to "am", + * and noon belongs to "pm", so on the same day, + * 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm * - * <p> * The date or time format strings are not part of the definition of a * calendar, as those must be modifiable or overridable by the user at - * runtime. Use {@link DateFormat} - * to format dates. + * runtime. Use `DateFormat` to format dates. * - * <p> - * <code>Calendar</code> provides an API for field "rolling", where fields + * `Calendar` provides an API for field "rolling", where fields * can be incremented or decremented, but wrap around. For example, rolling the - * month up in the date <code>December 12, <b>1996</b></code> results in - * <code>January 12, <b>1996</b></code>. + * month up in the date December 12, **1996** results in + * January 12, **1996**. * - * <p> - * <code>Calendar</code> also provides a date arithmetic function for + * `Calendar` also provides a date arithmetic function for * adding the specified (signed) amount of time to a particular time field. - * For example, subtracting 5 days from the date <code>September 12, 1996</code> - * results in <code>September 7, 1996</code>. + * For example, subtracting 5 days from the date `September 12, 1996` + * results in `September 7, 1996`. * - * <p><big><b>Supported range</b></big> + * ***Supported range*** * - * <p>The allowable range of <code>Calendar</code> has been - * narrowed. <code>GregorianCalendar</code> used to attempt to support - * the range of dates with millisecond values from - * <code>Long.MIN_VALUE</code> to <code>Long.MAX_VALUE</code>. - * The new <code>Calendar</code> protocol specifies the + * The allowable range of `Calendar` has been narrowed. `GregorianCalendar` used + * to attempt to support the range of dates with millisecond values from + * `Long.MIN_VALUE` to `Long.MAX_VALUE`. The new `Calendar` protocol specifies the * maximum range of supportable dates as those having Julian day numbers - * of <code>-0x7F000000</code> to <code>+0x7F000000</code>. This - * corresponds to years from ~5,800,000 BCE to ~5,800,000 CE. Programmers - * should use the protected constants in <code>Calendar</code> to - * specify an extremely early or extremely late date.</p> + * of `-0x7F000000` to `+0x7F000000`. This corresponds to years from ~5,800,000 BCE + * to ~5,800,000 CE. Programmers should use the protected constants in `Calendar` to + * specify an extremely early or extremely late date. + * + * <p> + * The Japanese calendar uses a combination of era name and year number. + * When an emperor of Japan abdicates and a new emperor ascends the throne, + * a new era is declared and year number is reset to 1. Even if the date of + * abdication is scheduled ahead of time, the new era name might not be + * announced until just before the date. In such case, ICU4C may include + * a start date of future era without actual era name, but not enabled + * by default. ICU4C users who want to test the behavior of the future era + * can enable the tentative era by: + * <ul> + * <li>Environment variable <code>ICU_ENABLE_TENTATIVE_ERA=true</code>.</li> + * </ul> * * @stable ICU 2.0 */ @@ -903,7 +886,7 @@ public: /** * Sets the behavior for handling wall time repeating multiple times * at negative time zone offset transitions. For example, 1:30 AM on - * November 6, 2011 in US Eastern time (Ameirca/New_York) occurs twice; + * November 6, 2011 in US Eastern time (America/New_York) occurs twice; * 1:30 AM EDT, then 1:30 AM EST one hour later. When <code>UCAL_WALLTIME_FIRST</code> * is used, the wall time 1:30AM in this example will be interpreted as 1:30 AM EDT * (first occurrence). When <code>UCAL_WALLTIME_LAST</code> is used, it will be @@ -1718,9 +1701,7 @@ protected: /** * Validate a single field of this calendar. Subclasses should * override this method to validate any calendar-specific fields. - * Generic fields can be handled by - * <code>Calendar::validateField()</code>. - * @see #validateField(int, int, int, int&) + * Generic fields can be handled by `Calendar::validateField()`. * @internal */ virtual void validateField(UCalendarDateFields field, UErrorCode &status); @@ -2171,7 +2152,7 @@ private: TimeZone* fZone; /** - * Option for rpeated wall time + * Option for repeated wall time * @see #setRepeatedWallTimeOption */ UCalendarWallTimeOption fRepeatedWallTime; @@ -2456,7 +2437,7 @@ private: BasicTimeZone* getBasicTimeZone() const; /** - * Find the previous zone transtion near the given time. + * Find the previous zone transition near the given time. * @param base The base time, inclusive * @param transitionTime Receives the result time * @param status The error status diff --git a/deps/icu-small/source/i18n/unicode/coll.h b/deps/icu-small/source/i18n/unicode/coll.h index d03570509e..653434f54c 100644 --- a/deps/icu-small/source/i18n/unicode/coll.h +++ b/deps/icu-small/source/i18n/unicode/coll.h @@ -235,16 +235,16 @@ public: * Returns TRUE if "other" is the same as "this". * * The base class implementation returns TRUE if "other" has the same type/class as "this": - * <code>typeid(*this) == typeid(other)</code>. + * `typeid(*this) == typeid(other)`. * * Subclass implementations should do something like the following: - * <pre> - * if (this == &other) { return TRUE; } - * if (!Collator::operator==(other)) { return FALSE; } // not the same class * - * const MyCollator &o = (const MyCollator&)other; - * (compare this vs. o's subclass fields) - * </pre> + * if (this == &other) { return TRUE; } + * if (!Collator::operator==(other)) { return FALSE; } // not the same class + * + * const MyCollator &o = (const MyCollator&)other; + * (compare this vs. o's subclass fields) + * * @param other Collator object to be compared * @return TRUE if other is the same as this. * @stable ICU 2.0 diff --git a/deps/icu-small/source/i18n/unicode/compactdecimalformat.h b/deps/icu-small/source/i18n/unicode/compactdecimalformat.h index 7dc92f6100..9c1e9183f4 100644 --- a/deps/icu-small/source/i18n/unicode/compactdecimalformat.h +++ b/deps/icu-small/source/i18n/unicode/compactdecimalformat.h @@ -30,30 +30,31 @@ U_NAMESPACE_BEGIN class PluralRules; /** - * <p><strong>IMPORTANT:</strong> New users are strongly encouraged to see if + * **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. - * <hr/> + * + * ----------------------------------------------------------------------------- * * The CompactDecimalFormat produces abbreviated numbers, suitable for display in * environments will limited real estate. For example, 'Hits: 1.2B' instead of * 'Hits: 1,200,000,000'. The format will be appropriate for the given language, * such as "1,2 Mrd." for German. - * <p> + * * For numbers under 1000 trillion (under 10^15, such as 123,456,789,012,345), * the result will be short for supported languages. However, the result may * sometimes exceed 7 characters, such as when there are combining marks or thin * characters. In such cases, the visual width in fonts should still be short. - * <p> + * * By default, there are 3 significant digits. After creation, if more than * three significant digits are set (with setMaximumSignificantDigits), or if a * fixed number of digits are set (with setMaximumIntegerDigits or * setMaximumFractionDigits), then result may be wider. - * <p> + * * At this time, parsing is not supported, and will produce a U_UNSUPPORTED_ERROR. * Resetting the pattern prefixes or suffixes is not supported; the method calls * are ignored. - * <p> + * * @stable ICU 51 */ class U_I18N_API CompactDecimalFormat : public DecimalFormat { @@ -61,9 +62,9 @@ public: /** * Returns a compact decimal instance for specified locale. - * <p> - * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * + * **NOTE:** New users are strongly encouraged to use + * `number::NumberFormatter` instead of NumberFormat. * @param inLocale the given locale. * @param style whether to use short or long style. * @param status error code returned here. diff --git a/deps/icu-small/source/i18n/unicode/currpinf.h b/deps/icu-small/source/i18n/unicode/currpinf.h index 1a327c5bae..80b0462513 100644 --- a/deps/icu-small/source/i18n/unicode/currpinf.h +++ b/deps/icu-small/source/i18n/unicode/currpinf.h @@ -2,7 +2,7 @@ // License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* - * Copyright (C) 2009-2015, International Business Machines Corporation and * + * Copyright (C) 2009-2015, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -240,18 +240,27 @@ private: /* * The plural rule is used to format currency plural name, * for example: "3.00 US Dollars". - * If there are 3 currency signs in the currency patttern, + * If there are 3 currency signs in the currency pattern, * the 3 currency signs will be replaced by currency plural name. */ PluralRules* fPluralRules; // locale Locale* fLocale; + +private: + /** + * An internal status variable used to indicate that the object is in an 'invalid' state. + * Used by copy constructor, the assignment operator and the clone method. + */ + UErrorCode fInternalStatus; }; inline UBool -CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const { return !operator==(info); } +CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const { + return !operator==(info); +} U_NAMESPACE_END diff --git a/deps/icu-small/source/i18n/unicode/currunit.h b/deps/icu-small/source/i18n/unicode/currunit.h index d5bc4aa6d6..48cadc10b7 100644 --- a/deps/icu-small/source/i18n/unicode/currunit.h +++ b/deps/icu-small/source/i18n/unicode/currunit.h @@ -38,7 +38,7 @@ class U_I18N_API CurrencyUnit: public MeasureUnit { public: /** * Default constructor. Initializes currency code to "XXX" (no currency). - * @draft ICU 60 + * @stable ICU 60 */ CurrencyUnit(); @@ -59,17 +59,15 @@ class U_I18N_API CurrencyUnit: public MeasureUnit { */ CurrencyUnit(const CurrencyUnit& other); -#ifndef U_HIDE_DRAFT_API /** * Copy constructor from MeasureUnit. This constructor allows you to * restore a CurrencyUnit that was sliced to MeasureUnit. * * @param measureUnit The MeasureUnit to copy from. * @param ec Set to a failing value if the MeasureUnit is not a currency. - * @draft ICU 60 + * @stable ICU 60 */ CurrencyUnit(const MeasureUnit& measureUnit, UErrorCode &ec); -#endif /* U_HIDE_DRAFT_API */ /** * Assignment operator diff --git a/deps/icu-small/source/i18n/unicode/datefmt.h b/deps/icu-small/source/i18n/unicode/datefmt.h index c895183931..13c63d9376 100644 --- a/deps/icu-small/source/i18n/unicode/datefmt.h +++ b/deps/icu-small/source/i18n/unicode/datefmt.h @@ -43,13 +43,17 @@ U_NAMESPACE_BEGIN class TimeZone; class DateTimePatternGenerator; -// 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 +/** + * \cond + * Export an explicit template instantiation. (See digitlst.h, datefmt.h, and others.) + * (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<UDateFormatBooleanAttribute, 0, UDAT_BOOLEAN_ATTRIBUTE_COUNT>; #endif +/** \endcond */ /** * DateFormat is an abstract class for a family of classes that convert dates and diff --git a/deps/icu-small/source/i18n/unicode/dcfmtsym.h b/deps/icu-small/source/i18n/unicode/dcfmtsym.h index 2f824cec30..55e3d8a6b3 100644 --- a/deps/icu-small/source/i18n/unicode/dcfmtsym.h +++ b/deps/icu-small/source/i18n/unicode/dcfmtsym.h @@ -181,7 +181,6 @@ public: */ DecimalFormatSymbols(const Locale& locale, UErrorCode& status); -#ifndef U_HIDE_DRAFT_API /** * Creates a DecimalFormatSymbols instance for the given locale with digits and symbols * corresponding to the given NumberingSystem. @@ -196,10 +195,9 @@ public: * @param ns The numbering system. * @param status Input/output parameter, set to success or * failure code upon return. - * @draft ICU 60 + * @stable ICU 60 */ DecimalFormatSymbols(const Locale& locale, const NumberingSystem& ns, UErrorCode& status); -#endif /* U_HIDE_DRAFT_API */ /** * Create a DecimalFormatSymbols object for the default locale. @@ -406,7 +404,7 @@ public: * returning a const reference to one of the symbol strings. * The returned reference becomes invalid when the symbol is changed * or when the DecimalFormatSymbols are destroyed. - * Note: moved #ifndef U_HIDE_INTERNAL_API after this, since this is needed for inline in DecimalFormat + * Note: moved \#ifndef U_HIDE_INTERNAL_API after this, since this is needed for inline in DecimalFormat * * This is not currently stable API, but if you think it should be stable, * post a comment on the following ticket and the ICU team will take a look: @@ -531,7 +529,7 @@ inline const UnicodeString& DecimalFormatSymbols::getConstDigitSymbol(int32_t di ENumberFormatSymbol key = static_cast<ENumberFormatSymbol>(kOneDigitSymbol + digit - 1); return fSymbols[key]; } -#endif +#endif /* U_HIDE_INTERNAL_API */ // ------------------------------------- diff --git a/deps/icu-small/source/i18n/unicode/decimfmt.h b/deps/icu-small/source/i18n/unicode/decimfmt.h index 3747f510f7..b3a5cc0495 100644 --- a/deps/icu-small/source/i18n/unicode/decimfmt.h +++ b/deps/icu-small/source/i18n/unicode/decimfmt.h @@ -63,19 +63,22 @@ class NumberParserImpl; } } -// 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 +/** + * \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 */ /** - * <p><strong>IMPORTANT:</strong> New users are strongly encouraged to see if + * **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. - * <hr/> * * DecimalFormat is a concrete subclass of NumberFormat that formats decimal * numbers. It has a variety of features designed to make it possible to parse @@ -85,13 +88,13 @@ template class U_I18N_API EnumSet<UNumberFormatAttribute, * ("1.23E4"), percentages ("12%"), and currency amounts ("$123", "USD123", * "123 US dollars"). All of these flavors can be easily localized. * - * <p>To obtain a NumberFormat for a specific locale (including the default + * To obtain a NumberFormat for a specific locale (including the default * locale) call one of NumberFormat's factory methods such as * createInstance(). Do not call the DecimalFormat constructors directly, unless * you know what you are doing, since the NumberFormat factory methods may * return subclasses other than DecimalFormat. * - * <p><strong>Example Usage</strong> + * **Example Usage** * * \code * // Normally we would have a GUI with a menu for this @@ -135,11 +138,11 @@ template class U_I18N_API EnumSet<UNumberFormatAttribute, * } * } * \endcode - * <P> - * Another example use createInstance(style) - * <P> - * <pre> - * <strong>// Print out a number using the localized number, currency, + * + * **Another example use createInstance(style)** + * + * \code + * // Print out a number using the localized number, currency, * // percent, scientific, integer, iso currency, and plural currency * // format for each locale</strong> * Locale* locale = new Locale("en", "US"); @@ -150,11 +153,13 @@ template class U_I18N_API EnumSet<UNumberFormatAttribute, * for (int j=NumberFormat::kNumberStyle; * j<=NumberFormat::kPluralCurrencyStyle; * ++j) { - * NumberFormat* format = NumberFormat::createInstance(locale, j, success); + * NumberFormat* form = NumberFormat::createInstance(locale, j, success); * str.remove(); * cout << "format result " << form->format(myNumber, str) << endl; * format->parse(form->format(myNumber, str), fmtable, success); - * }</pre> + * delete form; + * } + * \endcode * * * <p><strong>Patterns</strong> @@ -690,7 +695,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { * locale. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of DecimalFormat. + * #icu::number::NumberFormatter instead of DecimalFormat. * @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 @@ -708,7 +713,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { * locale. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of DecimalFormat. + * #icu::number::NumberFormatter instead of DecimalFormat. * @param pattern A non-localized pattern string. * @param status Output param set to success/failure code. If the * pattern is invalid this will be set to a failure code. @@ -728,7 +733,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { * a NumberFormat factory method. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of DecimalFormat. + * #icu::number::NumberFormatter instead of DecimalFormat. * * @param pattern a non-localized pattern string * @param symbolsToAdopt the set of symbols to be used. The caller should not @@ -782,7 +787,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { * May return U_UNSUPPORTED_ERROR if this instance does not support * the specified attribute. * @param attr the attribute to set - * @param newvalue new value + * @param newValue new value * @param status the error type * @return *this - for chaining (example: format.setAttribute(...).setAttribute(...) ) * @stable ICU 51 @@ -839,7 +844,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { * a NumberFormat factory method. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of DecimalFormat. + * #icu::number::NumberFormatter instead of DecimalFormat. * * @param pattern a non-localized pattern string * @param symbolsToAdopt the set of symbols to be used. The caller should not @@ -864,7 +869,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { * a NumberFormat factory method. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of DecimalFormat. + * #icu::number::NumberFormatter instead of DecimalFormat. * * @param pattern a non-localized pattern string * @param symbols the set of symbols to be used @@ -986,6 +991,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { * Result is appended to existing contents. * @param pos On input: an alignment field, if desired. * On output: the offsets of the alignment field. + * @param status Output param filled with success/failure status. * @return Reference to 'appendTo' parameter. * @internal */ @@ -1031,6 +1037,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { * Result is appended to existing contents. * @param pos On input: an alignment field, if desired. * On output: the offsets of the alignment field. + * @param status Output param filled with success/failure status. * @return Reference to 'appendTo' parameter. * @internal */ @@ -1726,7 +1733,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { virtual void setDecimalPatternMatchRequired(UBool newValue); /** - * {@icu} Returns whether to ignore exponents when parsing. + * Returns whether to ignore exponents when parsing. * * @see #setParseNoExponent * @internal This API is a technical preview. It may change in an upcoming release. @@ -1734,7 +1741,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { virtual UBool isParseNoExponent() const; /** - * {@icu} Specifies whether to stop parsing when an exponent separator is encountered. For + * Specifies whether to stop parsing when an exponent separator is encountered. For * example, parses "123E4" to 123 (with parse position 3) instead of 1230000 (with parse position * 5). * @@ -1744,7 +1751,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { virtual void setParseNoExponent(UBool value); /** - * {@icu} Returns whether parsing is sensitive to case (lowercase/uppercase). + * Returns whether parsing is sensitive to case (lowercase/uppercase). * * @see #setParseCaseSensitive * @internal This API is a technical preview. It may change in an upcoming release. @@ -1752,7 +1759,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { virtual UBool isParseCaseSensitive() const; /** - * {@icu} Whether to pay attention to case when parsing; default is to ignore case (perform + * Whether to pay attention to case when parsing; default is to ignore case (perform * case-folding). For example, "A" == "a" in case-insensitive but not case-sensitive mode. * * Currency symbols are never case-folded. For example, "us$1.00" will not parse in case-insensitive @@ -1763,7 +1770,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { virtual void setParseCaseSensitive(UBool value); /** - * {@icu} Returns whether truncation of high-order integer digits should result in an error. + * Returns whether truncation of high-order integer digits should result in an error. * By default, setMaximumIntegerDigits truncates high-order digits silently. * * @see setFormatFailIfMoreThanMaxDigits @@ -1772,7 +1779,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { virtual UBool isFormatFailIfMoreThanMaxDigits() const; /** - * {@icu} Sets whether truncation of high-order integer digits should result in an error. + * 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. @@ -2017,16 +2024,17 @@ class U_I18N_API DecimalFormat : public NumberFormat { virtual void setCurrency(const char16_t* theCurrency); /** - * Sets the <tt>Currency Context</tt> object used to display currency. + * Sets the `Currency Usage` object used to display currency. * This takes effect immediately, if this format is a * currency format. - * @param currencyContext new currency context object to use. + * @param newUsage new currency usage object to use. + * @param ec input-output error code * @stable ICU 54 */ void setCurrencyUsage(UCurrencyUsage newUsage, UErrorCode* ec); /** - * Returns the <tt>Currency Context</tt> object used to display currency + * Returns the `Currency Usage` object used to display currency * @stable ICU 54 */ UCurrencyUsage getCurrencyUsage() const; @@ -2050,7 +2058,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { void formatToDecimalQuantity(const Formattable& number, number::impl::DecimalQuantity& output, UErrorCode& status) const; -#endif +#endif /* U_HIDE_INTERNAL_API */ #ifndef U_HIDE_DRAFT_API /** @@ -2072,7 +2080,6 @@ class U_I18N_API DecimalFormat : public NumberFormat { * FormattedNumber result = df->toNumberFormatter().formatDouble(123, status); * </pre> * - * @param output The variable into which to store the LocalizedNumberFormatter. * @return The output variable, for chaining. * @draft ICU 62 */ diff --git a/deps/icu-small/source/i18n/unicode/dtptngen.h b/deps/icu-small/source/i18n/unicode/dtptngen.h index feb465e799..26ccc64060 100644 --- a/deps/icu-small/source/i18n/unicode/dtptngen.h +++ b/deps/icu-small/source/i18n/unicode/dtptngen.h @@ -498,27 +498,23 @@ public: private: /** * Constructor. - * @stable ICU 3.8 */ DateTimePatternGenerator(UErrorCode & status); /** * Constructor. - * @stable ICU 3.8 */ DateTimePatternGenerator(const Locale& locale, UErrorCode & status); /** * Copy constructor. * @param other DateTimePatternGenerator to copy - * @stable ICU 3.8 */ DateTimePatternGenerator(const DateTimePatternGenerator& other); /** * Default assignment operator. * @param other DateTimePatternGenerator to copy - * @stable ICU 3.8 */ DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other); @@ -542,6 +538,11 @@ private: int32_t fAllowedHourFormats[7]; // Actually an array of AllowedHourFormat enum type, ending with UNKNOWN. + // Internal error code used for recording/reporting errors that occur during methods that do not + // have a UErrorCode parameter. For example: the Copy Constructor, or the ::clone() method. + // When this is set to an error the object is in an invalid state. + UErrorCode internalErrorCode; + /* internal flags masks for adjustFieldTypes etc. */ enum { kDTPGNoFlags = 0, @@ -569,11 +570,10 @@ private: #endif // U_HIDE_DRAFT_API void getAppendName(UDateTimePatternField field, UnicodeString& value); UnicodeString mapSkeletonMetacharacters(const UnicodeString& patternForm, int32_t* flags, UErrorCode& status); - int32_t getCanonicalIndex(const UnicodeString& field); - const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, const PtnSkeleton** specifiedSkeletonPtr = 0); + const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, UErrorCode& status, const PtnSkeleton** specifiedSkeletonPtr = 0); UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS); - UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS); - int32_t getTopBitNumber(int32_t foundMask); + UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UErrorCode& status, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS); + int32_t getTopBitNumber(int32_t foundMask) const; void setAvailableFormat(const UnicodeString &key, UErrorCode& status); UBool isAvailableFormatSet(const UnicodeString &key) const; void copyHashtable(Hashtable *other, UErrorCode &status); diff --git a/deps/icu-small/source/i18n/unicode/fmtable.h b/deps/icu-small/source/i18n/unicode/fmtable.h index 2359b61d46..a06c23dc3b 100644 --- a/deps/icu-small/source/i18n/unicode/fmtable.h +++ b/deps/icu-small/source/i18n/unicode/fmtable.h @@ -658,7 +658,7 @@ public: /** * Adopt, and set value from, a DecimalQuantity * Internal Function, do not use. - * @param dl the DecimalQuantity to be adopted + * @param dq the DecimalQuantity to be adopted * @internal */ void adoptDecimalQuantity(number::impl::DecimalQuantity *dq); diff --git a/deps/icu-small/source/i18n/unicode/gender.h b/deps/icu-small/source/i18n/unicode/gender.h index 467b64ec5e..b7c31cb554 100644 --- a/deps/icu-small/source/i18n/unicode/gender.h +++ b/deps/icu-small/source/i18n/unicode/gender.h @@ -18,6 +18,11 @@ #ifndef _GENDER #define _GENDER +/** + * \file + * \brief C++ API: GenderInfo computes the gender of a list. + */ + #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING @@ -30,7 +35,7 @@ class GenderInfoTest; U_NAMESPACE_BEGIN -// Forward Declaration +/** \internal Forward Declaration */ void U_CALLCONV GenderInfo_initCache(UErrorCode &status); /** diff --git a/deps/icu-small/source/i18n/unicode/listformatter.h b/deps/icu-small/source/i18n/unicode/listformatter.h new file mode 100644 index 0000000000..5e36cf71cc --- /dev/null +++ b/deps/icu-small/source/i18n/unicode/listformatter.h @@ -0,0 +1,203 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +/* +******************************************************************************* +* +* Copyright (C) 2012-2016, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: listformatter.h +* encoding: UTF-8 +* tab size: 8 (not used) +* indentation:4 +* +* created on: 20120426 +* created by: Umesh P. Nair +*/ + +#ifndef __LISTFORMATTER_H__ +#define __LISTFORMATTER_H__ + +#include "unicode/utypes.h" + +#include "unicode/unistr.h" +#include "unicode/locid.h" + +U_NAMESPACE_BEGIN + +class FieldPositionIterator; +class FieldPositionHandler; + +/** @internal */ +class Hashtable; + +/** @internal */ +struct ListFormatInternal; + +/* The following can't be #ifndef U_HIDE_INTERNAL_API, needed for other .h file declarations */ +/** + * @internal + * \cond + */ +struct ListFormatData : public UMemory { + UnicodeString twoPattern; + UnicodeString startPattern; + UnicodeString middlePattern; + UnicodeString endPattern; + + ListFormatData(const UnicodeString& two, const UnicodeString& start, const UnicodeString& middle, const UnicodeString& end) : + twoPattern(two), startPattern(start), middlePattern(middle), endPattern(end) {} +}; +/** \endcond */ + + +/** + * \file + * \brief C++ API: API for formatting a list. + */ + + +/** + * An immutable class for formatting a list, using data from CLDR (or supplied + * separately). + * + * Example: Input data ["Alice", "Bob", "Charlie", "Delta"] will be formatted + * as "Alice, Bob, Charlie and Delta" in English. + * + * The ListFormatter class is not intended for public subclassing. + * @stable ICU 50 + */ +class U_I18N_API ListFormatter : public UObject{ + + public: + + /** + * Copy constructor. + * @stable ICU 52 + */ + ListFormatter(const ListFormatter&); + + /** + * Assignment operator. + * @stable ICU 52 + */ + ListFormatter& operator=(const ListFormatter& other); + + /** + * Creates a ListFormatter appropriate for the default locale. + * + * @param errorCode ICU error code, set if no data available for default locale. + * @return Pointer to a ListFormatter object for the default locale, + * created from internal data derived from CLDR data. + * @stable ICU 50 + */ + static ListFormatter* createInstance(UErrorCode& errorCode); + + /** + * Creates a ListFormatter appropriate for a locale. + * + * @param locale The locale. + * @param errorCode ICU error code, set if no data available for the given locale. + * @return A ListFormatter object created from internal data derived from + * CLDR data. + * @stable ICU 50 + */ + static ListFormatter* createInstance(const Locale& locale, UErrorCode& errorCode); + +#ifndef U_HIDE_INTERNAL_API + /** + * Creates a ListFormatter appropriate for a locale and style. + * + * @param locale The locale. + * @param style the style, either "standard", "duration", or "duration-short" + * @param errorCode ICU error code, set if no data available for the given locale. + * @return A ListFormatter object created from internal data derived from + * CLDR data. + * @internal + */ + static ListFormatter* createInstance(const Locale& locale, const char* style, UErrorCode& errorCode); +#endif /* U_HIDE_INTERNAL_API */ + + /** + * Destructor. + * + * @stable ICU 50 + */ + virtual ~ListFormatter(); + + + /** + * Formats a list of strings. + * + * @param items An array of strings to be combined and formatted. + * @param n_items Length of the array items. + * @param appendTo The string to which the result should be appended to. + * @param errorCode ICU error code, set if there is an error. + * @return Formatted string combining the elements of items, appended to appendTo. + * @stable ICU 50 + */ + UnicodeString& format(const UnicodeString items[], int32_t n_items, + UnicodeString& appendTo, UErrorCode& errorCode) const; + +#ifndef U_HIDE_DRAFT_API + /** + * Format a list of strings. + * + * @param items An array of strings to be combined and formatted. + * @param n_items Length of the array items. + * @param appendTo The string to which the formatted result will be + * appended. + * @param posIter On return, can be used to iterate over positions of + * fields generated by this format call. Field values are + * defined in UListFormatterField. Can be NULL. + * @param errorCode ICU error code returned here. + * @return Formatted string combining the elements of items, + * appended to appendTo. + * @draft ICU 63 + */ + UnicodeString& format(const UnicodeString items[], int32_t n_items, + UnicodeString & appendTo, FieldPositionIterator* posIter, + UErrorCode& errorCode) const; +#endif /* U_HIDE_DRAFT_API */ + +#ifndef U_HIDE_INTERNAL_API + /** + @internal for MeasureFormat + */ + UnicodeString& format( + const UnicodeString items[], + int32_t n_items, + UnicodeString& appendTo, + int32_t index, + int32_t &offset, + UErrorCode& errorCode) const; + /** + * @internal constructor made public for testing. + */ + ListFormatter(const ListFormatData &data, UErrorCode &errorCode); + /** + * @internal constructor made public for testing. + */ + ListFormatter(const ListFormatInternal* listFormatterInternal); +#endif /* U_HIDE_INTERNAL_API */ + + private: + static void initializeHash(UErrorCode& errorCode); + static const ListFormatInternal* getListFormatInternal(const Locale& locale, const char *style, UErrorCode& errorCode); + struct ListPatternsSink; + static ListFormatInternal* loadListFormatInternal(const Locale& locale, const char* style, UErrorCode& errorCode); + + UnicodeString& format_( + const UnicodeString items[], int32_t n_items, UnicodeString& appendTo, + int32_t index, int32_t &offset, FieldPositionHandler* handler, UErrorCode& errorCode) const; + + ListFormatter(); + + ListFormatInternal* owned; + const ListFormatInternal* data; +}; + +U_NAMESPACE_END + +#endif diff --git a/deps/icu-small/source/i18n/unicode/measfmt.h b/deps/icu-small/source/i18n/unicode/measfmt.h index 14399dd59a..bbdd2364bd 100644 --- a/deps/icu-small/source/i18n/unicode/measfmt.h +++ b/deps/icu-small/source/i18n/unicode/measfmt.h @@ -104,7 +104,7 @@ class U_I18N_API MeasureFormat : public Format { * Constructor. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * {@link icu::number::NumberFormatter} instead of NumberFormat. * @stable ICU 53 */ MeasureFormat( @@ -114,7 +114,7 @@ class U_I18N_API MeasureFormat : public Format { * Constructor. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * {@link icu::number::NumberFormatter} instead of NumberFormat. * @stable ICU 53 */ MeasureFormat( @@ -202,7 +202,7 @@ class U_I18N_API MeasureFormat : public Format { * formatted string is 3.5 meters per second. * @param measure The measure object. In above example, 3.5 meters. * @param perUnit The per unit. In above example, it is - * *MeasureUnit::createSecond(status). + * `*%MeasureUnit::createSecond(status)`. * @param appendTo formatted string appended here. * @param pos the field position. * @param status the error. @@ -223,7 +223,7 @@ class U_I18N_API MeasureFormat : public Format { * @param unit The unit for which to get a display name. * @param status the error. * @return The display name in the locale and width specified in - * {@link MeasureFormat#getInstance}, or null if there is no display name available + * the MeasureFormat constructor, or null if there is no display name available * for the specified unit. * * @stable ICU 58 @@ -236,7 +236,7 @@ class U_I18N_API MeasureFormat : public Format { * locale. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * {@link icu::number::NumberFormatter} instead of NumberFormat. * @param locale desired locale * @param ec input-output error code * @return a formatter object, or NULL upon error @@ -250,7 +250,7 @@ class U_I18N_API MeasureFormat : public Format { * locale. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * {@link icu::number::NumberFormatter} instead of NumberFormat. * @param ec input-output error code * @return a formatter object, or NULL upon error * @stable ICU 3.0 @@ -348,7 +348,7 @@ class U_I18N_API MeasureFormat : public Format { const MeasureFormatCacheData *cache; const SharedNumberFormat *numberFormat; const SharedPluralRules *pluralRules; - UMeasureFormatWidth width; + UMeasureFormatWidth fWidth; // Declared outside of MeasureFormatSharedData because ListFormatter // objects are relatively cheap to copy; therefore, they don't need to be diff --git a/deps/icu-small/source/i18n/unicode/measunit.h b/deps/icu-small/source/i18n/unicode/measunit.h index f552253544..676fdeb9c8 100644 --- a/deps/icu-small/source/i18n/unicode/measunit.h +++ b/deps/icu-small/source/i18n/unicode/measunit.h @@ -368,6 +368,26 @@ class U_I18N_API MeasureUnit: public UObject { */ static MeasureUnit *createPartPerMillion(UErrorCode &status); +#ifndef U_HIDE_DRAFT_API + /** + * Returns unit of concentr: percent. + * Caller owns returned value and must free it. + * @param status ICU error code. + * @draft ICU 63 + */ + static MeasureUnit *createPercent(UErrorCode &status); +#endif /* U_HIDE_DRAFT_API */ + +#ifndef U_HIDE_DRAFT_API + /** + * Returns unit of concentr: permille. + * Caller owns returned value and must free it. + * @param status ICU error code. + * @draft ICU 63 + */ + static MeasureUnit *createPermille(UErrorCode &status); +#endif /* U_HIDE_DRAFT_API */ + /** * Returns unit of consumption: liter-per-100kilometers. * Caller owns returned value and must free it. @@ -464,6 +484,16 @@ class U_I18N_API MeasureUnit: public UObject { */ static MeasureUnit *createMegabyte(UErrorCode &status); +#ifndef U_HIDE_DRAFT_API + /** + * Returns unit of digital: petabyte. + * Caller owns returned value and must free it. + * @param status ICU error code. + * @draft ICU 63 + */ + static MeasureUnit *createPetabyte(UErrorCode &status); +#endif /* U_HIDE_DRAFT_API */ + /** * Returns unit of digital: terabit. * Caller owns returned value and must free it. @@ -984,6 +1014,16 @@ class U_I18N_API MeasureUnit: public UObject { */ static MeasureUnit *createWatt(UErrorCode &status); +#ifndef U_HIDE_DRAFT_API + /** + * Returns unit of pressure: atmosphere. + * Caller owns returned value and must free it. + * @param status ICU error code. + * @draft ICU 63 + */ + static MeasureUnit *createAtmosphere(UErrorCode &status); +#endif /* U_HIDE_DRAFT_API */ + /** * Returns unit of pressure: hectopascal. * Caller owns returned value and must free it. diff --git a/deps/icu-small/source/i18n/unicode/msgfmt.h b/deps/icu-small/source/i18n/unicode/msgfmt.h index fef8010774..074d933540 100644 --- a/deps/icu-small/source/i18n/unicode/msgfmt.h +++ b/deps/icu-small/source/i18n/unicode/msgfmt.h @@ -124,7 +124,7 @@ class NumberFormat; * argNumber = '0' | ('1'..'9' ('0'..'9')*) * * argType = "number" | "date" | "time" | "spellout" | "ordinal" | "duration" - * argStyle = "short" | "medium" | "long" | "full" | "integer" | "currency" | "percent" | argStyleText + * argStyle = "short" | "medium" | "long" | "full" | "integer" | "currency" | "percent" | argStyleText | "::" argSkeletonText * </pre> * * <ul> @@ -166,7 +166,7 @@ class NumberFormat; * <td colspan=2><i>(none)</i> * <td><code>null</code> * <tr> - * <td rowspan=5><code>number</code> + * <td rowspan=6><code>number</code> * <td><i>(none)</i> * <td><code>NumberFormat.createInstance(getLocale(), status)</code> * <tr> @@ -182,6 +182,9 @@ class NumberFormat; * <td><i>argStyleText</i> * <td><code>new DecimalFormat(argStyleText, new DecimalFormatSymbols(getLocale(), status), status)</code> * <tr> + * <td><i>argSkeletonText</i> + * <td><code>NumberFormatter::forSkeleton(argSkeletonText, status).locale(getLocale()).toFormat(status)</code> + * <tr> * <td rowspan=6><code>date</code> * <td><i>(none)</i> * <td><code>DateFormat.createDateInstance(kDefault, getLocale(), status)</code> @@ -199,7 +202,7 @@ class NumberFormat; * <td><code>DateFormat.createDateInstance(kFull, getLocale(), status)</code> * <tr> * <td><i>argStyleText</i> - * <td><code>new SimpleDateFormat(argStyleText, getLocale(), status) + * <td><code>new SimpleDateFormat(argStyleText, getLocale(), status)</code> * <tr> * <td rowspan=6><code>time</code> * <td><i>(none)</i> @@ -218,7 +221,7 @@ class NumberFormat; * <td><code>DateFormat.createTimeInstance(kFull, getLocale(), status)</code> * <tr> * <td><i>argStyleText</i> - * <td><code>new SimpleDateFormat(argStyleText, getLocale(), status) + * <td><code>new SimpleDateFormat(argStyleText, getLocale(), status)</code> * <tr> * <td><code>spellout</code> * <td><i>argStyleText (optional)</i> diff --git a/deps/icu-small/source/i18n/unicode/numberformatter.h b/deps/icu-small/source/i18n/unicode/numberformatter.h index 3ab08319f7..469949a287 100644 --- a/deps/icu-small/source/i18n/unicode/numberformatter.h +++ b/deps/icu-small/source/i18n/unicode/numberformatter.h @@ -144,11 +144,31 @@ class MultiplierFormatHandler; class CurrencySymbols; class GeneratorHelpers; class DecNum; +class NumberRangeFormatterImpl; +struct RangeMacroProps; + +/** + * Used for NumberRangeFormatter and implemented in numrange_fluent.cpp. + * Declared here so it can be friended. + * + * @internal + */ +void touchRangeLocales(impl::RangeMacroProps& macros); } // namespace impl -// Reserve extra names in case they are added as classes in the future: +/** + * Extra name reserved in case it is needed in the future. + * + * @draft ICU 63 + */ typedef Notation CompactNotation; + +/** + * Extra name reserved in case it is needed in the future. + * + * @draft ICU 63 + */ typedef Notation SimpleNotation; /** @@ -308,10 +328,15 @@ class U_I18N_API Notation : public UMemory { union NotationUnion { // For NTN_SCIENTIFIC + /** @internal */ struct ScientificSettings { + /** @internal */ int8_t fEngineeringInterval; + /** @internal */ bool fRequireMinInt; + /** @internal */ impl::digits_t fMinExponentDigits; + /** @internal */ UNumberSignDisplay fExponentSignDisplay; } scientific; @@ -407,15 +432,39 @@ class U_I18N_API ScientificNotation : public Notation { friend class impl::NumberPropertyMapper; }; -// Reserve extra names in case they are added as classes in the future: +/** + * Extra name reserved in case it is needed in the future. + * + * @draft ICU 63 + */ typedef Precision SignificantDigitsPrecision; // Typedefs for ICU 60/61 compatibility. // These will be removed in ICU 64. // See http://bugs.icu-project.org/trac/ticket/13746 + +/** + * This will be removed in ICU 64. See ICU-13746. + * @deprecated ICU 63 + */ typedef Precision Rounder; + +/** + * This will be removed in ICU 64. See ICU-13746. + * @deprecated ICU 63 + */ typedef FractionPrecision FractionRounder; + +/** + * This will be removed in ICU 64. See ICU-13746. + * @deprecated ICU 63 + */ typedef IncrementPrecision IncrementRounder; + +/** + * This will be removed in ICU 64. See ICU-13746. + * @deprecated ICU 63 + */ typedef CurrencyPrecision CurrencyRounder; /** @@ -672,16 +721,25 @@ class U_I18N_API Precision : public UMemory { } fType; union PrecisionUnion { + /** @internal */ struct FractionSignificantSettings { // For RND_FRACTION, RND_SIGNIFICANT, and RND_FRACTION_SIGNIFICANT + /** @internal */ impl::digits_t fMinFrac; + /** @internal */ impl::digits_t fMaxFrac; + /** @internal */ impl::digits_t fMinSig; + /** @internal */ impl::digits_t fMaxSig; } fracSig; + /** @internal */ struct IncrementSettings { + /** @internal */ double fIncrement; + /** @internal */ impl::digits_t fMinFrac; + /** @internal */ impl::digits_t fMaxFrac; } increment; // For RND_INCREMENT UCurrencyUsage currencyUsage; // For RND_CURRENCY @@ -1205,7 +1263,7 @@ class U_I18N_API Grouper : public UMemory { public: #ifndef U_HIDE_INTERNAL_API /** @internal */ - static Grouper forStrategy(UGroupingStrategy grouping); + static Grouper forStrategy(UNumberGroupingStrategy grouping); /** * Resolve the values in Properties to a Grouper object. @@ -1216,7 +1274,7 @@ class U_I18N_API Grouper : public UMemory { // Future: static Grouper forProperties(DecimalFormatProperties& properties); /** @internal */ - Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping, UGroupingStrategy strategy) + Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping, UNumberGroupingStrategy strategy) : fGrouping1(grouping1), fGrouping2(grouping2), fMinGrouping(minGrouping), @@ -1251,10 +1309,10 @@ class U_I18N_API Grouper : public UMemory { int16_t fMinGrouping; /** - * The UGroupingStrategy that was used to create this Grouper, or UNUM_GROUPING_COUNT if this - * was not created from a UGroupingStrategy. + * The UNumberGroupingStrategy that was used to create this Grouper, or UNUM_GROUPING_COUNT if this + * was not created from a UNumberGroupingStrategy. */ - UGroupingStrategy fStrategy; + UNumberGroupingStrategy fStrategy; Grouper() : fGrouping1(-3) {}; @@ -1423,7 +1481,8 @@ struct U_I18N_API MacroProps : public UMemory { /** * An abstract base class for specifying settings related to number formatting. This class is implemented by - * {@link UnlocalizedNumberFormatter} and {@link LocalizedNumberFormatter}. + * {@link UnlocalizedNumberFormatter} and {@link LocalizedNumberFormatter}. This class is not intended for + * public subclassing. */ template<typename Derived> class U_I18N_API NumberFormatterSettings { @@ -1710,7 +1769,7 @@ class U_I18N_API NumberFormatterSettings { * The exact grouping widths will be chosen based on the locale. * * <p> - * Pass this method an element from the {@link UGroupingStrategy} enum. For example: + * Pass this method an element from the {@link UNumberGroupingStrategy} enum. For example: * * <pre> * NumberFormatter::with().grouping(UNUM_GROUPING_MIN2) @@ -1724,7 +1783,7 @@ class U_I18N_API NumberFormatterSettings { * @return The fluent chain. * @draft ICU 61 */ - Derived grouping(UGroupingStrategy strategy) const &; + Derived grouping(UNumberGroupingStrategy strategy) const &; /** * Overload of grouping() for use on an rvalue reference. @@ -1733,10 +1792,9 @@ class U_I18N_API NumberFormatterSettings { * The grouping strategy to use. * @return The fluent chain. * @see #grouping - * @provisional This API might change or be removed in a future release. * @draft ICU 62 */ - Derived grouping(UGroupingStrategy strategy) &&; + Derived grouping(UNumberGroupingStrategy strategy) &&; /** * Specifies the minimum and maximum number of digits to render before the decimal mark. @@ -1748,7 +1806,7 @@ class U_I18N_API NumberFormatterSettings { * </ul> * * <p> - * Pass this method the return value of {@link IntegerWidth#zeroFillTo(int)}. For example: + * Pass this method the return value of {@link IntegerWidth#zeroFillTo}. For example: * * <pre> * NumberFormatter::with().integerWidth(IntegerWidth::zeroFillTo(2)) @@ -2099,15 +2157,18 @@ class U_I18N_API NumberFormatterSettings { // NOTE: Uses default copy and move constructors. - protected: + private: impl::MacroProps fMacros; - private: // Don't construct me directly! Use (Un)LocalizedNumberFormatter. NumberFormatterSettings() = default; friend class LocalizedNumberFormatter; friend class UnlocalizedNumberFormatter; + + // Give NumberRangeFormatter access to the MacroProps + friend void impl::touchRangeLocales(impl::RangeMacroProps& macros); + friend class impl::NumberRangeFormatterImpl; }; /** @@ -2124,13 +2185,6 @@ class U_I18N_API UnlocalizedNumberFormatter * Associate the given locale with the number formatter. The locale is used for picking the appropriate symbols, * formats, and other data for number display. * - * <p> - * To use the Java default locale, call Locale::getDefault(): - * - * <pre> - * NumberFormatter::with(). ... .locale(Locale::getDefault()) - * </pre> - * * @param locale * The locale to use when loading data for number formatting. * @return The fluent chain. @@ -2156,7 +2210,6 @@ class U_I18N_API UnlocalizedNumberFormatter */ UnlocalizedNumberFormatter() = default; - // Make default copy constructor call the NumberFormatterSettings copy constructor. /** * Returns a copy of this UnlocalizedNumberFormatter. * @draft ICU 60 @@ -2271,7 +2324,7 @@ class U_I18N_API LocalizedNumberFormatter */ int32_t getCallCount() const; -#endif +#endif /* U_HIDE_INTERNAL_API */ /** * Creates a representation of this LocalizedNumberFormat as an icu::Format, enabling the use @@ -2295,7 +2348,6 @@ class U_I18N_API LocalizedNumberFormatter */ LocalizedNumberFormatter() = default; - // Make default copy constructor call the NumberFormatterSettings copy constructor. /** * Returns a copy of this LocalizedNumberFormatter. * @draft ICU 60 @@ -2333,11 +2385,12 @@ class U_I18N_API LocalizedNumberFormatter * * @param results * The results object. This method will mutate it to save the results. + * @param status * @internal */ void formatImpl(impl::UFormattedNumberData *results, UErrorCode &status) const; -#endif +#endif /* U_HIDE_INTERNAL_API */ /** * Destruct this LocalizedNumberFormatter, cleaning up any memory it might own. @@ -2359,6 +2412,8 @@ class U_I18N_API LocalizedNumberFormatter LocalizedNumberFormatter(impl::MacroProps &¯os, const Locale &locale); + void clear(); + void lnfMoveHelper(LocalizedNumberFormatter&& src); /** @@ -2430,7 +2485,7 @@ class U_I18N_API FormattedNumber : public UMemory { * @draft ICU 62 * @see Appendable */ - Appendable &appendTo(Appendable &appendable, UErrorCode& status); + Appendable &appendTo(Appendable &appendable, UErrorCode& status) const; #ifndef U_HIDE_DEPRECATED_API /** @@ -2457,9 +2512,9 @@ class U_I18N_API FormattedNumber : public UMemory { #endif /* U_HIDE_DEPRECATED_API */ /** - * Determines the start and end indices of the next occurrence of the given <em>field</em> in the - * output string. This allows you to determine the locations of, for example, the integer part, - * fraction part, or symbols. + * Determines the start (inclusive) and end (exclusive) indices of the next occurrence of the given + * <em>field</em> in the output string. This allows you to determine the locations of, for example, + * the integer part, fraction part, or symbols. * * If a field occurs just once, calling this method will find that occurrence and return it. If a * field occurs multiple times, this method may be called repeatedly with the following pattern: @@ -2478,7 +2533,7 @@ class U_I18N_API FormattedNumber : public UMemory { * Input+output variable. On input, the "field" property determines which field to look * up, and the "beginIndex" and "endIndex" properties determine where to begin the search. * On output, the "beginIndex" is set to the beginning of the first occurrence of the - * field with either begin or end indices after the input indices, "endIndex" is set to + * field with either begin or end indices after the input indices; "endIndex" is set to * the end of that occurrence of the field (exclusive index). If a field position is not * found, the method returns FALSE and the FieldPosition may or may not be changed. * @param status @@ -2537,7 +2592,7 @@ class U_I18N_API FormattedNumber : public UMemory { */ void getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih, UErrorCode& status) const; -#endif +#endif /* U_HIDE_INTERNAL_API */ /** * Copying not supported; use move constructor instead. diff --git a/deps/icu-small/source/i18n/unicode/numberrangeformatter.h b/deps/icu-small/source/i18n/unicode/numberrangeformatter.h new file mode 100644 index 0000000000..3e6248d934 --- /dev/null +++ b/deps/icu-small/source/i18n/unicode/numberrangeformatter.h @@ -0,0 +1,866 @@ +// © 2018 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html + +#if !UCONFIG_NO_FORMATTING +#ifndef __NUMBERRANGEFORMATTER_H__ +#define __NUMBERRANGEFORMATTER_H__ + +#include <atomic> +#include "unicode/appendable.h" +#include "unicode/fieldpos.h" +#include "unicode/fpositer.h" +#include "unicode/numberformatter.h" + +#ifndef U_HIDE_DRAFT_API + +/** + * \file + * \brief C++ API: Library for localized formatting of number, currency, and unit ranges. + * + * The main entrypoint to the formatting of ranges of numbers, including currencies and other units of measurement. + * <p> + * Usage example: + * <p> + * <pre> + * NumberRangeFormatter::with() + * .identityFallback(UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE) + * .numberFormatterFirst(NumberFormatter::with().adoptUnit(MeasureUnit::createMeter())) + * .numberFormatterSecond(NumberFormatter::with().adoptUnit(MeasureUnit::createKilometer())) + * .locale("en-GB") + * .formatRange(750, 1.2, status) + * .toString(status); + * // => "750 m - 1.2 km" + * </pre> + * <p> + * Like NumberFormatter, NumberRangeFormatter instances are immutable and thread-safe. This API is based on the + * <em>fluent</em> design pattern popularized by libraries such as Google's Guava. + * + * @author Shane Carr + */ + + +/** + * Defines how to merge fields that are identical across the range sign. + * + * @draft ICU 63 + */ +typedef enum UNumberRangeCollapse { + /** + * Use locale data and heuristics to determine how much of the string to collapse. Could end up collapsing none, + * some, or all repeated pieces in a locale-sensitive way. + * + * The heuristics used for this option are subject to change over time. + * + * @draft ICU 63 + */ + UNUM_RANGE_COLLAPSE_AUTO, + + /** + * Do not collapse any part of the number. Example: "3.2 thousand kilograms – 5.3 thousand kilograms" + * + * @draft ICU 63 + */ + UNUM_RANGE_COLLAPSE_NONE, + + /** + * Collapse the unit part of the number, but not the notation, if present. Example: "3.2 thousand – 5.3 thousand + * kilograms" + * + * @draft ICU 63 + */ + UNUM_RANGE_COLLAPSE_UNIT, + + /** + * Collapse any field that is equal across the range sign. May introduce ambiguity on the magnitude of the + * number. Example: "3.2 – 5.3 thousand kilograms" + * + * @draft ICU 63 + */ + UNUM_RANGE_COLLAPSE_ALL +} UNumberRangeCollapse; + +/** + * Defines the behavior when the two numbers in the range are identical after rounding. To programmatically detect + * when the identity fallback is used, compare the lower and upper BigDecimals via FormattedNumber. + * + * @draft ICU 63 + * @see NumberRangeFormatter + */ +typedef enum UNumberRangeIdentityFallback { + /** + * Show the number as a single value rather than a range. Example: "$5" + * + * @draft ICU 63 + */ + UNUM_IDENTITY_FALLBACK_SINGLE_VALUE, + + /** + * Show the number using a locale-sensitive approximation pattern. If the numbers were the same before rounding, + * show the single value. Example: "~$5" or "$5" + * + * @draft ICU 63 + */ + UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE, + + /** + * Show the number using a locale-sensitive approximation pattern. Use the range pattern always, even if the + * inputs are the same. Example: "~$5" + * + * @draft ICU 63 + */ + UNUM_IDENTITY_FALLBACK_APPROXIMATELY, + + /** + * Show the number as the range of two equal values. Use the range pattern always, even if the inputs are the + * same. Example (with RangeCollapse.NONE): "$5 – $5" + * + * @draft ICU 63 + */ + UNUM_IDENTITY_FALLBACK_RANGE +} UNumberRangeIdentityFallback; + +/** + * Used in the result class FormattedNumberRange to indicate to the user whether the numbers formatted in the range + * were equal or not, and whether or not the identity fallback was applied. + * + * @draft ICU 63 + * @see NumberRangeFormatter + */ +typedef enum UNumberRangeIdentityResult { + /** + * Used to indicate that the two numbers in the range were equal, even before any rounding rules were applied. + * + * @draft ICU 63 + * @see NumberRangeFormatter + */ + UNUM_IDENTITY_RESULT_EQUAL_BEFORE_ROUNDING, + + /** + * Used to indicate that the two numbers in the range were equal, but only after rounding rules were applied. + * + * @draft ICU 63 + * @see NumberRangeFormatter + */ + UNUM_IDENTITY_RESULT_EQUAL_AFTER_ROUNDING, + + /** + * Used to indicate that the two numbers in the range were not equal, even after rounding rules were applied. + * + * @draft ICU 63 + * @see NumberRangeFormatter + */ + UNUM_IDENTITY_RESULT_NOT_EQUAL, + +#ifndef U_HIDE_INTERNAL_API + /** + * The number of entries in this enum. + * @internal + */ + UNUM_IDENTITY_RESULT_COUNT +#endif + +} UNumberRangeIdentityResult; + +U_NAMESPACE_BEGIN + +namespace number { // icu::number + +// Forward declarations: +class UnlocalizedNumberRangeFormatter; +class LocalizedNumberRangeFormatter; +class FormattedNumberRange; + +namespace impl { + +// Forward declarations: +struct RangeMacroProps; +class DecimalQuantity; +struct UFormattedNumberRangeData; +class NumberRangeFormatterImpl; + +} // namespace impl + +/** + * \cond + * Export an explicit template instantiation. See datefmt.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 struct U_I18N_API std::atomic<impl::NumberRangeFormatterImpl*>; +#endif +/** \endcond */ + +// Other helper classes would go here, but there are none. + +namespace impl { // icu::number::impl + +// Do not enclose entire MacroProps with #ifndef U_HIDE_INTERNAL_API, needed for a protected field +/** @internal */ +struct U_I18N_API RangeMacroProps : public UMemory { + /** @internal */ + UnlocalizedNumberFormatter formatter1; // = NumberFormatter::with(); + + /** @internal */ + UnlocalizedNumberFormatter formatter2; // = NumberFormatter::with(); + + /** @internal */ + bool singleFormatter = true; + + /** @internal */ + UNumberRangeCollapse collapse = UNUM_RANGE_COLLAPSE_AUTO; + + /** @internal */ + UNumberRangeIdentityFallback identityFallback = UNUM_IDENTITY_FALLBACK_APPROXIMATELY; + + /** @internal */ + Locale locale; + + // NOTE: Uses default copy and move constructors. + + /** + * Check all members for errors. + * @internal + */ + bool copyErrorTo(UErrorCode &status) const { + return formatter1.copyErrorTo(status) || formatter2.copyErrorTo(status); + } +}; + +} // namespace impl + +/** + * An abstract base class for specifying settings related to number formatting. This class is implemented by + * {@link UnlocalizedNumberRangeFormatter} and {@link LocalizedNumberRangeFormatter}. This class is not intended for + * public subclassing. + */ +template<typename Derived> +class U_I18N_API NumberRangeFormatterSettings { + public: + /** + * Sets the NumberFormatter instance to use for the numbers in the range. The same formatter is applied to both + * sides of the range. + * <p> + * The NumberFormatter instances must not have a locale applied yet; the locale specified on the + * NumberRangeFormatter will be used. + * + * @param formatter + * The formatter to use for both numbers in the range. + * @return The fluent chain. + * @draft ICU 63 + */ + Derived numberFormatterBoth(const UnlocalizedNumberFormatter &formatter) const &; + + /** + * Overload of numberFormatterBoth() for use on an rvalue reference. + * + * @param formatter + * The formatter to use for both numbers in the range. + * @return The fluent chain. + * @see #numberFormatterBoth + * @draft ICU 63 + */ + Derived numberFormatterBoth(const UnlocalizedNumberFormatter &formatter) &&; + + /** + * Overload of numberFormatterBoth() for use on an rvalue reference. + * + * @param formatter + * The formatter to use for both numbers in the range. + * @return The fluent chain. + * @see #numberFormatterBoth + * @draft ICU 63 + */ + Derived numberFormatterBoth(UnlocalizedNumberFormatter &&formatter) const &; + + /** + * Overload of numberFormatterBoth() for use on an rvalue reference. + * + * @param formatter + * The formatter to use for both numbers in the range. + * @return The fluent chain. + * @see #numberFormatterBoth + * @draft ICU 63 + */ + Derived numberFormatterBoth(UnlocalizedNumberFormatter &&formatter) &&; + + /** + * Sets the NumberFormatter instance to use for the first number in the range. + * <p> + * The NumberFormatter instances must not have a locale applied yet; the locale specified on the + * NumberRangeFormatter will be used. + * + * @param formatterFirst + * The formatter to use for the first number in the range. + * @return The fluent chain. + * @draft ICU 63 + */ + Derived numberFormatterFirst(const UnlocalizedNumberFormatter &formatterFirst) const &; + + /** + * Overload of numberFormatterFirst() for use on an rvalue reference. + * + * @param formatterFirst + * The formatter to use for the first number in the range. + * @return The fluent chain. + * @see #numberFormatterFirst + * @draft ICU 63 + */ + Derived numberFormatterFirst(const UnlocalizedNumberFormatter &formatterFirst) &&; + + /** + * Overload of numberFormatterFirst() for use on an rvalue reference. + * + * @param formatterFirst + * The formatter to use for the first number in the range. + * @return The fluent chain. + * @see #numberFormatterFirst + * @draft ICU 63 + */ + Derived numberFormatterFirst(UnlocalizedNumberFormatter &&formatterFirst) const &; + + /** + * Overload of numberFormatterFirst() for use on an rvalue reference. + * + * @param formatterFirst + * The formatter to use for the first number in the range. + * @return The fluent chain. + * @see #numberFormatterFirst + * @draft ICU 63 + */ + Derived numberFormatterFirst(UnlocalizedNumberFormatter &&formatterFirst) &&; + + /** + * Sets the NumberFormatter instance to use for the second number in the range. + * <p> + * The NumberFormatter instances must not have a locale applied yet; the locale specified on the + * NumberRangeFormatter will be used. + * + * @param formatterSecond + * The formatter to use for the second number in the range. + * @return The fluent chain. + * @draft ICU 63 + */ + Derived numberFormatterSecond(const UnlocalizedNumberFormatter &formatterSecond) const &; + + /** + * Overload of numberFormatterSecond() for use on an rvalue reference. + * + * @param formatterSecond + * The formatter to use for the second number in the range. + * @return The fluent chain. + * @see #numberFormatterSecond + * @draft ICU 63 + */ + Derived numberFormatterSecond(const UnlocalizedNumberFormatter &formatterSecond) &&; + + /** + * Overload of numberFormatterSecond() for use on an rvalue reference. + * + * @param formatterSecond + * The formatter to use for the second number in the range. + * @return The fluent chain. + * @see #numberFormatterSecond + * @draft ICU 63 + */ + Derived numberFormatterSecond(UnlocalizedNumberFormatter &&formatterSecond) const &; + + /** + * Overload of numberFormatterSecond() for use on an rvalue reference. + * + * @param formatterSecond + * The formatter to use for the second number in the range. + * @return The fluent chain. + * @see #numberFormatterSecond + * @draft ICU 63 + */ + Derived numberFormatterSecond(UnlocalizedNumberFormatter &&formatterSecond) &&; + + /** + * Sets the aggressiveness of "collapsing" fields across the range separator. Possible values: + * <p> + * <ul> + * <li>ALL: "3-5K miles"</li> + * <li>UNIT: "3K - 5K miles"</li> + * <li>NONE: "3K miles - 5K miles"</li> + * <li>AUTO: usually UNIT or NONE, depending on the locale and formatter settings</li> + * </ul> + * <p> + * The default value is AUTO. + * + * @param collapse + * The collapsing strategy to use for this range. + * @return The fluent chain. + * @draft ICU 63 + */ + Derived collapse(UNumberRangeCollapse collapse) const &; + + /** + * Overload of collapse() for use on an rvalue reference. + * + * @param collapse + * The collapsing strategy to use for this range. + * @return The fluent chain. + * @see #collapse + * @draft ICU 63 + */ + Derived collapse(UNumberRangeCollapse collapse) &&; + + /** + * Sets the behavior when the two sides of the range are the same. This could happen if the same two numbers are + * passed to the formatRange function, or if different numbers are passed to the function but they become the same + * after rounding rules are applied. Possible values: + * <p> + * <ul> + * <li>SINGLE_VALUE: "5 miles"</li> + * <li>APPROXIMATELY_OR_SINGLE_VALUE: "~5 miles" or "5 miles", depending on whether the number was the same before + * rounding was applied</li> + * <li>APPROXIMATELY: "~5 miles"</li> + * <li>RANGE: "5-5 miles" (with collapse=UNIT)</li> + * </ul> + * <p> + * The default value is APPROXIMATELY. + * + * @param identityFallback + * The strategy to use when formatting two numbers that end up being the same. + * @return The fluent chain. + * @draft ICU 63 + */ + Derived identityFallback(UNumberRangeIdentityFallback identityFallback) const &; + + /** + * Overload of identityFallback() for use on an rvalue reference. + * + * @param identityFallback + * The strategy to use when formatting two numbers that end up being the same. + * @return The fluent chain. + * @see #identityFallback + * @draft ICU 63 + */ + Derived identityFallback(UNumberRangeIdentityFallback identityFallback) &&; + + /** + * Sets the UErrorCode if an error occurred in the fluent chain. + * Preserves older error codes in the outErrorCode. + * @return TRUE if U_FAILURE(outErrorCode) + * @draft ICU 63 + */ + UBool copyErrorTo(UErrorCode &outErrorCode) const { + if (U_FAILURE(outErrorCode)) { + // Do not overwrite the older error code + return TRUE; + } + fMacros.copyErrorTo(outErrorCode); + return U_FAILURE(outErrorCode); + }; + + // NOTE: Uses default copy and move constructors. + + private: + impl::RangeMacroProps fMacros; + + // Don't construct me directly! Use (Un)LocalizedNumberFormatter. + NumberRangeFormatterSettings() = default; + + friend class LocalizedNumberRangeFormatter; + friend class UnlocalizedNumberRangeFormatter; +}; + +/** + * A NumberRangeFormatter that does not yet have a locale. In order to format, a locale must be specified. + * + * @see NumberRangeFormatter + * @draft ICU 63 + */ +class U_I18N_API UnlocalizedNumberRangeFormatter + : public NumberRangeFormatterSettings<UnlocalizedNumberRangeFormatter>, public UMemory { + + public: + /** + * Associate the given locale with the number range formatter. The locale is used for picking the + * appropriate symbols, formats, and other data for number display. + * + * @param locale + * The locale to use when loading data for number formatting. + * @return The fluent chain. + * @draft ICU 63 + */ + LocalizedNumberRangeFormatter locale(const icu::Locale &locale) const &; + + /** + * Overload of locale() for use on an rvalue reference. + * + * @param locale + * The locale to use when loading data for number formatting. + * @return The fluent chain. + * @see #locale + * @draft ICU 63 + */ + LocalizedNumberRangeFormatter locale(const icu::Locale &locale) &&; + + /** + * Default constructor: puts the formatter into a valid but undefined state. + * + * @draft ICU 63 + */ + UnlocalizedNumberRangeFormatter() = default; + + /** + * Returns a copy of this UnlocalizedNumberRangeFormatter. + * @draft ICU 63 + */ + UnlocalizedNumberRangeFormatter(const UnlocalizedNumberRangeFormatter &other); + + /** + * Move constructor: + * The source UnlocalizedNumberRangeFormatter will be left in a valid but undefined state. + * @draft ICU 63 + */ + UnlocalizedNumberRangeFormatter(UnlocalizedNumberRangeFormatter&& src) U_NOEXCEPT; + + /** + * Copy assignment operator. + * @draft ICU 63 + */ + UnlocalizedNumberRangeFormatter& operator=(const UnlocalizedNumberRangeFormatter& other); + + /** + * Move assignment operator: + * The source UnlocalizedNumberRangeFormatter will be left in a valid but undefined state. + * @draft ICU 63 + */ + UnlocalizedNumberRangeFormatter& operator=(UnlocalizedNumberRangeFormatter&& src) U_NOEXCEPT; + + private: + explicit UnlocalizedNumberRangeFormatter( + const NumberRangeFormatterSettings<UnlocalizedNumberRangeFormatter>& other); + + explicit UnlocalizedNumberRangeFormatter( + NumberRangeFormatterSettings<UnlocalizedNumberRangeFormatter>&& src) U_NOEXCEPT; + + // To give the fluent setters access to this class's constructor: + friend class NumberRangeFormatterSettings<UnlocalizedNumberRangeFormatter>; + + // To give NumberRangeFormatter::with() access to this class's constructor: + friend class NumberRangeFormatter; +}; + +/** + * A NumberRangeFormatter that has a locale associated with it; this means .formatRange() methods are available. + * + * @see NumberFormatter + * @draft ICU 63 + */ +class U_I18N_API LocalizedNumberRangeFormatter + : public NumberRangeFormatterSettings<LocalizedNumberRangeFormatter>, public UMemory { + public: + /** + * Format the given Formattables to a string using the settings specified in the NumberRangeFormatter fluent setting + * chain. + * + * @param first + * The first number in the range, usually to the left in LTR locales. + * @param second + * The second number in the range, usually to the right in LTR locales. + * @param status + * Set if an error occurs while formatting. + * @return A FormattedNumberRange object; call .toString() to get the string. + * @draft ICU 63 + */ + FormattedNumberRange formatFormattableRange( + const Formattable& first, const Formattable& second, UErrorCode& status) const; + + /** + * Default constructor: puts the formatter into a valid but undefined state. + * + * @draft ICU 63 + */ + LocalizedNumberRangeFormatter() = default; + + /** + * Returns a copy of this LocalizedNumberRangeFormatter. + * @draft ICU 63 + */ + LocalizedNumberRangeFormatter(const LocalizedNumberRangeFormatter &other); + + /** + * Move constructor: + * The source LocalizedNumberRangeFormatter will be left in a valid but undefined state. + * @draft ICU 63 + */ + LocalizedNumberRangeFormatter(LocalizedNumberRangeFormatter&& src) U_NOEXCEPT; + + /** + * Copy assignment operator. + * @draft ICU 63 + */ + LocalizedNumberRangeFormatter& operator=(const LocalizedNumberRangeFormatter& other); + + /** + * Move assignment operator: + * The source LocalizedNumberRangeFormatter will be left in a valid but undefined state. + * @draft ICU 63 + */ + LocalizedNumberRangeFormatter& operator=(LocalizedNumberRangeFormatter&& src) U_NOEXCEPT; + +#ifndef U_HIDE_INTERNAL_API + + /** + * @param results + * The results object. This method will mutate it to save the results. + * @param equalBeforeRounding + * Whether the number was equal before copying it into a DecimalQuantity. + * Used for determining the identity fallback behavior. + * @param status + * Set if an error occurs while formatting. + * @internal + */ + void formatImpl(impl::UFormattedNumberRangeData& results, bool equalBeforeRounding, + UErrorCode& status) const; + +#endif + + /** + * Destruct this LocalizedNumberRangeFormatter, cleaning up any memory it might own. + * @draft ICU 63 + */ + ~LocalizedNumberRangeFormatter(); + + private: + std::atomic<impl::NumberRangeFormatterImpl*> fAtomicFormatter = {}; + + const impl::NumberRangeFormatterImpl* getFormatter(UErrorCode& stauts) const; + + explicit LocalizedNumberRangeFormatter( + const NumberRangeFormatterSettings<LocalizedNumberRangeFormatter>& other); + + explicit LocalizedNumberRangeFormatter( + NumberRangeFormatterSettings<LocalizedNumberRangeFormatter>&& src) U_NOEXCEPT; + + LocalizedNumberRangeFormatter(const impl::RangeMacroProps ¯os, const Locale &locale); + + LocalizedNumberRangeFormatter(impl::RangeMacroProps &¯os, const Locale &locale); + + void clear(); + + // To give the fluent setters access to this class's constructor: + friend class NumberRangeFormatterSettings<UnlocalizedNumberRangeFormatter>; + friend class NumberRangeFormatterSettings<LocalizedNumberRangeFormatter>; + + // To give UnlocalizedNumberRangeFormatter::locale() access to this class's constructor: + friend class UnlocalizedNumberRangeFormatter; +}; + +/** + * The result of a number range formatting operation. This class allows the result to be exported in several data types, + * including a UnicodeString and a FieldPositionIterator. + * + * @draft ICU 63 + */ +class U_I18N_API FormattedNumberRange : public UMemory { + public: + /** + * Returns a UnicodeString representation of the formatted number range. + * + * @param status + * Set if an error occurs while formatting the number to the UnicodeString. + * @return a UnicodeString containing the localized number range. + * @draft ICU 63 + */ + UnicodeString toString(UErrorCode& status) const; + + /** + * Appends the formatted number range to an Appendable. + * + * @param appendable + * The Appendable to which to append the formatted number range string. + * @param status + * Set if an error occurs while formatting the number range to the Appendable. + * @return The same Appendable, for chaining. + * @draft ICU 63 + * @see Appendable + */ + Appendable &appendTo(Appendable &appendable, UErrorCode& status) const; + + /** + * Determines the start (inclusive) and end (exclusive) indices of the next occurrence of the given + * <em>field</em> in the output string. This allows you to determine the locations of, for example, + * the integer part, fraction part, or symbols. + * + * If both sides of the range have the same field, the field will occur twice, once before the + * range separator and once after the range separator, if applicable. + * + * If a field occurs just once, calling this method will find that occurrence and return it. If a + * field occurs multiple times, this method may be called repeatedly with the following pattern: + * + * <pre> + * FieldPosition fpos(UNUM_INTEGER_FIELD); + * while (formattedNumberRange.nextFieldPosition(fpos, status)) { + * // do something with fpos. + * } + * </pre> + * + * This method is useful if you know which field to query. If you want all available field position + * information, use #getAllFieldPositions(). + * + * @param fieldPosition + * Input+output variable. See {@link FormattedNumber#nextFieldPosition}. + * @param status + * Set if an error occurs while populating the FieldPosition. + * @return TRUE if a new occurrence of the field was found; FALSE otherwise. + * @draft ICU 63 + * @see UNumberFormatFields + */ + UBool nextFieldPosition(FieldPosition& fieldPosition, UErrorCode& status) const; + + /** + * Export the formatted number range to a FieldPositionIterator. This allows you to determine which characters in + * the output string correspond to which <em>fields</em>, such as the integer part, fraction part, and sign. + * + * If information on only one field is needed, use #nextFieldPosition() instead. + * + * @param iterator + * The FieldPositionIterator to populate with all of the fields present in the formatted number. + * @param status + * Set if an error occurs while populating the FieldPositionIterator. + * @draft ICU 63 + * @see UNumberFormatFields + */ + void getAllFieldPositions(FieldPositionIterator &iterator, UErrorCode &status) const; + + /** + * Export the first formatted number as a decimal number. This endpoint + * is useful for obtaining the exact number being printed after scaling + * and rounding have been applied by the number range formatting pipeline. + * + * The syntax of the unformatted number is a "numeric string" + * as defined in the Decimal Arithmetic Specification, available at + * http://speleotrove.com/decimal + * + * @return A decimal representation of the first formatted number. + * @draft ICU 63 + * @see NumberRangeFormatter + * @see #getSecondDecimal + */ + UnicodeString getFirstDecimal(UErrorCode& status) const; + + /** + * Export the second formatted number as a decimal number. This endpoint + * is useful for obtaining the exact number being printed after scaling + * and rounding have been applied by the number range formatting pipeline. + * + * The syntax of the unformatted number is a "numeric string" + * as defined in the Decimal Arithmetic Specification, available at + * http://speleotrove.com/decimal + * + * @return A decimal representation of the second formatted number. + * @draft ICU 63 + * @see NumberRangeFormatter + * @see #getFirstDecimal + */ + UnicodeString getSecondDecimal(UErrorCode& status) const; + + /** + * Returns whether the pair of numbers was successfully formatted as a range or whether an identity fallback was + * used. For example, if the first and second number were the same either before or after rounding occurred, an + * identity fallback was used. + * + * @return An indication the resulting identity situation in the formatted number range. + * @draft ICU 63 + * @see UNumberRangeIdentityFallback + */ + UNumberRangeIdentityResult getIdentityResult(UErrorCode& status) const; + + /** + * Copying not supported; use move constructor instead. + */ + FormattedNumberRange(const FormattedNumberRange&) = delete; + + /** + * Copying not supported; use move assignment instead. + */ + FormattedNumberRange& operator=(const FormattedNumberRange&) = delete; + + /** + * Move constructor: + * Leaves the source FormattedNumberRange in an undefined state. + * @draft ICU 63 + */ + FormattedNumberRange(FormattedNumberRange&& src) U_NOEXCEPT; + + /** + * Move assignment: + * Leaves the source FormattedNumberRange in an undefined state. + * @draft ICU 63 + */ + FormattedNumberRange& operator=(FormattedNumberRange&& src) U_NOEXCEPT; + + /** + * Destruct an instance of FormattedNumberRange, cleaning up any memory it might own. + * @draft ICU 63 + */ + ~FormattedNumberRange(); + + private: + // Can't use LocalPointer because UFormattedNumberRangeData is forward-declared + const impl::UFormattedNumberRangeData *fResults; + + // Error code for the terminal methods + UErrorCode fErrorCode; + + /** + * Internal constructor from data type. Adopts the data pointer. + * @internal + */ + explicit FormattedNumberRange(impl::UFormattedNumberRangeData *results) + : fResults(results), fErrorCode(U_ZERO_ERROR) {}; + + explicit FormattedNumberRange(UErrorCode errorCode) + : fResults(nullptr), fErrorCode(errorCode) {}; + + void getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih, UErrorCode& status) const; + + // To give LocalizedNumberRangeFormatter format methods access to this class's constructor: + friend class LocalizedNumberRangeFormatter; +}; + +/** + * See the main description in numberrangeformatter.h for documentation and examples. + * + * @draft ICU 63 + */ +class U_I18N_API NumberRangeFormatter final { + public: + /** + * Call this method at the beginning of a NumberRangeFormatter fluent chain in which the locale is not currently + * known at the call site. + * + * @return An {@link UnlocalizedNumberRangeFormatter}, to be used for chaining. + * @draft ICU 63 + */ + static UnlocalizedNumberRangeFormatter with(); + + /** + * Call this method at the beginning of a NumberRangeFormatter fluent chain in which the locale is known at the call + * site. + * + * @param locale + * The locale from which to load formats and symbols for number range formatting. + * @return A {@link LocalizedNumberRangeFormatter}, to be used for chaining. + * @draft ICU 63 + */ + static LocalizedNumberRangeFormatter withLocale(const Locale &locale); + + /** + * Use factory methods instead of the constructor to create a NumberFormatter. + */ + NumberRangeFormatter() = delete; +}; + +} // namespace number +U_NAMESPACE_END + +#endif // U_HIDE_DRAFT_API + +#endif // __NUMBERRANGEFORMATTER_H__ + +#endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/unicode/numfmt.h b/deps/icu-small/source/i18n/unicode/numfmt.h index 572e6afc71..871fbd93e1 100644 --- a/deps/icu-small/source/i18n/unicode/numfmt.h +++ b/deps/icu-small/source/i18n/unicode/numfmt.h @@ -56,7 +56,6 @@ class StringEnumeration; * <p><strong>IMPORTANT:</strong> 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. - * <hr/> * * Abstract base class for all number formats. Provides interface for * formatting and parsing a number. Also provides methods for @@ -710,7 +709,7 @@ public: * The default formatting style is locale dependent. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * {@link icu::number::NumberFormatter} instead of NumberFormat. * @stable ICU 2.0 */ static NumberFormat* U_EXPORT2 createInstance(UErrorCode&); @@ -721,7 +720,7 @@ public: * @param inLocale the given locale. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * {@link icu::number::NumberFormatter} instead of NumberFormat. * @stable ICU 2.0 */ static NumberFormat* U_EXPORT2 createInstance(const Locale& inLocale, @@ -731,7 +730,7 @@ public: * Create a specific style NumberFormat for the specified locale. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * {@link icu::number::NumberFormatter} instead of NumberFormat. * @param desiredLocale the given locale. * @param style the given style. * @param errorCode Output param filled with success/failure status. @@ -770,7 +769,7 @@ public: * Returns a currency format for the current default locale. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * {@link icu::number::NumberFormatter} instead of NumberFormat. * @stable ICU 2.0 */ static NumberFormat* U_EXPORT2 createCurrencyInstance(UErrorCode&); @@ -779,7 +778,7 @@ public: * Returns a currency format for the specified locale. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * {@link icu::number::NumberFormatter} instead of NumberFormat. * @param inLocale the given locale. * @stable ICU 2.0 */ @@ -790,7 +789,7 @@ public: * Returns a percentage format for the current default locale. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * {@link icu::number::NumberFormatter} instead of NumberFormat. * @stable ICU 2.0 */ static NumberFormat* U_EXPORT2 createPercentInstance(UErrorCode&); @@ -799,7 +798,7 @@ public: * Returns a percentage format for the specified locale. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * {@link icu::number::NumberFormatter} instead of NumberFormat. * @param inLocale the given locale. * @stable ICU 2.0 */ @@ -810,7 +809,7 @@ public: * Returns a scientific format for the current default locale. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * {@link icu::number::NumberFormatter} instead of NumberFormat. * @stable ICU 2.0 */ static NumberFormat* U_EXPORT2 createScientificInstance(UErrorCode&); @@ -819,7 +818,7 @@ public: * Returns a scientific format for the specified locale. * <p> * <strong>NOTE:</strong> New users are strongly encouraged to use - * {@link NumberFormatter} instead of NumberFormat. + * {@link icu::number::NumberFormatter} instead of NumberFormat. * @param inLocale the given locale. * @stable ICU 2.0 */ @@ -1028,14 +1027,14 @@ public: * Get the rounding mode. This will always return NumberFormat::ERoundingMode::kRoundUnnecessary * if the subclass does not support rounding. * @return A rounding mode - * @draft ICU 60 + * @stable ICU 60 */ virtual ERoundingMode getRoundingMode(void) const; /** * Set the rounding mode. If a subclass does not support rounding, this will do nothing. * @param roundingMode A rounding mode - * @draft ICU 60 + * @stable ICU 60 */ virtual void setRoundingMode(ERoundingMode roundingMode); diff --git a/deps/icu-small/source/i18n/unicode/plurfmt.h b/deps/icu-small/source/i18n/unicode/plurfmt.h index 9a83e52550..6b757c8841 100644 --- a/deps/icu-small/source/i18n/unicode/plurfmt.h +++ b/deps/icu-small/source/i18n/unicode/plurfmt.h @@ -520,15 +520,7 @@ public: */ virtual UClassID getDynamicClassID() const; -#if (defined(__xlC__) && (__xlC__ < 0x0C00)) || (U_PLATFORM == U_PF_OS390) || (U_PLATFORM ==U_PF_OS400) -// Work around a compiler bug on xlC 11.1 on AIX 7.1 that would -// prevent PluralSelectorAdapter from implementing private PluralSelector. -// xlC error message: -// 1540-0300 (S) The "private" member "class icu_49::PluralFormat::PluralSelector" cannot be accessed. -public: -#else private: -#endif /** * @internal */ @@ -564,10 +556,6 @@ private: PluralRules* pluralRules; }; -#if defined(__xlC__) -// End of xlC bug workaround, keep remaining definitions private. -private: -#endif Locale locale; MessagePattern msgPattern; NumberFormat* numberFormat; diff --git a/deps/icu-small/source/i18n/unicode/plurrule.h b/deps/icu-small/source/i18n/unicode/plurrule.h index 03dea3f1b9..daeed52bee 100644 --- a/deps/icu-small/source/i18n/unicode/plurrule.h +++ b/deps/icu-small/source/i18n/unicode/plurrule.h @@ -118,7 +118,6 @@ class SharedPluralRules; * Examples are in the following table: * </p> * <table border='1' style="border-collapse:collapse"> - * <tbody> * <tr> * <th>n</th> * <th>i</th> @@ -155,7 +154,6 @@ class SharedPluralRules; * <td align="right">23</td> * <td>2</td> * </tr> - * </tbody> * </table> * <p> * The difference between 'in' and 'within' is that 'in' only includes integers in the specified range, while 'within' @@ -499,6 +497,12 @@ private: UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status); RuleChain *rulesForKeyword(const UnicodeString &keyword) const; + /** + * An internal status variable used to indicate that the object is in an 'invalid' state. + * Used by copy constructor, the assignment operator and the clone method. + */ + UErrorCode mInternalStatus; + friend class PluralRuleParser; }; diff --git a/deps/icu-small/source/i18n/unicode/rbnf.h b/deps/icu-small/source/i18n/unicode/rbnf.h index 2d284909f8..f7cd85a322 100644 --- a/deps/icu-small/source/i18n/unicode/rbnf.h +++ b/deps/icu-small/source/i18n/unicode/rbnf.h @@ -313,7 +313,6 @@ enum URBNFRuleSetTag { * <td>The rule for an IEEE 754 NaN (not a number).</td> * </tr> * <tr> - * <tr> * <td><em>nothing</em></td> * <td>If the rule's rule descriptor is left out, the base value is one plus the * preceding rule's base value (or zero if this is the first rule in the list) in a normal @@ -1013,14 +1012,14 @@ public: /** * Get the rounding mode. * @return A rounding mode - * @draft ICU 60 + * @stable ICU 60 */ virtual ERoundingMode getRoundingMode(void) const; /** * Set the rounding mode. * @param roundingMode A rounding mode - * @draft ICU 60 + * @stable ICU 60 */ virtual void setRoundingMode(ERoundingMode roundingMode); @@ -1095,7 +1094,7 @@ private: void format(double number, NFRuleSet& rs, UnicodeString& toAppendTo, UErrorCode& status) const; private: - NFRuleSet **ruleSets; + NFRuleSet **fRuleSets; UnicodeString* ruleSetDescriptions; int32_t numRuleSets; NFRuleSet *defaultRuleSet; @@ -1104,7 +1103,7 @@ private: DecimalFormatSymbols* decimalFormatSymbols; NFRule *defaultInfinityRule; NFRule *defaultNaNRule; - ERoundingMode roundingMode; + ERoundingMode fRoundingMode; UBool lenient; UnicodeString* lenientParseRules; LocalizationInfo* localizations; diff --git a/deps/icu-small/source/i18n/unicode/region.h b/deps/icu-small/source/i18n/unicode/region.h index 667c4051f0..ccd63901a5 100644 --- a/deps/icu-small/source/i18n/unicode/region.h +++ b/deps/icu-small/source/i18n/unicode/region.h @@ -192,7 +192,7 @@ private: char id[4]; UnicodeString idStr; int32_t code; - URegionType type; + URegionType fType; Region *containingRegion; UVector *containedRegions; UVector *preferredValues; diff --git a/deps/icu-small/source/i18n/unicode/reldatefmt.h b/deps/icu-small/source/i18n/unicode/reldatefmt.h index abd43522c3..dd8bc53d55 100644 --- a/deps/icu-small/source/i18n/unicode/reldatefmt.h +++ b/deps/icu-small/source/i18n/unicode/reldatefmt.h @@ -165,12 +165,20 @@ typedef enum UDateAbsoluteUnit { */ UDAT_ABSOLUTE_NOW, +#ifndef U_HIDE_DRAFT_API + /** + * Quarter + * @draft ICU 63 + */ + UDAT_ABSOLUTE_QUARTER, +#endif // U_HIDE_DRAFT_API + #ifndef U_HIDE_DEPRECATED_API /** * One more than the highest normal UDateAbsoluteUnit value. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ - UDAT_ABSOLUTE_UNIT_COUNT + UDAT_ABSOLUTE_UNIT_COUNT = UDAT_ABSOLUTE_NOW + 2 #endif // U_HIDE_DEPRECATED_API } UDateAbsoluteUnit; @@ -328,7 +336,7 @@ public: * @param nfToAdopt Constructed object takes ownership of this pointer. * It is an error for caller to delete this pointer or change its * contents after calling this constructor. - * @status Any error is returned here. + * @param status Any error is returned here. * @stable ICU 53 */ RelativeDateTimeFormatter( @@ -346,7 +354,7 @@ public: * @param style the format style. The UDAT_RELATIVE bit field has no effect. * @param capitalizationContext A value from UDisplayContext that pertains to * capitalization. - * @status Any error is returned here. + * @param status Any error is returned here. * @stable ICU 54 */ RelativeDateTimeFormatter( diff --git a/deps/icu-small/source/i18n/unicode/smpdtfmt.h b/deps/icu-small/source/i18n/unicode/smpdtfmt.h index 305412b8d1..929c1b4675 100644 --- a/deps/icu-small/source/i18n/unicode/smpdtfmt.h +++ b/deps/icu-small/source/i18n/unicode/smpdtfmt.h @@ -1147,7 +1147,7 @@ public: * Overrides base class method and * This method clears per field NumberFormat instances * previously set by {@see adoptNumberFormat(const UnicodeString&, NumberFormat*, UErrorCode)} - * @param adoptNF the NumbeferFormat used + * @param formatToAdopt the NumbeferFormat used * @stable ICU 54 */ void adoptNumberFormat(NumberFormat *formatToAdopt); @@ -1162,7 +1162,7 @@ public: * Per field NumberFormat can also be cleared in {@see DateFormat::setNumberFormat(const NumberFormat& newNumberFormat)} * * @param fields the fields to override(like y) - * @param adoptNF the NumbeferFormat used + * @param formatToAdopt the NumbeferFormat used * @param status Receives a status code, which will be U_ZERO_ERROR * if the operation succeeds. * @stable ICU 54 diff --git a/deps/icu-small/source/i18n/unicode/translit.h b/deps/icu-small/source/i18n/unicode/translit.h index dc31d97bc6..6b4888145f 100644 --- a/deps/icu-small/source/i18n/unicode/translit.h +++ b/deps/icu-small/source/i18n/unicode/translit.h @@ -31,7 +31,6 @@ U_NAMESPACE_BEGIN class UnicodeFilter; class UnicodeSet; -class CompoundTransliterator; class TransliteratorParser; class NormalizationTransliterator; class TransliteratorIDParser; @@ -77,8 +76,7 @@ class TransliteratorIDParser; * transliteration. For example, given a string <code>input</code> * and a transliterator <code>t</code>, the call * - * \htmlonly<blockquote>\endhtmlonly<code>String result = t.transliterate(input); - * </code>\htmlonly</blockquote>\endhtmlonly + * String result = t.transliterate(input); * * will transliterate it and return the result. Other methods allow * the client to specify a substring to be transliterated and to use @@ -98,22 +96,20 @@ class TransliteratorIDParser; * contents of the buffer may show text being modified as each new * character arrives. * - * <p>Consider the simple <code>RuleBasedTransliterator</code>: - * - * \htmlonly<blockquote>\endhtmlonly<code> - * th>{theta}<br> - * t>{tau} - * </code>\htmlonly</blockquote>\endhtmlonly + * <p>Consider the simple rule-based Transliterator: + * <pre> + * th>{theta} + * t>{tau} + * </pre> * * When the user types 't', nothing will happen, since the * transliterator is waiting to see if the next character is 'h'. To * remedy this, we introduce the notion of a cursor, marked by a '|' * in the output string: - * - * \htmlonly<blockquote>\endhtmlonly<code> - * t>|{tau}<br> - * {tau}h>{theta} - * </code>\htmlonly</blockquote>\endhtmlonly + * <pre> + * t>|{tau} + * {tau}h>{theta} + * </pre> * * Now when the user types 't', tau appears, and if the next character * is 'h', the tau changes to a theta. This is accomplished by @@ -135,7 +131,7 @@ class TransliteratorIDParser; * which the transliterator last stopped, either because it reached * the end, or because it required more characters to disambiguate * between possible inputs. The <code>CURSOR</code> can also be - * explicitly set by rules in a <code>RuleBasedTransliterator</code>. + * explicitly set by rules in a rule-based Transliterator. * Any characters before the <code>CURSOR</code> index are frozen; * future keyboard transliteration calls within this input sequence * will not change them. New text is inserted at the @@ -237,6 +233,255 @@ class TransliteratorIDParser; * if the performance of these methods can be improved over the * performance obtained by the default implementations in this class. * + * <p><b>Rule syntax</b> + * + * <p>A set of rules determines how to perform translations. + * Rules within a rule set are separated by semicolons (';'). + * To include a literal semicolon, prefix it with a backslash ('\'). + * Unicode Pattern_White_Space is ignored. + * If the first non-blank character on a line is '#', + * the entire line is ignored as a comment. + * + * <p>Each set of rules consists of two groups, one forward, and one + * reverse. This is a convention that is not enforced; rules for one + * direction may be omitted, with the result that translations in + * that direction will not modify the source text. In addition, + * bidirectional forward-reverse rules may be specified for + * symmetrical transformations. + * + * <p>Note: Another description of the Transliterator rule syntax is available in + * <a href="https://www.unicode.org/reports/tr35/tr35-general.html#Transform_Rules_Syntax">section + * Transform Rules Syntax of UTS #35: Unicode LDML</a>. + * The rules are shown there using arrow symbols ← and → and ↔. + * ICU supports both those and the equivalent ASCII symbols < and > and <>. + * + * <p>Rule statements take one of the following forms: + * + * <dl> + * <dt><code>$alefmadda=\\u0622;</code></dt> + * <dd><strong>Variable definition.</strong> The name on the + * left is assigned the text on the right. In this example, + * after this statement, instances of the left hand name, + * "<code>$alefmadda</code>", will be replaced by + * the Unicode character U+0622. Variable names must begin + * with a letter and consist only of letters, digits, and + * underscores. Case is significant. Duplicate names cause + * an exception to be thrown, that is, variables cannot be + * redefined. The right hand side may contain well-formed + * text of any length, including no text at all ("<code>$empty=;</code>"). + * The right hand side may contain embedded <code>UnicodeSet</code> + * patterns, for example, "<code>$softvowel=[eiyEIY]</code>".</dd> + * <dt><code>ai>$alefmadda;</code></dt> + * <dd><strong>Forward translation rule.</strong> This rule + * states that the string on the left will be changed to the + * string on the right when performing forward + * transliteration.</dd> + * <dt><code>ai<$alefmadda;</code></dt> + * <dd><strong>Reverse translation rule.</strong> This rule + * states that the string on the right will be changed to + * the string on the left when performing reverse + * transliteration.</dd> + * </dl> + * + * <dl> + * <dt><code>ai<>$alefmadda;</code></dt> + * <dd><strong>Bidirectional translation rule.</strong> This + * rule states that the string on the right will be changed + * to the string on the left when performing forward + * transliteration, and vice versa when performing reverse + * transliteration.</dd> + * </dl> + * + * <p>Translation rules consist of a <em>match pattern</em> and an <em>output + * string</em>. The match pattern consists of literal characters, + * optionally preceded by context, and optionally followed by + * context. Context characters, like literal pattern characters, + * must be matched in the text being transliterated. However, unlike + * literal pattern characters, they are not replaced by the output + * text. For example, the pattern "<code>abc{def}</code>" + * indicates the characters "<code>def</code>" must be + * preceded by "<code>abc</code>" for a successful match. + * If there is a successful match, "<code>def</code>" will + * be replaced, but not "<code>abc</code>". The final '<code>}</code>' + * is optional, so "<code>abc{def</code>" is equivalent to + * "<code>abc{def}</code>". Another example is "<code>{123}456</code>" + * (or "<code>123}456</code>") in which the literal + * pattern "<code>123</code>" must be followed by "<code>456</code>". + * + * <p>The output string of a forward or reverse rule consists of + * characters to replace the literal pattern characters. If the + * output string contains the character '<code>|</code>', this is + * taken to indicate the location of the <em>cursor</em> after + * replacement. The cursor is the point in the text at which the + * next replacement, if any, will be applied. The cursor is usually + * placed within the replacement text; however, it can actually be + * placed into the precending or following context by using the + * special character '@'. Examples: + * + * <pre> + * a {foo} z > | @ bar; # foo -> bar, move cursor before a + * {foo} xyz > bar @@|; # foo -> bar, cursor between y and z + * </pre> + * + * <p><b>UnicodeSet</b> + * + * <p><code>UnicodeSet</code> patterns may appear anywhere that + * makes sense. They may appear in variable definitions. + * Contrariwise, <code>UnicodeSet</code> patterns may themselves + * contain variable references, such as "<code>$a=[a-z];$not_a=[^$a]</code>", + * or "<code>$range=a-z;$ll=[$range]</code>". + * + * <p><code>UnicodeSet</code> patterns may also be embedded directly + * into rule strings. Thus, the following two rules are equivalent: + * + * <pre> + * $vowel=[aeiou]; $vowel>'*'; # One way to do this + * [aeiou]>'*'; # Another way + * </pre> + * + * <p>See {@link UnicodeSet} for more documentation and examples. + * + * <p><b>Segments</b> + * + * <p>Segments of the input string can be matched and copied to the + * output string. This makes certain sets of rules simpler and more + * general, and makes reordering possible. For example: + * + * <pre> + * ([a-z]) > $1 $1; # double lowercase letters + * ([:Lu:]) ([:Ll:]) > $2 $1; # reverse order of Lu-Ll pairs + * </pre> + * + * <p>The segment of the input string to be copied is delimited by + * "<code>(</code>" and "<code>)</code>". Up to + * nine segments may be defined. Segments may not overlap. In the + * output string, "<code>$1</code>" through "<code>$9</code>" + * represent the input string segments, in left-to-right order of + * definition. + * + * <p><b>Anchors</b> + * + * <p>Patterns can be anchored to the beginning or the end of the text. This is done with the + * special characters '<code>^</code>' and '<code>$</code>'. For example: + * + * <pre> + * ^ a > 'BEG_A'; # match 'a' at start of text + * a > 'A'; # match other instances of 'a' + * z $ > 'END_Z'; # match 'z' at end of text + * z > 'Z'; # match other instances of 'z' + * </pre> + * + * <p>It is also possible to match the beginning or the end of the text using a <code>UnicodeSet</code>. + * This is done by including a virtual anchor character '<code>$</code>' at the end of the + * set pattern. Although this is usually the match chafacter for the end anchor, the set will + * match either the beginning or the end of the text, depending on its placement. For + * example: + * + * <pre> + * $x = [a-z$]; # match 'a' through 'z' OR anchor + * $x 1 > 2; # match '1' after a-z or at the start + * 3 $x > 4; # match '3' before a-z or at the end + * </pre> + * + * <p><b>Example</b> + * + * <p>The following example rules illustrate many of the features of + * the rule language. + * + * <table border="0" cellpadding="4"> + * <tr> + * <td style="vertical-align: top;">Rule 1.</td> + * <td style="vertical-align: top; write-space: nowrap;"><code>abc{def}>x|y</code></td> + * </tr> + * <tr> + * <td style="vertical-align: top;">Rule 2.</td> + * <td style="vertical-align: top; write-space: nowrap;"><code>xyz>r</code></td> + * </tr> + * <tr> + * <td style="vertical-align: top;">Rule 3.</td> + * <td style="vertical-align: top; write-space: nowrap;"><code>yz>q</code></td> + * </tr> + * </table> + * + * <p>Applying these rules to the string "<code>adefabcdefz</code>" + * yields the following results: + * + * <table border="0" cellpadding="4"> + * <tr> + * <td style="vertical-align: top; write-space: nowrap;"><code>|adefabcdefz</code></td> + * <td style="vertical-align: top;">Initial state, no rules match. Advance + * cursor.</td> + * </tr> + * <tr> + * <td style="vertical-align: top; write-space: nowrap;"><code>a|defabcdefz</code></td> + * <td style="vertical-align: top;">Still no match. Rule 1 does not match + * because the preceding context is not present.</td> + * </tr> + * <tr> + * <td style="vertical-align: top; write-space: nowrap;"><code>ad|efabcdefz</code></td> + * <td style="vertical-align: top;">Still no match. Keep advancing until + * there is a match...</td> + * </tr> + * <tr> + * <td style="vertical-align: top; write-space: nowrap;"><code>ade|fabcdefz</code></td> + * <td style="vertical-align: top;">...</td> + * </tr> + * <tr> + * <td style="vertical-align: top; write-space: nowrap;"><code>adef|abcdefz</code></td> + * <td style="vertical-align: top;">...</td> + * </tr> + * <tr> + * <td style="vertical-align: top; write-space: nowrap;"><code>adefa|bcdefz</code></td> + * <td style="vertical-align: top;">...</td> + * </tr> + * <tr> + * <td style="vertical-align: top; write-space: nowrap;"><code>adefab|cdefz</code></td> + * <td style="vertical-align: top;">...</td> + * </tr> + * <tr> + * <td style="vertical-align: top; write-space: nowrap;"><code>adefabc|defz</code></td> + * <td style="vertical-align: top;">Rule 1 matches; replace "<code>def</code>" + * with "<code>xy</code>" and back up the cursor + * to before the '<code>y</code>'.</td> + * </tr> + * <tr> + * <td style="vertical-align: top; write-space: nowrap;"><code>adefabcx|yz</code></td> + * <td style="vertical-align: top;">Although "<code>xyz</code>" is + * present, rule 2 does not match because the cursor is + * before the '<code>y</code>', not before the '<code>x</code>'. + * Rule 3 does match. Replace "<code>yz</code>" + * with "<code>q</code>".</td> + * </tr> + * <tr> + * <td style="vertical-align: top; write-space: nowrap;"><code>adefabcxq|</code></td> + * <td style="vertical-align: top;">The cursor is at the end; + * transliteration is complete.</td> + * </tr> + * </table> + * + * <p>The order of rules is significant. If multiple rules may match + * at some point, the first matching rule is applied. + * + * <p>Forward and reverse rules may have an empty output string. + * Otherwise, an empty left or right hand side of any statement is a + * syntax error. + * + * <p>Single quotes are used to quote any character other than a + * digit or letter. To specify a single quote itself, inside or + * outside of quotes, use two single quotes in a row. For example, + * the rule "<code>'>'>o''clock</code>" changes the + * string "<code>></code>" to the string "<code>o'clock</code>". + * + * <p><b>Notes</b> + * + * <p>While a Transliterator is being built from rules, it checks that + * the rules are added in proper order. For example, if the rule + * "a>x" is followed by the rule "ab>y", + * then the second rule will throw an exception. The reason is that + * the second rule can never be triggered, since the first rule + * always matches anything it matches. In other words, the first + * rule <em>masks</em> the second rule. + * * @author Alan Liu * @stable ICU 2.0 */ @@ -499,9 +744,9 @@ public: * for details. * @param text the buffer holding transliterated and * untransliterated text - * @param index an array of three integers. See {@link #transliterate(Replaceable&, UTransPosition&, const UnicodeString*, UErrorCode&) const }. + * @param index an array of three integers. * @param status Output param to filled in with a success or an error. - * @see #transliterate(Replaceable, int[], String) + * @see #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode &) const * @stable ICU 2.0 */ virtual void transliterate(Replaceable& text, UTransPosition& index, @@ -632,7 +877,7 @@ public: /** * Transliterate a substring of text, as specified by index, taking filters * into account. This method is for subclasses that need to delegate to - * another transliterator, such as CompoundTransliterator. + * another transliterator. * @param text the text to be transliterated * @param index the position indices * @param incremental if TRUE, then assume more characters may be inserted @@ -846,17 +1091,19 @@ public: /** * Returns a <code>Transliterator</code> object constructed from - * the given rule string. This will be a RuleBasedTransliterator, + * the given rule string. This will be a rule-based Transliterator, * if the rule string contains only rules, or a - * CompoundTransliterator, if it contains ID blocks, or a - * NullTransliterator, if it contains ID blocks which parse as + * compound Transliterator, if it contains ID blocks, or a + * null Transliterator, if it contains ID blocks which parse as * empty for the given direction. + * * @param ID the id for the transliterator. * @param rules rules, separated by ';' * @param dir either FORWARD or REVERSE. - * @param parseError Struct to recieve information on position + * @param parseError Struct to receive information on position * of error if an error is encountered * @param status Output param set to success/failure code. + * @return a newly created Transliterator * @stable ICU 2.0 */ static Transliterator* U_EXPORT2 createFromRules(const UnicodeString& ID, diff --git a/deps/icu-small/source/i18n/unicode/tzfmt.h b/deps/icu-small/source/i18n/unicode/tzfmt.h index 633cd8dc69..d2aa768b8c 100644 --- a/deps/icu-small/source/i18n/unicode/tzfmt.h +++ b/deps/icu-small/source/i18n/unicode/tzfmt.h @@ -237,10 +237,10 @@ typedef enum UTimeZoneFormatParseOption { */ UTZFMT_PARSE_OPTION_ALL_STYLES = 0x01, /** - * When parsing a time zone display name in UTZFMT_STYLE_SPECIFIC_SHORT, + * When parsing a time zone display name in \link UTZFMT_STYLE_SPECIFIC_SHORT \endlink, * look for the IANA tz database compatible zone abbreviations in addition - * to the localized names coming from the {@link TimeZoneNames} currently - * used by the {@link TimeZoneFormat}. + * to the localized names coming from the icu::TimeZoneNames currently + * used by the icu::TimeZoneFormat. * @stable ICU 54 */ UTZFMT_PARSE_OPTION_TZ_DATABASE_ABBREVIATIONS = 0x02 diff --git a/deps/icu-small/source/i18n/unicode/ucal.h b/deps/icu-small/source/i18n/unicode/ucal.h index 10d8bc5274..889a1ec51d 100644 --- a/deps/icu-small/source/i18n/unicode/ucal.h +++ b/deps/icu-small/source/i18n/unicode/ucal.h @@ -139,6 +139,19 @@ * For example, subtracting 5 days from the date <code>September 12, 1996</code> * results in <code>September 7, 1996</code>. * + * <p> + * The Japanese calendar uses a combination of era name and year number. + * When an emperor of Japan abdicates and a new emperor ascends the throne, + * a new era is declared and year number is reset to 1. Even if the date of + * abdication is scheduled ahead of time, the new era name might not be + * announced until just before the date. In such case, ICU4C may include + * a start date of future era without actual era name, but not enabled + * by default. ICU4C users who want to test the behavior of the future era + * can enable the tentative era by: + * <ul> + * <li>Environment variable <code>ICU_ENABLE_TENTATIVE_ERA=true</code>.</li> + * </ul> + * * @stable ICU 2.0 */ diff --git a/deps/icu-small/source/i18n/unicode/ucol.h b/deps/icu-small/source/i18n/unicode/ucol.h index b5bacbfcb4..f084ac61e6 100644 --- a/deps/icu-small/source/i18n/unicode/ucol.h +++ b/deps/icu-small/source/i18n/unicode/ucol.h @@ -1149,7 +1149,7 @@ ucol_getUCAVersion(const UCollator* coll, UVersionInfo info); * The recommended way to achieve "merged" sorting is by * concatenating strings with U+FFFE between them. * The concatenation has the same sort order as the merged sort keys, - * but merge(getSortKey(str1), getSortKey(str2)) may differ from getSortKey(str1 + '\uFFFE' + str2). + * but merge(getSortKey(str1), getSortKey(str2)) may differ from getSortKey(str1 + '\\uFFFE' + str2). * Using strings with U+FFFE may yield shorter sort keys. * * For details about Sort Key Features see @@ -1294,6 +1294,7 @@ U_STABLE uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCod * the top of one of the supported reordering groups, * and it must not be beyond the last of those groups. * See ucol_setMaxVariable(). + * @param coll collator to be set * @param varTop primary weight, as returned by ucol_setVariableTop or ucol_getVariableTop * @param status error code * @see ucol_getVariableTop diff --git a/deps/icu-small/source/i18n/unicode/ugender.h b/deps/icu-small/source/i18n/unicode/ugender.h index d015a2300c..903f3dd5de 100644 --- a/deps/icu-small/source/i18n/unicode/ugender.h +++ b/deps/icu-small/source/i18n/unicode/ugender.h @@ -49,11 +49,11 @@ enum UGender { */ typedef enum UGender UGender; +struct UGenderInfo; /** * Opaque UGenderInfo object for use in C programs. * @stable ICU 50 */ -struct UGenderInfo; typedef struct UGenderInfo UGenderInfo; /** @@ -77,7 +77,7 @@ ugender_getInstance(const char *locale, UErrorCode *status); * @stable ICU 50 */ U_STABLE UGender U_EXPORT2 -ugender_getListGender(const UGenderInfo* genderinfo, const UGender *genders, int32_t size, UErrorCode *status); +ugender_getListGender(const UGenderInfo* genderInfo, const UGender *genders, int32_t size, UErrorCode *status); #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/unicode/ulistformatter.h b/deps/icu-small/source/i18n/unicode/ulistformatter.h new file mode 100644 index 0000000000..242d7d2164 --- /dev/null +++ b/deps/icu-small/source/i18n/unicode/ulistformatter.h @@ -0,0 +1,150 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +/* +***************************************************************************************** +* Copyright (C) 2015-2016, International Business Machines +* Corporation and others. All Rights Reserved. +***************************************************************************************** +*/ + +#ifndef ULISTFORMATTER_H +#define ULISTFORMATTER_H + +#include "unicode/utypes.h" + +#if !UCONFIG_NO_FORMATTING + +#include "unicode/localpointer.h" + +/** + * \file + * \brief C API: Format a list in a locale-appropriate way. + * + * A UListFormatter is used to format a list of items in a locale-appropriate way, + * using data from CLDR. + * Example: Input data ["Alice", "Bob", "Charlie", "Delta"] will be formatted + * as "Alice, Bob, Charlie, and Delta" in English. + */ + +/** + * Opaque UListFormatter object for use in C + * @stable ICU 55 + */ +struct UListFormatter; +typedef struct UListFormatter UListFormatter; /**< C typedef for struct UListFormatter. @stable ICU 55 */ + +#ifndef U_HIDE_DRAFT_API +/** + * FieldPosition and UFieldPosition selectors for format fields + * defined by ListFormatter. + * @draft ICU 63 + */ +typedef enum UListFormatterField { + /** + * The literal text in the result which came from the resources. + * @draft ICU 63 + */ + ULISTFMT_LITERAL_FIELD, + /** + * The element text in the result which came from the input strings. + * @draft ICU 63 + */ + ULISTFMT_ELEMENT_FIELD +} UListFormatterField; +#endif // U_HIDE_DRAFT_API + +/** + * Open a new UListFormatter object using the rules for a given locale. + * @param locale + * The locale whose rules should be used; may be NULL for + * default locale. + * @param status + * A pointer to a standard ICU UErrorCode (input/output parameter). + * Its input value must pass the U_SUCCESS() test, or else the + * function returns immediately. The caller should check its output + * value with U_FAILURE(), or use with function chaining (see User + * Guide for details). + * @return + * A pointer to a UListFormatter object for the specified locale, + * or NULL if an error occurred. + * @stable ICU 55 + */ +U_CAPI UListFormatter* U_EXPORT2 +ulistfmt_open(const char* locale, + UErrorCode* status); + +/** + * Close a UListFormatter object. Once closed it may no longer be used. + * @param listfmt + * The UListFormatter object to close. + * @stable ICU 55 + */ +U_CAPI void U_EXPORT2 +ulistfmt_close(UListFormatter *listfmt); + + +#if U_SHOW_CPLUSPLUS_API + +U_NAMESPACE_BEGIN + +/** + * \class LocalUListFormatterPointer + * "Smart pointer" class, closes a UListFormatter via ulistfmt_close(). + * For most methods see the LocalPointerBase base class. + * + * @see LocalPointerBase + * @see LocalPointer + * @stable ICU 55 + */ +U_DEFINE_LOCAL_OPEN_POINTER(LocalUListFormatterPointer, UListFormatter, ulistfmt_close); + +U_NAMESPACE_END + +#endif + +/** + * Formats a list of strings using the conventions established for the + * UListFormatter object. + * @param listfmt + * The UListFormatter object specifying the list conventions. + * @param strings + * An array of pointers to UChar strings; the array length is + * specified by stringCount. Must be non-NULL if stringCount > 0. + * @param stringLengths + * An array of string lengths corresponding to the strings[] + * parameter; any individual length value may be negative to indicate + * that the corresponding strings[] entry is 0-terminated, or + * stringLengths itself may be NULL if all of the strings are + * 0-terminated. If non-NULL, the stringLengths array must have + * stringCount entries. + * @param stringCount + * the number of entries in strings[], and the number of entries + * in the stringLengths array if it is not NULL. Must be >= 0. + * @param result + * A pointer to a buffer to receive the formatted list. + * @param resultCapacity + * The maximum size of result. + * @param status + * A pointer to a standard ICU UErrorCode (input/output parameter). + * Its input value must pass the U_SUCCESS() test, or else the + * function returns immediately. The caller should check its output + * value with U_FAILURE(), or use with function chaining (see User + * Guide for details). + * @return + * The total buffer size needed; if greater than resultLength, the + * output was truncated. May be <=0 if unable to determine the + * total buffer size needed (e.g. for illegal arguments). + * @stable ICU 55 + */ +U_CAPI int32_t U_EXPORT2 +ulistfmt_format(const UListFormatter* listfmt, + const UChar* const strings[], + const int32_t * stringLengths, + int32_t stringCount, + UChar* result, + int32_t resultCapacity, + UErrorCode* status); + +#endif /* #if !UCONFIG_NO_FORMATTING */ + +#endif diff --git a/deps/icu-small/source/i18n/unicode/unumberformatter.h b/deps/icu-small/source/i18n/unicode/unumberformatter.h index b37f80c503..d05b15cdec 100644 --- a/deps/icu-small/source/i18n/unicode/unumberformatter.h +++ b/deps/icu-small/source/i18n/unicode/unumberformatter.h @@ -91,7 +91,7 @@ * </ul> * * <p> - * This enum is similar to {@link com.ibm.icu.text.MeasureFormat.FormatWidth}. + * This enum is similar to {@link UMeasureFormatWidth}. * * @draft ICU 60 */ @@ -190,10 +190,9 @@ typedef enum UNumberUnitWidth { * Note: This enum specifies the strategy for grouping sizes. To set which character to use as the * grouping separator, use the "symbols" setter. * - * @draft ICU 61 -- TODO: This should be renamed to UNumberGroupingStrategy before promoting to stable, - * for consistency with the other enums. + * @draft ICU 63 */ -typedef enum UGroupingStrategy { +typedef enum UNumberGroupingStrategy { /** * Do not display grouping separators in any locale. * @@ -254,16 +253,28 @@ typedef enum UGroupingStrategy { * * @draft ICU 61 */ - UNUM_GROUPING_THOUSANDS, + UNUM_GROUPING_THOUSANDS +#ifndef U_HIDE_INTERNAL_API + , /** - * One more than the highest UGroupingStrategy value. + * One more than the highest UNumberGroupingStrategy value. * * @internal ICU 62: The numeric value may change over time; see ICU ticket #12420. */ UNUM_GROUPING_COUNT +#endif /* U_HIDE_INTERNAL_API */ + +} UNumberGroupingStrategy; + +#ifndef U_HIDE_DEPRECATED_API +/** + * Old name for compatibility: will be removed in ICU 64. + * @deprecated ICU 63 + */ +typedef UNumberGroupingStrategy UGroupingStrategy; +#endif /* U_HIDE_DEPRECATED_API */ -} UGroupingStrategy; #endif /* U_HIDE_DRAFT_API */ #ifndef U_HIDE_DRAFT_API @@ -398,6 +409,8 @@ typedef enum UNumberDecimalSeparatorDisplay { #endif /* U_HIDE_DRAFT_API */ #ifndef U_HIDE_DRAFT_API + +struct UNumberFormatter; /** * C-compatible version of icu::number::LocalizedNumberFormatter. * @@ -405,10 +418,9 @@ typedef enum UNumberDecimalSeparatorDisplay { * * @draft ICU 62 */ -struct UNumberFormatter; typedef struct UNumberFormatter UNumberFormatter; - +struct UFormattedNumber; /** * C-compatible version of icu::number::FormattedNumber. * @@ -416,7 +428,6 @@ typedef struct UNumberFormatter UNumberFormatter; * * @draft ICU 62 */ -struct UFormattedNumber; typedef struct UFormattedNumber UFormattedNumber; @@ -559,7 +570,8 @@ unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t buf * * NOTE: All fields of the UFieldPosition must be initialized before calling this method. * - * @param fieldPosition + * @param uresult The object containing the formatted number. + * @param ufpos * Input+output variable. On input, the "field" property determines which field to look up, * and the "endIndex" property determines where to begin the search. On output, the * "beginIndex" field is set to the beginning of the first occurrence of the field after the @@ -580,7 +592,7 @@ unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* u * If you need information on only one field, use unumf_resultNextFieldPosition(). * * @param uresult The object containing the formatted number. - * @param fpositer + * @param ufpositer * A pointer to a UFieldPositionIterator created by {@link #ufieldpositer_open}. Iteration * information already present in the UFieldPositionIterator is deleted, and the iterator is reset * to apply to the fields in the formatted string created by this function call. The field values diff --git a/deps/icu-small/source/i18n/unicode/usearch.h b/deps/icu-small/source/i18n/unicode/usearch.h index 600f9142b4..6b495ef001 100644 --- a/deps/icu-small/source/i18n/unicode/usearch.h +++ b/deps/icu-small/source/i18n/unicode/usearch.h @@ -257,10 +257,9 @@ typedef enum { * match an e with the same diacritic or a plain e in the searched text. * * This option is similar to "asymmetric search" as described in - * <a href="http://www.unicode.org/reports/tr10/#Asymmetric_Search"> - * UTS #10 Unicode Collation Algorithm</a, but also allows unmarked - * characters in the searched text to match marked or unmarked versions of - * that character in the pattern. + * [UTS #10 Unicode Collation Algorithm](http://www.unicode.org/reports/tr10/#Asymmetric_Search), + * but also allows unmarked characters in the searched text to match + * marked or unmarked versions of that character in the pattern. * * @stable ICU 4.4 */ diff --git a/deps/icu-small/source/i18n/unicode/uspoof.h b/deps/icu-small/source/i18n/unicode/uspoof.h index 781a88247f..d15ba4b242 100644 --- a/deps/icu-small/source/i18n/unicode/uspoof.h +++ b/deps/icu-small/source/i18n/unicode/uspoof.h @@ -94,7 +94,6 @@ * // ... * \endcode * - * <p> * UTS 39 defines two strings to be <em>confusable</em> if they map to the same <em>skeleton string</em>. A skeleton can * be thought of as a "hash code". {@link uspoof_getSkeleton} computes the skeleton for a particular string, so * the following snippet is equivalent to the example above: @@ -128,7 +127,6 @@ * free(skel2); * \endcode * - * <p> * If you need to check if a string is confusable with any string in a dictionary of many strings, rather than calling * {@link uspoof_areConfusable} many times in a loop, {@link uspoof_getSkeleton} can be used instead, as shown below: * @@ -172,14 +170,12 @@ * uspoof_close(sc); * \endcode * - * <p> * <b>Note:</b> Since the Unicode confusables mapping table is frequently updated, confusable skeletons are <em>not</em> * guaranteed to be the same between ICU releases. We therefore recommend that you always compute confusable skeletons * at runtime and do not rely on creating a permanent, or difficult to update, database of skeletons. * * <h2>Spoof Detection</h2> * - * <p> * The following snippet shows a minimal example of using <code>USpoofChecker</code> to perform spoof detection on a * string: * @@ -204,16 +200,13 @@ * uset_close(allowed); * \endcode * - * <p> * As in the case for confusability checking, it is good practice to create one <code>USpoofChecker</code> instance at * startup, and call the cheaper {@link uspoof_check} online. We specify the set of * allowed characters to be those with type RECOMMENDED or INCLUSION, according to the recommendation in UTS 39. * - * <p> * In addition to {@link uspoof_check}, the function {@link uspoof_checkUTF8} is exposed for UTF8-encoded char* strings, * and {@link uspoof_checkUnicodeString} is exposed for C++ programmers. * - * <p> * If the {@link USPOOF_AUX_INFO} check is enabled, a limited amount of information on why a string failed the checks * is available in the returned bitmask. For complete information, use the {@link uspoof_check2} class of functions * with a {@link USpoofCheckResult} parameter: @@ -274,7 +267,6 @@ * // Explicit cleanup not necessary. * \endcode * - * <p> * The return value is a bitmask of the checks that failed. In this case, there was one check that failed: * {@link USPOOF_RESTRICTION_LEVEL}, corresponding to the fifth bit (16). The possible checks are: * @@ -307,7 +299,6 @@ * uspoof_close(sc); * \endcode * - * <p> * Here is an example in C++ showing how to compute the restriction level of a string: * * \code{.cpp} @@ -334,11 +325,9 @@ * printf("Restriction level: %#010x (status: %s)\n", restrictionLevel, u_errorName(status)); * \endcode * - * <p> * The code '0x50000000' corresponds to the restriction level USPOOF_MINIMALLY_RESTRICTIVE. Since * USPOOF_MINIMALLY_RESTRICTIVE is weaker than USPOOF_MODERATELY_RESTRICTIVE, the string fails the check. * - * <p> * <b>Note:</b> The Restriction Level is the most powerful of the checks. The full logic is documented in * <a href="http://unicode.org/reports/tr39/#Restriction_Level_Detection">UTS 39</a>, but the basic idea is that strings * are restricted to contain characters from only a single script, <em>except</em> that most scripts are allowed to have @@ -352,15 +341,12 @@ * * <h2>Additional Information</h2> * - * <p> * A <code>USpoofChecker</code> instance may be used repeatedly to perform checks on any number of identifiers. * - * <p> * <b>Thread Safety:</b> The test functions for checking a single identifier, or for testing whether * two identifiers are possible confusable, are thread safe. They may called concurrently, from multiple threads, * using the same USpoofChecker instance. * - * <p> * More generally, the standard ICU thread safety rules apply: functions that take a const USpoofChecker parameter are * thread safe. Those that take a non-const USpoofChecker are not thread safe.. * @@ -1219,14 +1205,21 @@ U_NAMESPACE_BEGIN /** * \class LocalUSpoofCheckResultPointer - * "Smart pointer" class, closes a USpoofCheckResult via {@link uspoof_closeCheckResult}. + * "Smart pointer" class, closes a USpoofCheckResult via `uspoof_closeCheckResult()`. * For most methods see the LocalPointerBase base class. * * @see LocalPointerBase * @see LocalPointer * @stable ICU 58 */ + +/** + * \cond + * Note: Doxygen is giving a bogus warning on this U_DEFINE_LOCAL_OPEN_POINTER. + * For now, suppress with a Doxygen cond + */ U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckResultPointer, USpoofCheckResult, uspoof_closeCheckResult); +/** \endcond */ U_NAMESPACE_END |