Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 09:25:39

0001 // © 2016 and later: Unicode, Inc. and others.
0002 // License & terms of use: http://www.unicode.org/copyright.html
0003 /*
0004 ********************************************************************************
0005 * Copyright (C) 1997-2016, International Business Machines Corporation and others.
0006 * All Rights Reserved.
0007 ********************************************************************************
0008 *
0009 * File NUMFMT.H
0010 *
0011 * Modification History:
0012 *
0013 *   Date        Name        Description
0014 *   02/19/97    aliu        Converted from java.
0015 *   03/18/97    clhuang     Updated per C++ implementation.
0016 *   04/17/97    aliu        Changed DigitCount to int per code review.
0017 *    07/20/98    stephen        JDK 1.2 sync up. Added scientific support.
0018 *                            Changed naming conventions to match C++ guidelines
0019 *                            Deprecated Java style constants (eg, INTEGER_FIELD)
0020 ********************************************************************************
0021 */
0022 
0023 #ifndef NUMFMT_H
0024 #define NUMFMT_H
0025 
0026 
0027 #include "unicode/utypes.h"
0028 
0029 #if U_SHOW_CPLUSPLUS_API
0030 
0031 /**
0032  * \file
0033  * \brief C++ API: Compatibility APIs for number formatting.
0034  */
0035 
0036 #if !UCONFIG_NO_FORMATTING
0037 
0038 #include "unicode/unistr.h"
0039 #include "unicode/format.h"
0040 #include "unicode/unum.h" // UNumberFormatStyle
0041 #include "unicode/locid.h"
0042 #include "unicode/stringpiece.h"
0043 #include "unicode/curramt.h"
0044 #include "unicode/udisplaycontext.h"
0045 
0046 class NumberFormatTest;
0047 
0048 U_NAMESPACE_BEGIN
0049 
0050 class SharedNumberFormat;
0051 
0052 #if !UCONFIG_NO_SERVICE
0053 class NumberFormatFactory;
0054 class StringEnumeration;
0055 #endif
0056 
0057 /**
0058  * <p><strong>IMPORTANT:</strong> New users are strongly encouraged to see if
0059  * numberformatter.h fits their use case.  Although not deprecated, this header
0060  * is provided for backwards compatibility only.
0061  *
0062  * Abstract base class for all number formats.  Provides interface for
0063  * formatting and parsing a number.  Also provides methods for
0064  * determining which locales have number formats, and what their names
0065  * are.
0066  *
0067  * \headerfile unicode/numfmt.h "unicode/numfmt.h"
0068  * <P>
0069  * NumberFormat helps you to format and parse numbers for any locale.
0070  * Your code can be completely independent of the locale conventions
0071  * for decimal points, thousands-separators, or even the particular
0072  * decimal digits used, or whether the number format is even decimal.
0073  * <P>
0074  * To format a number for the current Locale, use one of the static
0075  * factory methods:
0076  * \code
0077  *    #include <iostream>
0078  *    #include "unicode/numfmt.h"
0079  *    #include "unicode/unistr.h"
0080  *    #include "unicode/ustream.h"
0081  *    using namespace std;
0082  *    
0083  *    int main() {
0084  *        double myNumber = 7.0;
0085  *        UnicodeString myString;
0086  *        UErrorCode success = U_ZERO_ERROR;
0087  *        NumberFormat* nf = NumberFormat::createInstance(success);
0088  *        nf->format(myNumber, myString);
0089  *        cout << " Example 1: " << myString << endl;
0090  *    }
0091  * \endcode
0092  * Note that there are additional factory methods within subclasses of
0093  * NumberFormat.
0094  * <P>
0095  * If you are formatting multiple numbers, it is more efficient to get
0096  * the format and use it multiple times so that the system doesn't
0097  * have to fetch the information about the local language and country
0098  * conventions multiple times.
0099  * \code
0100  *     UnicodeString myString;
0101  *     UErrorCode success = U_ZERO_ERROR;
0102  *     NumberFormat *nf = NumberFormat::createInstance( success );
0103  *     for (int32_t number: {123, 3333, -1234567}) {
0104  *         nf->format(number, myString);
0105  *         myString += "; ";
0106  *     }
0107  *     cout << " Example 2: " << myString << endl;
0108  * \endcode
0109  * To format a number for a different Locale, specify it in the
0110  * call to \c createInstance().
0111  * \code
0112  *     nf = NumberFormat::createInstance(Locale::getFrench(), success);
0113  * \endcode
0114  * You can use a \c NumberFormat to parse also.
0115  * \code
0116  *    UErrorCode success;
0117  *    Formattable result(-999);  // initialized with error code
0118  *    nf->parse(myString, result, success);
0119  * \endcode
0120  * Use \c createInstance() to get the normal number format for a \c Locale.
0121  * There are other static factory methods available.  Use \c createCurrencyInstance()
0122  * to get the currency number format for that country.  Use \c createPercentInstance()
0123  * to get a format for displaying percentages. With this format, a
0124  * fraction from 0.53 is displayed as 53%.
0125  * <P>
0126  * The type of number formatting can be specified by passing a 'style' parameter to \c createInstance().
0127  * For example, use\n
0128  * \c createInstance(locale, UNUM_DECIMAL, errorCode) to get the normal number format,\n
0129  * \c createInstance(locale, UNUM_PERCENT, errorCode) to get a format for displaying percentage,\n
0130  * \c createInstance(locale, UNUM_SCIENTIFIC, errorCode) to get a format for displaying scientific number,\n
0131  * \c createInstance(locale, UNUM_CURRENCY, errorCode) to get the currency number format,
0132  * in which the currency is represented by its symbol, for example, "$3.00".\n
0133  * \c createInstance(locale, UNUM_CURRENCY_ISO, errorCode)  to get the currency number format,
0134  * in which the currency is represented by its ISO code, for example "USD3.00".\n
0135  * \c createInstance(locale, UNUM_CURRENCY_PLURAL, errorCode) to get the currency number format,
0136  * in which the currency is represented by its full name in plural format,
0137  * for example, "3.00 US dollars" or "1.00 US dollar".
0138  * <P>
0139  * You can also control the display of numbers with such methods as
0140  * \c getMinimumFractionDigits().  If you want even more control over the
0141  * format or parsing, or want to give your users more control, you can
0142  * try dynamic_casting the \c NumberFormat you get from the factory methods to a
0143  * \c DecimalFormat. This will work for the vast majority of
0144  * countries; just remember to test for nullptr in case you
0145  * encounter an unusual one.
0146  * <P>
0147  * You can also use forms of the parse and format methods with
0148  * \c ParsePosition and \c FieldPosition to allow you to:
0149  * <ul type=round>
0150  *   <li>(a) progressively parse through pieces of a string.
0151  *   <li>(b) align the decimal point and other areas.
0152  * </ul>
0153  * For example, you can align numbers in two ways.
0154  * <P>
0155  * If you are using a monospaced font with spacing for alignment, you
0156  * can pass the \c FieldPosition in your format call, with field =
0157  * \c UNUM_INTEGER_FIELD. On output, \c getEndIndex will be set to the offset
0158  * between the last character of the integer and the decimal. Add
0159  * (desiredSpaceCount - getEndIndex) spaces at the front of the
0160  * string.
0161  * <P>
0162  * If you are using proportional fonts, instead of padding with
0163  * spaces, measure the width of the string in pixels from the start to
0164  * getEndIndex.  Then move the pen by (desiredPixelWidth -
0165  * widthToAlignmentPoint) before drawing the text.  It also works
0166  * where there is no decimal, but possibly additional characters at
0167  * the end, e.g. with parentheses in negative numbers: "(12)" for -12.
0168  * <p>
0169  * <em>User subclasses are not supported.</em> While clients may write
0170  * subclasses, such code will not necessarily work and will not be
0171  * guaranteed to work stably from release to release.
0172  *
0173  * @stable ICU 2.0
0174  */
0175 class U_I18N_API NumberFormat : public Format {
0176 public:
0177     /**
0178      * Rounding mode.
0179      *
0180      * <p>
0181      * For more detail on rounding modes, see:
0182      * https://unicode-org.github.io/icu/userguide/format_parse/numbers/rounding-modes
0183      *
0184      * @stable ICU 2.4
0185      */
0186     enum ERoundingMode {
0187         kRoundCeiling,  /**< Round towards positive infinity */
0188         kRoundFloor,    /**< Round towards negative infinity */
0189         kRoundDown,     /**< Round towards zero */
0190         kRoundUp,       /**< Round away from zero */
0191         kRoundHalfEven, /**< Round towards the nearest integer, or
0192                              towards the nearest even integer if equidistant */
0193         kRoundHalfDown, /**< Round towards the nearest integer, or
0194                              towards zero if equidistant */
0195         kRoundHalfUp,   /**< Round towards the nearest integer, or
0196                              away from zero if equidistant */
0197         /**
0198           *  Return U_FORMAT_INEXACT_ERROR if number does not format exactly.
0199           *  @stable ICU 4.8
0200           */
0201         kRoundUnnecessary,
0202         /**
0203          * Rounds ties toward the odd number.
0204          * @stable ICU 73
0205          */
0206         kRoundHalfOdd,
0207         /**
0208          * Rounds ties toward +∞.
0209          * @stable ICU 73
0210          */
0211         kRoundHalfCeiling,
0212         /**
0213          * Rounds ties toward -∞.
0214          * @stable ICU 73
0215          */
0216         kRoundHalfFloor,
0217     };
0218 
0219     /**
0220      * Alignment Field constants used to construct a FieldPosition object.
0221      * Signifies that the position of the integer part or fraction part of
0222      * a formatted number should be returned.
0223      *
0224      * Note: as of ICU 4.4, the values in this enum have been extended to
0225      * support identification of all number format fields, not just those
0226      * pertaining to alignment.
0227      *
0228      * These constants are provided for backwards compatibility only.
0229      * Please use the C style constants defined in the header file unum.h.
0230      *
0231      * @see FieldPosition
0232      * @stable ICU 2.0
0233      */
0234     enum EAlignmentFields {
0235         /** @stable ICU 2.0 */
0236         kIntegerField = UNUM_INTEGER_FIELD,
0237         /** @stable ICU 2.0 */
0238         kFractionField = UNUM_FRACTION_FIELD,
0239         /** @stable ICU 2.0 */
0240         kDecimalSeparatorField = UNUM_DECIMAL_SEPARATOR_FIELD,
0241         /** @stable ICU 2.0 */
0242         kExponentSymbolField = UNUM_EXPONENT_SYMBOL_FIELD,
0243         /** @stable ICU 2.0 */
0244         kExponentSignField = UNUM_EXPONENT_SIGN_FIELD,
0245         /** @stable ICU 2.0 */
0246         kExponentField = UNUM_EXPONENT_FIELD,
0247         /** @stable ICU 2.0 */
0248         kGroupingSeparatorField = UNUM_GROUPING_SEPARATOR_FIELD,
0249         /** @stable ICU 2.0 */
0250         kCurrencyField = UNUM_CURRENCY_FIELD,
0251         /** @stable ICU 2.0 */
0252         kPercentField = UNUM_PERCENT_FIELD,
0253         /** @stable ICU 2.0 */
0254         kPermillField = UNUM_PERMILL_FIELD,
0255         /** @stable ICU 2.0 */
0256         kSignField = UNUM_SIGN_FIELD,
0257         /** @stable ICU 64 */
0258         kMeasureUnitField = UNUM_MEASURE_UNIT_FIELD,
0259         /** @stable ICU 64 */
0260         kCompactField = UNUM_COMPACT_FIELD,
0261 
0262     /**
0263      * These constants are provided for backwards compatibility only.
0264      * Please use the constants defined in the header file unum.h.
0265      */
0266         /** @stable ICU 2.0 */
0267         INTEGER_FIELD        = UNUM_INTEGER_FIELD,
0268         /** @stable ICU 2.0 */
0269         FRACTION_FIELD       = UNUM_FRACTION_FIELD
0270     };
0271 
0272     /**
0273      * Destructor.
0274      * @stable ICU 2.0
0275      */
0276     virtual ~NumberFormat();
0277 
0278     /**
0279      * Clones this object polymorphically.
0280      * The caller owns the result and should delete it when done.
0281      * @return clone, or nullptr if an error occurred
0282      * @stable ICU 2.0
0283      */
0284     virtual NumberFormat* clone() const override = 0;
0285 
0286     /**
0287      * Return true if the given Format objects are semantically equal.
0288      * Objects of different subclasses are considered unequal.
0289      * @return    true if the given Format objects are semantically equal.
0290      * @stable ICU 2.0
0291      */
0292     virtual bool operator==(const Format& other) const override;
0293 
0294 
0295     using Format::format;
0296 
0297     /**
0298      * Format an object to produce a string.  This method handles
0299      * Formattable objects with numeric types. If the Formattable
0300      * object type is not a numeric type, then it returns a failing
0301      * UErrorCode.
0302      *
0303      * @param obj       The object to format.
0304      * @param appendTo  Output parameter to receive result.
0305      *                  Result is appended to existing contents.
0306      * @param pos       On input: an alignment field, if desired.
0307      *                  On output: the offsets of the alignment field.
0308      * @param status    Output param filled with success/failure status.
0309      * @return          Reference to 'appendTo' parameter.
0310      * @stable ICU 2.0
0311      */
0312     virtual UnicodeString& format(const Formattable& obj,
0313                                   UnicodeString& appendTo,
0314                                   FieldPosition& pos,
0315                                   UErrorCode& status) const override;
0316 
0317     /**
0318      * Format an object to produce a string.  This method handles
0319      * Formattable objects with numeric types. If the Formattable
0320      * object type is not a numeric type, then it returns a failing
0321      * UErrorCode.
0322      *
0323      * @param obj       The object to format.
0324      * @param appendTo  Output parameter to receive result.
0325      *                  Result is appended to existing contents.
0326      * @param posIter   On return, can be used to iterate over positions
0327      *                  of fields generated by this format call.  Can be
0328      *                  nullptr.
0329      * @param status    Output param filled with success/failure status.
0330      * @return          Reference to 'appendTo' parameter.
0331      * @stable ICU 4.4
0332      */
0333     virtual UnicodeString& format(const Formattable& obj,
0334                                   UnicodeString& appendTo,
0335                                   FieldPositionIterator* posIter,
0336                                   UErrorCode& status) const override;
0337 
0338     /**
0339      * Parse a string to produce an object.  This methods handles
0340      * parsing of numeric strings into Formattable objects with numeric
0341      * types.
0342      * <P>
0343      * Before calling, set parse_pos.index to the offset you want to
0344      * start parsing at in the source. After calling, parse_pos.index
0345      * indicates the position after the successfully parsed text.  If
0346      * an error occurs, parse_pos.index is unchanged.
0347      * <P>
0348      * When parsing, leading whitespace is discarded (with successful
0349      * parse), while trailing whitespace is left as is.
0350      * <P>
0351      * See Format::parseObject() for more.
0352      *
0353      * @param source    The string to be parsed into an object.
0354      * @param result    Formattable to be set to the parse result.
0355      *                  If parse fails, return contents are undefined.
0356      * @param parse_pos The position to start parsing at. Upon return
0357      *                  this param is set to the position after the
0358      *                  last character successfully parsed. If the
0359      *                  source is not parsed successfully, this param
0360      *                  will remain unchanged.
0361      * @return          A newly created Formattable* object, or nullptr
0362      *                  on failure.  The caller owns this and should
0363      *                  delete it when done.
0364      * @stable ICU 2.0
0365      */
0366     virtual void parseObject(const UnicodeString& source,
0367                              Formattable& result,
0368                              ParsePosition& parse_pos) const override;
0369 
0370     /**
0371      * Format a double number. These methods call the NumberFormat
0372      * pure virtual format() methods with the default FieldPosition.
0373      *
0374      * @param number    The value to be formatted.
0375      * @param appendTo  Output parameter to receive result.
0376      *                  Result is appended to existing contents.
0377      * @return          Reference to 'appendTo' parameter.
0378      * @stable ICU 2.0
0379      */
0380     UnicodeString& format(  double number,
0381                             UnicodeString& appendTo) const;
0382 
0383     /**
0384      * Format a long number. These methods call the NumberFormat
0385      * pure virtual format() methods with the default FieldPosition.
0386      *
0387      * @param number    The value to be formatted.
0388      * @param appendTo  Output parameter to receive result.
0389      *                  Result is appended to existing contents.
0390      * @return          Reference to 'appendTo' parameter.
0391      * @stable ICU 2.0
0392      */
0393     UnicodeString& format(  int32_t number,
0394                             UnicodeString& appendTo) const;
0395 
0396     /**
0397      * Format an int64 number. These methods call the NumberFormat
0398      * pure virtual format() methods with the default FieldPosition.
0399      *
0400      * @param number    The value to be formatted.
0401      * @param appendTo  Output parameter to receive result.
0402      *                  Result is appended to existing contents.
0403      * @return          Reference to 'appendTo' parameter.
0404      * @stable ICU 2.8
0405      */
0406     UnicodeString& format(  int64_t number,
0407                             UnicodeString& appendTo) const;
0408 
0409     /**
0410      * Format a double number. Concrete subclasses must implement
0411      * these pure virtual methods.
0412      *
0413      * @param number    The value to be formatted.
0414      * @param appendTo  Output parameter to receive result.
0415      *                  Result is appended to existing contents.
0416      * @param pos       On input: an alignment field, if desired.
0417      *                  On output: the offsets of the alignment field.
0418      * @return          Reference to 'appendTo' parameter.
0419      * @stable ICU 2.0
0420      */
0421     virtual UnicodeString& format(double number,
0422                                   UnicodeString& appendTo,
0423                                   FieldPosition& pos) const = 0;
0424     /**
0425      * Format a double number. By default, the parent function simply
0426      * calls the base class and does not return an error status.
0427      * Therefore, the status may be ignored in some subclasses.
0428      *
0429      * @param number    The value to be formatted.
0430      * @param appendTo  Output parameter to receive result.
0431      *                  Result is appended to existing contents.
0432      * @param pos       On input: an alignment field, if desired.
0433      *                  On output: the offsets of the alignment field.
0434      * @param status    error status
0435      * @return          Reference to 'appendTo' parameter.
0436      * @internal
0437      */
0438     virtual UnicodeString& format(double number,
0439                                   UnicodeString& appendTo,
0440                                   FieldPosition& pos,
0441                                   UErrorCode &status) const;
0442     /**
0443      * Format a double number. Subclasses must implement
0444      * this method.
0445      *
0446      * @param number    The value to be formatted.
0447      * @param appendTo  Output parameter to receive result.
0448      *                  Result is appended to existing contents.
0449      * @param posIter   On return, can be used to iterate over positions
0450      *                  of fields generated by this format call.
0451      *                  Can be nullptr.
0452      * @param status    Output param filled with success/failure status.
0453      * @return          Reference to 'appendTo' parameter.
0454      * @stable ICU 4.4
0455      */
0456     virtual UnicodeString& format(double number,
0457                                   UnicodeString& appendTo,
0458                                   FieldPositionIterator* posIter,
0459                                   UErrorCode& status) const;
0460     /**
0461      * Format a long number. Concrete subclasses must implement
0462      * these pure virtual methods.
0463      *
0464      * @param number    The value to be formatted.
0465      * @param appendTo  Output parameter to receive result.
0466      *                  Result is appended to existing contents.
0467      * @param pos       On input: an alignment field, if desired.
0468      *                  On output: the offsets of the alignment field.
0469      * @return          Reference to 'appendTo' parameter.
0470      * @stable ICU 2.0
0471     */
0472     virtual UnicodeString& format(int32_t number,
0473                                   UnicodeString& appendTo,
0474                                   FieldPosition& pos) const = 0;
0475 
0476     /**
0477      * Format a long number. Concrete subclasses may override
0478      * this function to provide status return.
0479      *
0480      * @param number    The value to be formatted.
0481      * @param appendTo  Output parameter to receive result.
0482      *                  Result is appended to existing contents.
0483      * @param pos       On input: an alignment field, if desired.
0484      *                  On output: the offsets of the alignment field.
0485      * @param status the output status.
0486      * @return          Reference to 'appendTo' parameter.
0487      * @internal
0488     */
0489     virtual UnicodeString& format(int32_t number,
0490                                   UnicodeString& appendTo,
0491                                   FieldPosition& pos,
0492                                   UErrorCode &status) const;
0493 
0494     /**
0495      * Format an int32 number. Subclasses must implement
0496      * this method.
0497      *
0498      * @param number    The value to be formatted.
0499      * @param appendTo  Output parameter to receive result.
0500      *                  Result is appended to existing contents.
0501      * @param posIter   On return, can be used to iterate over positions
0502      *                  of fields generated by this format call.
0503      *                  Can be nullptr.
0504      * @param status    Output param filled with success/failure status.
0505      * @return          Reference to 'appendTo' parameter.
0506      * @stable ICU 4.4
0507      */
0508     virtual UnicodeString& format(int32_t number,
0509                                   UnicodeString& appendTo,
0510                                   FieldPositionIterator* posIter,
0511                                   UErrorCode& status) const;
0512     /**
0513      * Format an int64 number. (Not abstract to retain compatibility
0514      * with earlier releases, however subclasses should override this
0515      * method as it just delegates to format(int32_t number...);
0516      *
0517      * @param number    The value to be formatted.
0518      * @param appendTo  Output parameter to receive result.
0519      *                  Result is appended to existing contents.
0520      * @param pos       On input: an alignment field, if desired.
0521      *                  On output: the offsets of the alignment field.
0522      * @return          Reference to 'appendTo' parameter.
0523      * @stable ICU 2.8
0524     */
0525     virtual UnicodeString& format(int64_t number,
0526                                   UnicodeString& appendTo,
0527                                   FieldPosition& pos) const;
0528 
0529     /**
0530      * Format an int64 number. (Not abstract to retain compatibility
0531      * with earlier releases, however subclasses should override this
0532      * method as it just delegates to format(int32_t number...);
0533      *
0534      * @param number    The value to be formatted.
0535      * @param appendTo  Output parameter to receive result.
0536      *                  Result is appended to existing contents.
0537      * @param pos       On input: an alignment field, if desired.
0538      *                  On output: the offsets of the alignment field.
0539      * @param status    Output param filled with success/failure status.
0540      * @return          Reference to 'appendTo' parameter.
0541      * @internal
0542     */
0543     virtual UnicodeString& format(int64_t number,
0544                                   UnicodeString& appendTo,
0545                                   FieldPosition& pos,
0546                                   UErrorCode& status) const;
0547     /**
0548      * Format an int64 number. Subclasses must implement
0549      * this method.
0550      *
0551      * @param number    The value to be formatted.
0552      * @param appendTo  Output parameter to receive result.
0553      *                  Result is appended to existing contents.
0554      * @param posIter   On return, can be used to iterate over positions
0555      *                  of fields generated by this format call.
0556      *                  Can be nullptr.
0557      * @param status    Output param filled with success/failure status.
0558      * @return          Reference to 'appendTo' parameter.
0559      * @stable ICU 4.4
0560      */
0561     virtual UnicodeString& format(int64_t number,
0562                                   UnicodeString& appendTo,
0563                                   FieldPositionIterator* posIter,
0564                                   UErrorCode& status) const;
0565 
0566     /**
0567      * Format a decimal number. Subclasses must implement
0568      * this method.  The syntax of the unformatted number is a "numeric string"
0569      * as defined in the Decimal Arithmetic Specification, available at
0570      * http://speleotrove.com/decimal
0571      *
0572      * @param number    The unformatted number, as a string, to be formatted.
0573      * @param appendTo  Output parameter to receive result.
0574      *                  Result is appended to existing contents.
0575      * @param posIter   On return, can be used to iterate over positions
0576      *                  of fields generated by this format call.
0577      *                  Can be nullptr.
0578      * @param status    Output param filled with success/failure status.
0579      * @return          Reference to 'appendTo' parameter.
0580      * @stable ICU 4.4
0581      */
0582     virtual UnicodeString& format(StringPiece number,
0583                                   UnicodeString& appendTo,
0584                                   FieldPositionIterator* posIter,
0585                                   UErrorCode& status) const;
0586 
0587 // Can't use #ifndef U_HIDE_INTERNAL_API because these are virtual methods
0588 
0589     /**
0590      * Format a decimal number.
0591      * The number is a DecimalQuantity wrapper onto a floating point decimal number.
0592      * The default implementation in NumberFormat converts the decimal number
0593      * to a double and formats that.  Subclasses of NumberFormat that want
0594      * to specifically handle big decimal numbers must override this method.
0595      * class DecimalFormat does so.
0596      *
0597      * @param number    The number, a DecimalQuantity format Decimal Floating Point.
0598      * @param appendTo  Output parameter to receive result.
0599      *                  Result is appended to existing contents.
0600      * @param posIter   On return, can be used to iterate over positions
0601      *                  of fields generated by this format call.
0602      * @param status    Output param filled with success/failure status.
0603      * @return          Reference to 'appendTo' parameter.
0604      * @internal
0605      */
0606     virtual UnicodeString& format(const number::impl::DecimalQuantity &number,
0607                                   UnicodeString& appendTo,
0608                                   FieldPositionIterator* posIter,
0609                                   UErrorCode& status) const;
0610 
0611     /**
0612      * Format a decimal number.
0613      * The number is a DecimalQuantity wrapper onto a floating point decimal number.
0614      * The default implementation in NumberFormat converts the decimal number
0615      * to a double and formats that.  Subclasses of NumberFormat that want
0616      * to specifically handle big decimal numbers must override this method.
0617      * class DecimalFormat does so.
0618      *
0619      * @param number    The number, a DecimalQuantity format Decimal Floating Point.
0620      * @param appendTo  Output parameter to receive result.
0621      *                  Result is appended to existing contents.
0622      * @param pos       On input: an alignment field, if desired.
0623      *                  On output: the offsets of the alignment field.
0624      * @param status    Output param filled with success/failure status.
0625      * @return          Reference to 'appendTo' parameter.
0626      * @internal
0627      */
0628     virtual UnicodeString& format(const number::impl::DecimalQuantity &number,
0629                                   UnicodeString& appendTo,
0630                                   FieldPosition& pos,
0631                                   UErrorCode& status) const;
0632 
0633    /**
0634     * Return a long if possible (e.g. within range LONG_MAX,
0635     * LONG_MAX], and with no decimals), otherwise a double.  If
0636     * IntegerOnly is set, will stop at a decimal point (or equivalent;
0637     * e.g. for rational numbers "1 2/3", will stop after the 1).
0638     * <P>
0639     * If no object can be parsed, index is unchanged, and nullptr is
0640     * returned.
0641     * <P>
0642     * This is a pure virtual which concrete subclasses must implement.
0643     *
0644     * @param text           The text to be parsed.
0645     * @param result         Formattable to be set to the parse result.
0646     *                       If parse fails, return contents are undefined.
0647     * @param parsePosition  The position to start parsing at on input.
0648     *                       On output, moved to after the last successfully
0649     *                       parse character. On parse failure, does not change.
0650     * @stable ICU 2.0
0651     */
0652     virtual void parse(const UnicodeString& text,
0653                        Formattable& result,
0654                        ParsePosition& parsePosition) const = 0;
0655 
0656     /**
0657      * Parse a string as a numeric value, and return a Formattable
0658      * numeric object. This method parses integers only if IntegerOnly
0659      * is set.
0660      *
0661      * @param text          The text to be parsed.
0662      * @param result        Formattable to be set to the parse result.
0663      *                      If parse fails, return contents are undefined.
0664      * @param status        Output parameter set to a failure error code
0665      *                      when a failure occurs. The error code when the
0666      *                      string fails to parse is U_INVALID_FORMAT_ERROR,
0667      *                      unless overridden by a subclass.
0668      * @see                 NumberFormat::isParseIntegerOnly
0669      * @stable ICU 2.0
0670      */
0671     virtual void parse(const UnicodeString& text,
0672                        Formattable& result,
0673                        UErrorCode& status) const;
0674 
0675     /**
0676      * Parses text from the given string as a currency amount.  Unlike
0677      * the parse() method, this method will attempt to parse a generic
0678      * currency name, searching for a match of this object's locale's
0679      * currency display names, or for a 3-letter ISO currency code.
0680      * This method will fail if this format is not a currency format,
0681      * that is, if it does not contain the currency pattern symbol
0682      * (U+00A4) in its prefix or suffix.
0683      *
0684      * @param text the string to parse
0685      * @param pos  input-output position; on input, the position within text
0686      *             to match; must have 0 <= pos.getIndex() < text.length();
0687      *             on output, the position after the last matched character.
0688      *             If the parse fails, the position in unchanged upon output.
0689      * @return     if parse succeeds, a pointer to a newly-created CurrencyAmount
0690      *             object (owned by the caller) containing information about
0691      *             the parsed currency; if parse fails, this is nullptr.
0692      * @stable ICU 49
0693      */
0694     virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
0695                                           ParsePosition& pos) const;
0696 
0697     /**
0698      * Return true if this format will parse numbers as integers
0699      * only.  For example in the English locale, with ParseIntegerOnly
0700      * true, the string "1234." would be parsed as the integer value
0701      * 1234 and parsing would stop at the "." character.  Of course,
0702      * the exact format accepted by the parse operation is locale
0703      * dependent and determined by sub-classes of NumberFormat.
0704      * @return    true if this format will parse numbers as integers
0705      *            only.
0706      * @stable ICU 2.0
0707      */
0708     UBool isParseIntegerOnly() const;
0709 
0710     /**
0711      * Sets whether or not numbers should be parsed as integers only.
0712      * @param value    set True, this format will parse numbers as integers
0713      *                 only.
0714      * @see isParseIntegerOnly
0715      * @stable ICU 2.0
0716      */
0717     virtual void setParseIntegerOnly(UBool value);
0718 
0719     /**
0720      * Sets whether lenient parsing should be enabled (it is off by default).
0721      *
0722      * @param enable \c true if lenient parsing should be used,
0723      *               \c false otherwise.
0724      * @stable ICU 4.8
0725      */
0726     virtual void setLenient(UBool enable);
0727 
0728     /**
0729      * Returns whether lenient parsing is enabled (it is off by default).
0730      *
0731      * @return \c true if lenient parsing is enabled,
0732      *         \c false otherwise.
0733      * @see #setLenient
0734      * @stable ICU 4.8
0735      */
0736     virtual UBool isLenient() const;
0737 
0738     /**
0739      * Create a default style NumberFormat for the current default locale.
0740      * The default formatting style is locale dependent.
0741      * <p>
0742      * <strong>NOTE:</strong> New users are strongly encouraged to use
0743      * {@link icu::number::NumberFormatter} instead of NumberFormat.
0744      * @stable ICU 2.0
0745      */
0746     static NumberFormat* U_EXPORT2 createInstance(UErrorCode&);
0747 
0748     /**
0749      * Create a default style NumberFormat for the specified locale.
0750      * The default formatting style is locale dependent.
0751      * @param inLocale    the given locale.
0752      * <p>
0753      * <strong>NOTE:</strong> New users are strongly encouraged to use
0754      * {@link icu::number::NumberFormatter} instead of NumberFormat.
0755      * @stable ICU 2.0
0756      */
0757     static NumberFormat* U_EXPORT2 createInstance(const Locale& inLocale,
0758                                         UErrorCode&);
0759 
0760     /**
0761      * Create a specific style NumberFormat for the specified locale.
0762      * <p>
0763      * <strong>NOTE:</strong> New users are strongly encouraged to use
0764      * {@link icu::number::NumberFormatter} instead of NumberFormat.
0765      * @param desiredLocale    the given locale.
0766      * @param style            the given style.
0767      * @param errorCode        Output param filled with success/failure status.
0768      * @return                 A new NumberFormat instance.
0769      * @stable ICU 4.8
0770      */
0771     static NumberFormat* U_EXPORT2 createInstance(const Locale& desiredLocale,
0772                                                   UNumberFormatStyle style,
0773                                                   UErrorCode& errorCode);
0774 
0775 #ifndef U_HIDE_INTERNAL_API
0776 
0777     /**
0778      * ICU use only.
0779      * Creates NumberFormat instance without using the cache.
0780      * @internal
0781      */
0782     static NumberFormat* internalCreateInstance(
0783             const Locale& desiredLocale,
0784             UNumberFormatStyle style,
0785             UErrorCode& errorCode);
0786 
0787     /**
0788      * ICU use only.
0789      * Returns handle to the shared, cached NumberFormat instance for given
0790      * locale. On success, caller must call removeRef() on returned value
0791      * once it is done with the shared instance.
0792      * @internal
0793      */
0794     static const SharedNumberFormat* U_EXPORT2 createSharedInstance(
0795             const Locale& inLocale, UNumberFormatStyle style, UErrorCode& status);
0796 
0797 #endif  /* U_HIDE_INTERNAL_API */
0798 
0799     /**
0800      * Returns a currency format for the current default locale.
0801      * <p>
0802      * <strong>NOTE:</strong> New users are strongly encouraged to use
0803      * {@link icu::number::NumberFormatter} instead of NumberFormat.
0804      * @stable ICU 2.0
0805      */
0806     static NumberFormat* U_EXPORT2 createCurrencyInstance(UErrorCode&);
0807 
0808     /**
0809      * Returns a currency format for the specified locale.
0810      * <p>
0811      * <strong>NOTE:</strong> New users are strongly encouraged to use
0812      * {@link icu::number::NumberFormatter} instead of NumberFormat.
0813      * @param inLocale    the given locale.
0814      * @stable ICU 2.0
0815      */
0816     static NumberFormat* U_EXPORT2 createCurrencyInstance(const Locale& inLocale,
0817                                                 UErrorCode&);
0818 
0819     /**
0820      * Returns a percentage format for the current default locale.
0821      * <p>
0822      * <strong>NOTE:</strong> New users are strongly encouraged to use
0823      * {@link icu::number::NumberFormatter} instead of NumberFormat.
0824      * @stable ICU 2.0
0825      */
0826     static NumberFormat* U_EXPORT2 createPercentInstance(UErrorCode&);
0827 
0828     /**
0829      * Returns a percentage format for the specified locale.
0830      * <p>
0831      * <strong>NOTE:</strong> New users are strongly encouraged to use
0832      * {@link icu::number::NumberFormatter} instead of NumberFormat.
0833      * @param inLocale    the given locale.
0834      * @stable ICU 2.0
0835      */
0836     static NumberFormat* U_EXPORT2 createPercentInstance(const Locale& inLocale,
0837                                                UErrorCode&);
0838 
0839     /**
0840      * Returns a scientific format for the current default locale.
0841      * <p>
0842      * <strong>NOTE:</strong> New users are strongly encouraged to use
0843      * {@link icu::number::NumberFormatter} instead of NumberFormat.
0844      * @stable ICU 2.0
0845      */
0846     static NumberFormat* U_EXPORT2 createScientificInstance(UErrorCode&);
0847 
0848     /**
0849      * Returns a scientific format for the specified locale.
0850      * <p>
0851      * <strong>NOTE:</strong> New users are strongly encouraged to use
0852      * {@link icu::number::NumberFormatter} instead of NumberFormat.
0853      * @param inLocale    the given locale.
0854      * @stable ICU 2.0
0855      */
0856     static NumberFormat* U_EXPORT2 createScientificInstance(const Locale& inLocale,
0857                                                 UErrorCode&);
0858 
0859     /**
0860      * Get the set of Locales for which NumberFormats are installed.
0861      * @param count    Output param to receive the size of the locales
0862      * @stable ICU 2.0
0863      */
0864     static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
0865 
0866 #if !UCONFIG_NO_SERVICE
0867     /**
0868      * Register a new NumberFormatFactory.  The factory will be adopted.
0869      * Because ICU may choose to cache NumberFormat objects internally,
0870      * this must be called at application startup, prior to any calls to
0871      * NumberFormat::createInstance to avoid undefined behavior.
0872      * @param toAdopt the NumberFormatFactory instance to be adopted
0873      * @param status the in/out status code, no special meanings are assigned
0874      * @return a registry key that can be used to unregister this factory
0875      * @stable ICU 2.6
0876      */
0877     static URegistryKey U_EXPORT2 registerFactory(NumberFormatFactory* toAdopt, UErrorCode& status);
0878 
0879     /**
0880      * Unregister a previously-registered NumberFormatFactory using the key returned from the
0881      * register call.  Key becomes invalid after a successful call and should not be used again.
0882      * The NumberFormatFactory corresponding to the key will be deleted.
0883      * Because ICU may choose to cache NumberFormat objects internally,
0884      * this should be called during application shutdown, after all calls to
0885      * NumberFormat::createInstance to avoid undefined behavior.
0886      * @param key the registry key returned by a previous call to registerFactory
0887      * @param status the in/out status code, no special meanings are assigned
0888      * @return true if the factory for the key was successfully unregistered
0889      * @stable ICU 2.6
0890      */
0891     static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
0892 
0893     /**
0894      * Return a StringEnumeration over the locales available at the time of the call,
0895      * including registered locales.
0896      * @return a StringEnumeration over the locales available at the time of the call
0897      * @stable ICU 2.6
0898      */
0899     static StringEnumeration* U_EXPORT2 getAvailableLocales();
0900 #endif /* UCONFIG_NO_SERVICE */
0901 
0902     /**
0903      * Returns true if grouping is used in this format. For example,
0904      * in the English locale, with grouping on, the number 1234567
0905      * might be formatted as "1,234,567". The grouping separator as
0906      * well as the size of each group is locale dependent and is
0907      * determined by sub-classes of NumberFormat.
0908      * @see setGroupingUsed
0909      * @stable ICU 2.0
0910      */
0911     UBool isGroupingUsed() const;
0912 
0913     /**
0914      * Set whether or not grouping will be used in this format.
0915      * @param newValue    True, grouping will be used in this format.
0916      * @see getGroupingUsed
0917      * @stable ICU 2.0
0918      */
0919     virtual void setGroupingUsed(UBool newValue);
0920 
0921     /**
0922      * Returns the maximum number of digits allowed in the integer portion of a
0923      * number.
0924      * @return     the maximum number of digits allowed in the integer portion of a
0925      *             number.
0926      * @see setMaximumIntegerDigits
0927      * @stable ICU 2.0
0928      */
0929     int32_t getMaximumIntegerDigits() const;
0930 
0931     /**
0932      * Sets the maximum number of digits allowed in the integer portion of a
0933      * number. maximumIntegerDigits must be >= minimumIntegerDigits.  If the
0934      * new value for maximumIntegerDigits is less than the current value
0935      * of minimumIntegerDigits, then minimumIntegerDigits will also be set to
0936      * the new value.
0937      *
0938      * @param newValue    the new value for the maximum number of digits
0939      *                    allowed in the integer portion of a number.
0940      * @see getMaximumIntegerDigits
0941      * @stable ICU 2.0
0942      */
0943     virtual void setMaximumIntegerDigits(int32_t newValue);
0944 
0945     /**
0946      * Returns the minimum number of digits allowed in the integer portion of a
0947      * number.
0948      * @return    the minimum number of digits allowed in the integer portion of a
0949      *            number.
0950      * @see setMinimumIntegerDigits
0951      * @stable ICU 2.0
0952      */
0953     int32_t getMinimumIntegerDigits() const;
0954 
0955     /**
0956      * Sets the minimum number of digits allowed in the integer portion of a
0957      * number. minimumIntegerDigits must be &lt;= maximumIntegerDigits.  If the
0958      * new value for minimumIntegerDigits exceeds the current value
0959      * of maximumIntegerDigits, then maximumIntegerDigits will also be set to
0960      * the new value.
0961      * @param newValue    the new value to be set.
0962      * @see getMinimumIntegerDigits
0963      * @stable ICU 2.0
0964      */
0965     virtual void setMinimumIntegerDigits(int32_t newValue);
0966 
0967     /**
0968      * Returns the maximum number of digits allowed in the fraction portion of a
0969      * number.
0970      * @return    the maximum number of digits allowed in the fraction portion of a
0971      *            number.
0972      * @see setMaximumFractionDigits
0973      * @stable ICU 2.0
0974      */
0975     int32_t getMaximumFractionDigits() const;
0976 
0977     /**
0978      * Sets the maximum number of digits allowed in the fraction portion of a
0979      * number. maximumFractionDigits must be >= minimumFractionDigits.  If the
0980      * new value for maximumFractionDigits is less than the current value
0981      * of minimumFractionDigits, then minimumFractionDigits will also be set to
0982      * the new value.
0983      * @param newValue    the new value to be set.
0984      * @see getMaximumFractionDigits
0985      * @stable ICU 2.0
0986      */
0987     virtual void setMaximumFractionDigits(int32_t newValue);
0988 
0989     /**
0990      * Returns the minimum number of digits allowed in the fraction portion of a
0991      * number.
0992      * @return    the minimum number of digits allowed in the fraction portion of a
0993      *            number.
0994      * @see setMinimumFractionDigits
0995      * @stable ICU 2.0
0996      */
0997     int32_t getMinimumFractionDigits() const;
0998 
0999     /**
1000      * Sets the minimum number of digits allowed in the fraction portion of a
1001      * number. minimumFractionDigits must be &lt;= maximumFractionDigits.   If the
1002      * new value for minimumFractionDigits exceeds the current value
1003      * of maximumFractionDigits, then maximumIntegerDigits will also be set to
1004      * the new value
1005      * @param newValue    the new value to be set.
1006      * @see getMinimumFractionDigits
1007      * @stable ICU 2.0
1008      */
1009     virtual void setMinimumFractionDigits(int32_t newValue);
1010 
1011     /**
1012      * Sets the currency used to display currency
1013      * amounts.  This takes effect immediately, if this format is a
1014      * currency format.  If this format is not a currency format, then
1015      * the currency is used if and when this object becomes a
1016      * currency format.
1017      * @param theCurrency a 3-letter ISO code indicating new currency
1018      * to use.  It need not be null-terminated.  May be the empty
1019      * string or nullptr to indicate no currency.
1020      * @param ec input-output error code
1021      * @stable ICU 3.0
1022      */
1023     virtual void setCurrency(const char16_t* theCurrency, UErrorCode& ec);
1024 
1025     /**
1026      * Gets the currency used to display currency
1027      * amounts.  This may be an empty string for some subclasses.
1028      * @return a 3-letter null-terminated ISO code indicating
1029      * the currency in use, or a pointer to the empty string.
1030      * @stable ICU 2.6
1031      */
1032     const char16_t* getCurrency() const;
1033 
1034     /**
1035      * Set a particular UDisplayContext value in the formatter, such as
1036      * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
1037      * @param value The UDisplayContext value to set.
1038      * @param status Input/output status. If at entry this indicates a failure
1039      *               status, the function will do nothing; otherwise this will be
1040      *               updated with any new status from the function.
1041      * @stable ICU 53
1042      */
1043     virtual void setContext(UDisplayContext value, UErrorCode& status);
1044 
1045     /**
1046      * Get the formatter's UDisplayContext value for the specified UDisplayContextType,
1047      * such as UDISPCTX_TYPE_CAPITALIZATION.
1048      * @param type The UDisplayContextType whose value to return
1049      * @param status Input/output status. If at entry this indicates a failure
1050      *               status, the function will do nothing; otherwise this will be
1051      *               updated with any new status from the function.
1052      * @return The UDisplayContextValue for the specified type.
1053      * @stable ICU 53
1054      */
1055     virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const;
1056 
1057     /**
1058      * Get the rounding mode. This will always return NumberFormat::ERoundingMode::kRoundUnnecessary
1059      * if the subclass does not support rounding. 
1060      * @return A rounding mode
1061      * @stable ICU 60
1062      */
1063     virtual ERoundingMode getRoundingMode() const;
1064 
1065     /**
1066      * Set the rounding mode. If a subclass does not support rounding, this will do nothing.
1067      * @param roundingMode A rounding mode
1068      * @stable ICU 60
1069      */
1070     virtual void setRoundingMode(ERoundingMode roundingMode);
1071 
1072 public:
1073 
1074     /**
1075      * Return the class ID for this class.  This is useful for
1076      * comparing to a return value from getDynamicClassID(). Note that,
1077      * because NumberFormat is an abstract base class, no fully constructed object
1078      * will have the class ID returned by NumberFormat::getStaticClassID().
1079      * @return The class ID for all objects of this class.
1080      * @stable ICU 2.0
1081      */
1082     static UClassID U_EXPORT2 getStaticClassID();
1083 
1084     /**
1085      * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.
1086      * This method is to implement a simple version of RTTI, since not all
1087      * C++ compilers support genuine RTTI.  Polymorphic operator==() and
1088      * clone() methods call this method.
1089      * <P>
1090      * @return The class ID for this object. All objects of a
1091      * given class have the same class ID.  Objects of
1092      * other classes have different class IDs.
1093      * @stable ICU 2.0
1094      */
1095     virtual UClassID getDynamicClassID() const override = 0;
1096 
1097 protected:
1098 
1099     /**
1100      * Default constructor for subclass use only.
1101      * @stable ICU 2.0
1102      */
1103     NumberFormat();
1104 
1105     /**
1106      * Copy constructor.
1107      * @stable ICU 2.0
1108      */
1109     NumberFormat(const NumberFormat&);
1110 
1111     /**
1112      * Assignment operator.
1113      * @stable ICU 2.0
1114      */
1115     NumberFormat& operator=(const NumberFormat&);
1116 
1117     /**
1118      * Returns the currency in effect for this formatter.  Subclasses
1119      * should override this method as needed.  Unlike getCurrency(),
1120      * this method should never return "".
1121      * @result output parameter for null-terminated result, which must
1122      * have a capacity of at least 4
1123      * @internal
1124      */
1125     virtual void getEffectiveCurrency(char16_t* result, UErrorCode& ec) const;
1126 
1127 #ifndef U_HIDE_INTERNAL_API
1128     /**
1129      * Creates the specified number format style of the desired locale.
1130      * If mustBeDecimalFormat is true, then the returned pointer is
1131      * either a DecimalFormat or it is nullptr.
1132      * @internal
1133      */
1134     static NumberFormat* makeInstance(const Locale& desiredLocale,
1135                                       UNumberFormatStyle style,
1136                                       UBool mustBeDecimalFormat,
1137                                       UErrorCode& errorCode);
1138 #endif  /* U_HIDE_INTERNAL_API */
1139 
1140 private:
1141 
1142     static UBool isStyleSupported(UNumberFormatStyle style);
1143 
1144     /**
1145      * Creates the specified decimal format style of the desired locale.
1146      * @param desiredLocale    the given locale.
1147      * @param style            the given style.
1148      * @param errorCode        Output param filled with success/failure status.
1149      * @return                 A new NumberFormat instance.
1150      */
1151     static NumberFormat* makeInstance(const Locale& desiredLocale,
1152                                       UNumberFormatStyle style,
1153                                       UErrorCode& errorCode);
1154 
1155     UBool       fGroupingUsed;
1156     int32_t     fMaxIntegerDigits;
1157     int32_t     fMinIntegerDigits;
1158     int32_t     fMaxFractionDigits;
1159     int32_t     fMinFractionDigits;
1160 
1161   protected:
1162     /** \internal */
1163     static const int32_t gDefaultMaxIntegerDigits;
1164     /** \internal */
1165     static const int32_t gDefaultMinIntegerDigits;
1166 
1167   private:
1168     UBool      fParseIntegerOnly;
1169     UBool      fLenient; // true => lenient parse is enabled
1170 
1171     // ISO currency code
1172     char16_t      fCurrency[4];
1173 
1174     UDisplayContext fCapitalizationContext;
1175 
1176     friend class ICUNumberFormatFactory; // access to makeInstance
1177     friend class ICUNumberFormatService;
1178     friend class ::NumberFormatTest;  // access to isStyleSupported()
1179 };
1180 
1181 #if !UCONFIG_NO_SERVICE
1182 /**
1183  * A NumberFormatFactory is used to register new number formats.  The factory
1184  * should be able to create any of the predefined formats for each locale it
1185  * supports.  When registered, the locales it supports extend or override the
1186  * locale already supported by ICU.
1187  *
1188  * @stable ICU 2.6
1189  */
1190 class U_I18N_API NumberFormatFactory : public UObject {
1191 public:
1192 
1193     /**
1194      * Destructor
1195      * @stable ICU 3.0
1196      */
1197     virtual ~NumberFormatFactory();
1198 
1199     /**
1200      * Return true if this factory will be visible.  Default is true.
1201      * If not visible, the locales supported by this factory will not
1202      * be listed by getAvailableLocales.
1203      * @stable ICU 2.6
1204      */
1205     virtual UBool visible() const = 0;
1206 
1207     /**
1208      * Return the locale names directly supported by this factory.  The number of names
1209      * is returned in count;
1210      * @stable ICU 2.6
1211      */
1212     virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const = 0;
1213 
1214     /**
1215      * Return a number format of the appropriate type.  If the locale
1216      * is not supported, return null.  If the locale is supported, but
1217      * the type is not provided by this service, return null.  Otherwise
1218      * return an appropriate instance of NumberFormat.
1219      * @stable ICU 2.6
1220      */
1221     virtual NumberFormat* createFormat(const Locale& loc, UNumberFormatStyle formatType) = 0;
1222 };
1223 
1224 /**
1225  * A NumberFormatFactory that supports a single locale.  It can be visible or invisible.
1226  * @stable ICU 2.6
1227  */
1228 class U_I18N_API SimpleNumberFormatFactory : public NumberFormatFactory {
1229 protected:
1230     /**
1231      * True if the locale supported by this factory is visible.
1232      * @stable ICU 2.6
1233      */
1234     const UBool _visible;
1235 
1236     /**
1237      * The locale supported by this factory, as a UnicodeString.
1238      * @stable ICU 2.6
1239      */
1240     UnicodeString _id;
1241 
1242 public:
1243     /**
1244      * @stable ICU 2.6
1245      */
1246     SimpleNumberFormatFactory(const Locale& locale, UBool visible = true);
1247 
1248     /**
1249      * @stable ICU 3.0
1250      */
1251     virtual ~SimpleNumberFormatFactory();
1252 
1253     /**
1254      * @stable ICU 2.6
1255      */
1256     virtual UBool visible() const override;
1257 
1258     /**
1259      * @stable ICU 2.6
1260      */
1261     virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const override;
1262 };
1263 #endif /* #if !UCONFIG_NO_SERVICE */
1264 
1265 // -------------------------------------
1266 
1267 inline UBool
1268 NumberFormat::isParseIntegerOnly() const
1269 {
1270     return fParseIntegerOnly;
1271 }
1272 
1273 inline UBool
1274 NumberFormat::isLenient() const
1275 {
1276     return fLenient;
1277 }
1278 
1279 U_NAMESPACE_END
1280 
1281 #endif /* #if !UCONFIG_NO_FORMATTING */
1282 
1283 #endif /* U_SHOW_CPLUSPLUS_API */
1284 
1285 #endif // _NUMFMT
1286 //eof