|
||||
Warning, file /include/unicode/numfmt.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 #ifndef U_HIDE_DRAFT_API 0203 /** 0204 * Rounds ties toward the odd number. 0205 * @draft ICU 73 0206 */ 0207 kRoundHalfOdd, 0208 /** 0209 * Rounds ties toward +∞. 0210 * @draft ICU 73 0211 */ 0212 kRoundHalfCeiling, 0213 /** 0214 * Rounds ties toward -∞. 0215 * @draft ICU 73 0216 */ 0217 kRoundHalfFloor, 0218 #endif /* U_HIDE_DRAFT_API */ 0219 }; 0220 0221 /** 0222 * Alignment Field constants used to construct a FieldPosition object. 0223 * Signifies that the position of the integer part or fraction part of 0224 * a formatted number should be returned. 0225 * 0226 * Note: as of ICU 4.4, the values in this enum have been extended to 0227 * support identification of all number format fields, not just those 0228 * pertaining to alignment. 0229 * 0230 * These constants are provided for backwards compatibility only. 0231 * Please use the C style constants defined in the header file unum.h. 0232 * 0233 * @see FieldPosition 0234 * @stable ICU 2.0 0235 */ 0236 enum EAlignmentFields { 0237 /** @stable ICU 2.0 */ 0238 kIntegerField = UNUM_INTEGER_FIELD, 0239 /** @stable ICU 2.0 */ 0240 kFractionField = UNUM_FRACTION_FIELD, 0241 /** @stable ICU 2.0 */ 0242 kDecimalSeparatorField = UNUM_DECIMAL_SEPARATOR_FIELD, 0243 /** @stable ICU 2.0 */ 0244 kExponentSymbolField = UNUM_EXPONENT_SYMBOL_FIELD, 0245 /** @stable ICU 2.0 */ 0246 kExponentSignField = UNUM_EXPONENT_SIGN_FIELD, 0247 /** @stable ICU 2.0 */ 0248 kExponentField = UNUM_EXPONENT_FIELD, 0249 /** @stable ICU 2.0 */ 0250 kGroupingSeparatorField = UNUM_GROUPING_SEPARATOR_FIELD, 0251 /** @stable ICU 2.0 */ 0252 kCurrencyField = UNUM_CURRENCY_FIELD, 0253 /** @stable ICU 2.0 */ 0254 kPercentField = UNUM_PERCENT_FIELD, 0255 /** @stable ICU 2.0 */ 0256 kPermillField = UNUM_PERMILL_FIELD, 0257 /** @stable ICU 2.0 */ 0258 kSignField = UNUM_SIGN_FIELD, 0259 /** @stable ICU 64 */ 0260 kMeasureUnitField = UNUM_MEASURE_UNIT_FIELD, 0261 /** @stable ICU 64 */ 0262 kCompactField = UNUM_COMPACT_FIELD, 0263 0264 /** 0265 * These constants are provided for backwards compatibility only. 0266 * Please use the constants defined in the header file unum.h. 0267 */ 0268 /** @stable ICU 2.0 */ 0269 INTEGER_FIELD = UNUM_INTEGER_FIELD, 0270 /** @stable ICU 2.0 */ 0271 FRACTION_FIELD = UNUM_FRACTION_FIELD 0272 }; 0273 0274 /** 0275 * Destructor. 0276 * @stable ICU 2.0 0277 */ 0278 virtual ~NumberFormat(); 0279 0280 /** 0281 * Clones this object polymorphically. 0282 * The caller owns the result and should delete it when done. 0283 * @return clone, or nullptr if an error occurred 0284 * @stable ICU 2.0 0285 */ 0286 virtual NumberFormat* clone() const override = 0; 0287 0288 /** 0289 * Return true if the given Format objects are semantically equal. 0290 * Objects of different subclasses are considered unequal. 0291 * @return true if the given Format objects are semantically equal. 0292 * @stable ICU 2.0 0293 */ 0294 virtual bool operator==(const Format& other) const override; 0295 0296 0297 using Format::format; 0298 0299 /** 0300 * Format an object to produce a string. This method handles 0301 * Formattable objects with numeric types. If the Formattable 0302 * object type is not a numeric type, then it returns a failing 0303 * UErrorCode. 0304 * 0305 * @param obj The object to format. 0306 * @param appendTo Output parameter to receive result. 0307 * Result is appended to existing contents. 0308 * @param pos On input: an alignment field, if desired. 0309 * On output: the offsets of the alignment field. 0310 * @param status Output param filled with success/failure status. 0311 * @return Reference to 'appendTo' parameter. 0312 * @stable ICU 2.0 0313 */ 0314 virtual UnicodeString& format(const Formattable& obj, 0315 UnicodeString& appendTo, 0316 FieldPosition& pos, 0317 UErrorCode& status) const override; 0318 0319 /** 0320 * Format an object to produce a string. This method handles 0321 * Formattable objects with numeric types. If the Formattable 0322 * object type is not a numeric type, then it returns a failing 0323 * UErrorCode. 0324 * 0325 * @param obj The object to format. 0326 * @param appendTo Output parameter to receive result. 0327 * Result is appended to existing contents. 0328 * @param posIter On return, can be used to iterate over positions 0329 * of fields generated by this format call. Can be 0330 * nullptr. 0331 * @param status Output param filled with success/failure status. 0332 * @return Reference to 'appendTo' parameter. 0333 * @stable ICU 4.4 0334 */ 0335 virtual UnicodeString& format(const Formattable& obj, 0336 UnicodeString& appendTo, 0337 FieldPositionIterator* posIter, 0338 UErrorCode& status) const override; 0339 0340 /** 0341 * Parse a string to produce an object. This methods handles 0342 * parsing of numeric strings into Formattable objects with numeric 0343 * types. 0344 * <P> 0345 * Before calling, set parse_pos.index to the offset you want to 0346 * start parsing at in the source. After calling, parse_pos.index 0347 * indicates the position after the successfully parsed text. If 0348 * an error occurs, parse_pos.index is unchanged. 0349 * <P> 0350 * When parsing, leading whitespace is discarded (with successful 0351 * parse), while trailing whitespace is left as is. 0352 * <P> 0353 * See Format::parseObject() for more. 0354 * 0355 * @param source The string to be parsed into an object. 0356 * @param result Formattable to be set to the parse result. 0357 * If parse fails, return contents are undefined. 0358 * @param parse_pos The position to start parsing at. Upon return 0359 * this param is set to the position after the 0360 * last character successfully parsed. If the 0361 * source is not parsed successfully, this param 0362 * will remain unchanged. 0363 * @return A newly created Formattable* object, or nullptr 0364 * on failure. The caller owns this and should 0365 * delete it when done. 0366 * @stable ICU 2.0 0367 */ 0368 virtual void parseObject(const UnicodeString& source, 0369 Formattable& result, 0370 ParsePosition& parse_pos) const override; 0371 0372 /** 0373 * Format a double number. These methods call the NumberFormat 0374 * pure virtual format() methods with the default FieldPosition. 0375 * 0376 * @param number The value to be formatted. 0377 * @param appendTo Output parameter to receive result. 0378 * Result is appended to existing contents. 0379 * @return Reference to 'appendTo' parameter. 0380 * @stable ICU 2.0 0381 */ 0382 UnicodeString& format( double number, 0383 UnicodeString& appendTo) const; 0384 0385 /** 0386 * Format a long number. These methods call the NumberFormat 0387 * pure virtual format() methods with the default FieldPosition. 0388 * 0389 * @param number The value to be formatted. 0390 * @param appendTo Output parameter to receive result. 0391 * Result is appended to existing contents. 0392 * @return Reference to 'appendTo' parameter. 0393 * @stable ICU 2.0 0394 */ 0395 UnicodeString& format( int32_t number, 0396 UnicodeString& appendTo) const; 0397 0398 /** 0399 * Format an int64 number. These methods call the NumberFormat 0400 * pure virtual format() methods with the default FieldPosition. 0401 * 0402 * @param number The value to be formatted. 0403 * @param appendTo Output parameter to receive result. 0404 * Result is appended to existing contents. 0405 * @return Reference to 'appendTo' parameter. 0406 * @stable ICU 2.8 0407 */ 0408 UnicodeString& format( int64_t number, 0409 UnicodeString& appendTo) const; 0410 0411 /** 0412 * Format a double number. Concrete subclasses must implement 0413 * these pure virtual methods. 0414 * 0415 * @param number The value to be formatted. 0416 * @param appendTo Output parameter to receive result. 0417 * Result is appended to existing contents. 0418 * @param pos On input: an alignment field, if desired. 0419 * On output: the offsets of the alignment field. 0420 * @return Reference to 'appendTo' parameter. 0421 * @stable ICU 2.0 0422 */ 0423 virtual UnicodeString& format(double number, 0424 UnicodeString& appendTo, 0425 FieldPosition& pos) const = 0; 0426 /** 0427 * Format a double number. By default, the parent function simply 0428 * calls the base class and does not return an error status. 0429 * Therefore, the status may be ignored in some subclasses. 0430 * 0431 * @param number The value to be formatted. 0432 * @param appendTo Output parameter to receive result. 0433 * Result is appended to existing contents. 0434 * @param pos On input: an alignment field, if desired. 0435 * On output: the offsets of the alignment field. 0436 * @param status error status 0437 * @return Reference to 'appendTo' parameter. 0438 * @internal 0439 */ 0440 virtual UnicodeString& format(double number, 0441 UnicodeString& appendTo, 0442 FieldPosition& pos, 0443 UErrorCode &status) const; 0444 /** 0445 * Format a double number. Subclasses must implement 0446 * this method. 0447 * 0448 * @param number The value to be formatted. 0449 * @param appendTo Output parameter to receive result. 0450 * Result is appended to existing contents. 0451 * @param posIter On return, can be used to iterate over positions 0452 * of fields generated by this format call. 0453 * Can be nullptr. 0454 * @param status Output param filled with success/failure status. 0455 * @return Reference to 'appendTo' parameter. 0456 * @stable ICU 4.4 0457 */ 0458 virtual UnicodeString& format(double number, 0459 UnicodeString& appendTo, 0460 FieldPositionIterator* posIter, 0461 UErrorCode& status) const; 0462 /** 0463 * Format a long number. Concrete subclasses must implement 0464 * these pure virtual methods. 0465 * 0466 * @param number The value to be formatted. 0467 * @param appendTo Output parameter to receive result. 0468 * Result is appended to existing contents. 0469 * @param pos On input: an alignment field, if desired. 0470 * On output: the offsets of the alignment field. 0471 * @return Reference to 'appendTo' parameter. 0472 * @stable ICU 2.0 0473 */ 0474 virtual UnicodeString& format(int32_t number, 0475 UnicodeString& appendTo, 0476 FieldPosition& pos) const = 0; 0477 0478 /** 0479 * Format a long number. Concrete subclasses may override 0480 * this function to provide status return. 0481 * 0482 * @param number The value to be formatted. 0483 * @param appendTo Output parameter to receive result. 0484 * Result is appended to existing contents. 0485 * @param pos On input: an alignment field, if desired. 0486 * On output: the offsets of the alignment field. 0487 * @param status the output status. 0488 * @return Reference to 'appendTo' parameter. 0489 * @internal 0490 */ 0491 virtual UnicodeString& format(int32_t number, 0492 UnicodeString& appendTo, 0493 FieldPosition& pos, 0494 UErrorCode &status) const; 0495 0496 /** 0497 * Format an int32 number. Subclasses must implement 0498 * this method. 0499 * 0500 * @param number The value to be formatted. 0501 * @param appendTo Output parameter to receive result. 0502 * Result is appended to existing contents. 0503 * @param posIter On return, can be used to iterate over positions 0504 * of fields generated by this format call. 0505 * Can be nullptr. 0506 * @param status Output param filled with success/failure status. 0507 * @return Reference to 'appendTo' parameter. 0508 * @stable ICU 4.4 0509 */ 0510 virtual UnicodeString& format(int32_t number, 0511 UnicodeString& appendTo, 0512 FieldPositionIterator* posIter, 0513 UErrorCode& status) const; 0514 /** 0515 * Format an int64 number. (Not abstract to retain compatibility 0516 * with earlier releases, however subclasses should override this 0517 * method as it just delegates to format(int32_t number...); 0518 * 0519 * @param number The value to be formatted. 0520 * @param appendTo Output parameter to receive result. 0521 * Result is appended to existing contents. 0522 * @param pos On input: an alignment field, if desired. 0523 * On output: the offsets of the alignment field. 0524 * @return Reference to 'appendTo' parameter. 0525 * @stable ICU 2.8 0526 */ 0527 virtual UnicodeString& format(int64_t number, 0528 UnicodeString& appendTo, 0529 FieldPosition& pos) const; 0530 0531 /** 0532 * Format an int64 number. (Not abstract to retain compatibility 0533 * with earlier releases, however subclasses should override this 0534 * method as it just delegates to format(int32_t number...); 0535 * 0536 * @param number The value to be formatted. 0537 * @param appendTo Output parameter to receive result. 0538 * Result is appended to existing contents. 0539 * @param pos On input: an alignment field, if desired. 0540 * On output: the offsets of the alignment field. 0541 * @param status Output param filled with success/failure status. 0542 * @return Reference to 'appendTo' parameter. 0543 * @internal 0544 */ 0545 virtual UnicodeString& format(int64_t number, 0546 UnicodeString& appendTo, 0547 FieldPosition& pos, 0548 UErrorCode& status) const; 0549 /** 0550 * Format an int64 number. Subclasses must implement 0551 * this method. 0552 * 0553 * @param number The value to be formatted. 0554 * @param appendTo Output parameter to receive result. 0555 * Result is appended to existing contents. 0556 * @param posIter On return, can be used to iterate over positions 0557 * of fields generated by this format call. 0558 * Can be nullptr. 0559 * @param status Output param filled with success/failure status. 0560 * @return Reference to 'appendTo' parameter. 0561 * @stable ICU 4.4 0562 */ 0563 virtual UnicodeString& format(int64_t number, 0564 UnicodeString& appendTo, 0565 FieldPositionIterator* posIter, 0566 UErrorCode& status) const; 0567 0568 /** 0569 * Format a decimal number. Subclasses must implement 0570 * this method. The syntax of the unformatted number is a "numeric string" 0571 * as defined in the Decimal Arithmetic Specification, available at 0572 * http://speleotrove.com/decimal 0573 * 0574 * @param number The unformatted number, as a string, to be formatted. 0575 * @param appendTo Output parameter to receive result. 0576 * Result is appended to existing contents. 0577 * @param posIter On return, can be used to iterate over positions 0578 * of fields generated by this format call. 0579 * Can be nullptr. 0580 * @param status Output param filled with success/failure status. 0581 * @return Reference to 'appendTo' parameter. 0582 * @stable ICU 4.4 0583 */ 0584 virtual UnicodeString& format(StringPiece number, 0585 UnicodeString& appendTo, 0586 FieldPositionIterator* posIter, 0587 UErrorCode& status) const; 0588 0589 // Can't use #ifndef U_HIDE_INTERNAL_API because these are virtual methods 0590 0591 /** 0592 * Format a decimal number. 0593 * The number is a DecimalQuantity wrapper onto a floating point decimal number. 0594 * The default implementation in NumberFormat converts the decimal number 0595 * to a double and formats that. Subclasses of NumberFormat that want 0596 * to specifically handle big decimal numbers must override this method. 0597 * class DecimalFormat does so. 0598 * 0599 * @param number The number, a DecimalQuantity format Decimal Floating Point. 0600 * @param appendTo Output parameter to receive result. 0601 * Result is appended to existing contents. 0602 * @param posIter On return, can be used to iterate over positions 0603 * of fields generated by this format call. 0604 * @param status Output param filled with success/failure status. 0605 * @return Reference to 'appendTo' parameter. 0606 * @internal 0607 */ 0608 virtual UnicodeString& format(const number::impl::DecimalQuantity &number, 0609 UnicodeString& appendTo, 0610 FieldPositionIterator* posIter, 0611 UErrorCode& status) const; 0612 0613 /** 0614 * Format a decimal number. 0615 * The number is a DecimalQuantity wrapper onto a floating point decimal number. 0616 * The default implementation in NumberFormat converts the decimal number 0617 * to a double and formats that. Subclasses of NumberFormat that want 0618 * to specifically handle big decimal numbers must override this method. 0619 * class DecimalFormat does so. 0620 * 0621 * @param number The number, a DecimalQuantity format Decimal Floating Point. 0622 * @param appendTo Output parameter to receive result. 0623 * Result is appended to existing contents. 0624 * @param pos On input: an alignment field, if desired. 0625 * On output: the offsets of the alignment field. 0626 * @param status Output param filled with success/failure status. 0627 * @return Reference to 'appendTo' parameter. 0628 * @internal 0629 */ 0630 virtual UnicodeString& format(const number::impl::DecimalQuantity &number, 0631 UnicodeString& appendTo, 0632 FieldPosition& pos, 0633 UErrorCode& status) const; 0634 0635 /** 0636 * Return a long if possible (e.g. within range LONG_MAX, 0637 * LONG_MAX], and with no decimals), otherwise a double. If 0638 * IntegerOnly is set, will stop at a decimal point (or equivalent; 0639 * e.g. for rational numbers "1 2/3", will stop after the 1). 0640 * <P> 0641 * If no object can be parsed, index is unchanged, and nullptr is 0642 * returned. 0643 * <P> 0644 * This is a pure virtual which concrete subclasses must implement. 0645 * 0646 * @param text The text to be parsed. 0647 * @param result Formattable to be set to the parse result. 0648 * If parse fails, return contents are undefined. 0649 * @param parsePosition The position to start parsing at on input. 0650 * On output, moved to after the last successfully 0651 * parse character. On parse failure, does not change. 0652 * @stable ICU 2.0 0653 */ 0654 virtual void parse(const UnicodeString& text, 0655 Formattable& result, 0656 ParsePosition& parsePosition) const = 0; 0657 0658 /** 0659 * Parse a string as a numeric value, and return a Formattable 0660 * numeric object. This method parses integers only if IntegerOnly 0661 * is set. 0662 * 0663 * @param text The text to be parsed. 0664 * @param result Formattable to be set to the parse result. 0665 * If parse fails, return contents are undefined. 0666 * @param status Output parameter set to a failure error code 0667 * when a failure occurs. The error code when the 0668 * string fails to parse is U_INVALID_FORMAT_ERROR, 0669 * unless overridden by a subclass. 0670 * @see NumberFormat::isParseIntegerOnly 0671 * @stable ICU 2.0 0672 */ 0673 virtual void parse(const UnicodeString& text, 0674 Formattable& result, 0675 UErrorCode& status) const; 0676 0677 /** 0678 * Parses text from the given string as a currency amount. Unlike 0679 * the parse() method, this method will attempt to parse a generic 0680 * currency name, searching for a match of this object's locale's 0681 * currency display names, or for a 3-letter ISO currency code. 0682 * This method will fail if this format is not a currency format, 0683 * that is, if it does not contain the currency pattern symbol 0684 * (U+00A4) in its prefix or suffix. 0685 * 0686 * @param text the string to parse 0687 * @param pos input-output position; on input, the position within text 0688 * to match; must have 0 <= pos.getIndex() < text.length(); 0689 * on output, the position after the last matched character. 0690 * If the parse fails, the position in unchanged upon output. 0691 * @return if parse succeeds, a pointer to a newly-created CurrencyAmount 0692 * object (owned by the caller) containing information about 0693 * the parsed currency; if parse fails, this is nullptr. 0694 * @stable ICU 49 0695 */ 0696 virtual CurrencyAmount* parseCurrency(const UnicodeString& text, 0697 ParsePosition& pos) const; 0698 0699 /** 0700 * Return true if this format will parse numbers as integers 0701 * only. For example in the English locale, with ParseIntegerOnly 0702 * true, the string "1234." would be parsed as the integer value 0703 * 1234 and parsing would stop at the "." character. Of course, 0704 * the exact format accepted by the parse operation is locale 0705 * dependent and determined by sub-classes of NumberFormat. 0706 * @return true if this format will parse numbers as integers 0707 * only. 0708 * @stable ICU 2.0 0709 */ 0710 UBool isParseIntegerOnly(void) const; 0711 0712 /** 0713 * Sets whether or not numbers should be parsed as integers only. 0714 * @param value set True, this format will parse numbers as integers 0715 * only. 0716 * @see isParseIntegerOnly 0717 * @stable ICU 2.0 0718 */ 0719 virtual void setParseIntegerOnly(UBool value); 0720 0721 /** 0722 * Sets whether lenient parsing should be enabled (it is off by default). 0723 * 0724 * @param enable \c true if lenient parsing should be used, 0725 * \c false otherwise. 0726 * @stable ICU 4.8 0727 */ 0728 virtual void setLenient(UBool enable); 0729 0730 /** 0731 * Returns whether lenient parsing is enabled (it is off by default). 0732 * 0733 * @return \c true if lenient parsing is enabled, 0734 * \c false otherwise. 0735 * @see #setLenient 0736 * @stable ICU 4.8 0737 */ 0738 virtual UBool isLenient(void) const; 0739 0740 /** 0741 * Create a default style NumberFormat for the current default locale. 0742 * The default formatting style is locale dependent. 0743 * <p> 0744 * <strong>NOTE:</strong> New users are strongly encouraged to use 0745 * {@link icu::number::NumberFormatter} instead of NumberFormat. 0746 * @stable ICU 2.0 0747 */ 0748 static NumberFormat* U_EXPORT2 createInstance(UErrorCode&); 0749 0750 /** 0751 * Create a default style NumberFormat for the specified locale. 0752 * The default formatting style is locale dependent. 0753 * @param inLocale the given locale. 0754 * <p> 0755 * <strong>NOTE:</strong> New users are strongly encouraged to use 0756 * {@link icu::number::NumberFormatter} instead of NumberFormat. 0757 * @stable ICU 2.0 0758 */ 0759 static NumberFormat* U_EXPORT2 createInstance(const Locale& inLocale, 0760 UErrorCode&); 0761 0762 /** 0763 * Create a specific style NumberFormat for the specified locale. 0764 * <p> 0765 * <strong>NOTE:</strong> New users are strongly encouraged to use 0766 * {@link icu::number::NumberFormatter} instead of NumberFormat. 0767 * @param desiredLocale the given locale. 0768 * @param style the given style. 0769 * @param errorCode Output param filled with success/failure status. 0770 * @return A new NumberFormat instance. 0771 * @stable ICU 4.8 0772 */ 0773 static NumberFormat* U_EXPORT2 createInstance(const Locale& desiredLocale, 0774 UNumberFormatStyle style, 0775 UErrorCode& errorCode); 0776 0777 #ifndef U_HIDE_INTERNAL_API 0778 0779 /** 0780 * ICU use only. 0781 * Creates NumberFormat instance without using the cache. 0782 * @internal 0783 */ 0784 static NumberFormat* internalCreateInstance( 0785 const Locale& desiredLocale, 0786 UNumberFormatStyle style, 0787 UErrorCode& errorCode); 0788 0789 /** 0790 * ICU use only. 0791 * Returns handle to the shared, cached NumberFormat instance for given 0792 * locale. On success, caller must call removeRef() on returned value 0793 * once it is done with the shared instance. 0794 * @internal 0795 */ 0796 static const SharedNumberFormat* U_EXPORT2 createSharedInstance( 0797 const Locale& inLocale, UNumberFormatStyle style, UErrorCode& status); 0798 0799 #endif /* U_HIDE_INTERNAL_API */ 0800 0801 /** 0802 * Returns a currency format for the current default locale. 0803 * <p> 0804 * <strong>NOTE:</strong> New users are strongly encouraged to use 0805 * {@link icu::number::NumberFormatter} instead of NumberFormat. 0806 * @stable ICU 2.0 0807 */ 0808 static NumberFormat* U_EXPORT2 createCurrencyInstance(UErrorCode&); 0809 0810 /** 0811 * Returns a currency format for the specified locale. 0812 * <p> 0813 * <strong>NOTE:</strong> New users are strongly encouraged to use 0814 * {@link icu::number::NumberFormatter} instead of NumberFormat. 0815 * @param inLocale the given locale. 0816 * @stable ICU 2.0 0817 */ 0818 static NumberFormat* U_EXPORT2 createCurrencyInstance(const Locale& inLocale, 0819 UErrorCode&); 0820 0821 /** 0822 * Returns a percentage format for the current default locale. 0823 * <p> 0824 * <strong>NOTE:</strong> New users are strongly encouraged to use 0825 * {@link icu::number::NumberFormatter} instead of NumberFormat. 0826 * @stable ICU 2.0 0827 */ 0828 static NumberFormat* U_EXPORT2 createPercentInstance(UErrorCode&); 0829 0830 /** 0831 * Returns a percentage format for the specified locale. 0832 * <p> 0833 * <strong>NOTE:</strong> New users are strongly encouraged to use 0834 * {@link icu::number::NumberFormatter} instead of NumberFormat. 0835 * @param inLocale the given locale. 0836 * @stable ICU 2.0 0837 */ 0838 static NumberFormat* U_EXPORT2 createPercentInstance(const Locale& inLocale, 0839 UErrorCode&); 0840 0841 /** 0842 * Returns a scientific format for the current default locale. 0843 * <p> 0844 * <strong>NOTE:</strong> New users are strongly encouraged to use 0845 * {@link icu::number::NumberFormatter} instead of NumberFormat. 0846 * @stable ICU 2.0 0847 */ 0848 static NumberFormat* U_EXPORT2 createScientificInstance(UErrorCode&); 0849 0850 /** 0851 * Returns a scientific format for the specified locale. 0852 * <p> 0853 * <strong>NOTE:</strong> New users are strongly encouraged to use 0854 * {@link icu::number::NumberFormatter} instead of NumberFormat. 0855 * @param inLocale the given locale. 0856 * @stable ICU 2.0 0857 */ 0858 static NumberFormat* U_EXPORT2 createScientificInstance(const Locale& inLocale, 0859 UErrorCode&); 0860 0861 /** 0862 * Get the set of Locales for which NumberFormats are installed. 0863 * @param count Output param to receive the size of the locales 0864 * @stable ICU 2.0 0865 */ 0866 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count); 0867 0868 #if !UCONFIG_NO_SERVICE 0869 /** 0870 * Register a new NumberFormatFactory. The factory will be adopted. 0871 * Because ICU may choose to cache NumberFormat objects internally, 0872 * this must be called at application startup, prior to any calls to 0873 * NumberFormat::createInstance to avoid undefined behavior. 0874 * @param toAdopt the NumberFormatFactory instance to be adopted 0875 * @param status the in/out status code, no special meanings are assigned 0876 * @return a registry key that can be used to unregister this factory 0877 * @stable ICU 2.6 0878 */ 0879 static URegistryKey U_EXPORT2 registerFactory(NumberFormatFactory* toAdopt, UErrorCode& status); 0880 0881 /** 0882 * Unregister a previously-registered NumberFormatFactory using the key returned from the 0883 * register call. Key becomes invalid after a successful call and should not be used again. 0884 * The NumberFormatFactory corresponding to the key will be deleted. 0885 * Because ICU may choose to cache NumberFormat objects internally, 0886 * this should be called during application shutdown, after all calls to 0887 * NumberFormat::createInstance to avoid undefined behavior. 0888 * @param key the registry key returned by a previous call to registerFactory 0889 * @param status the in/out status code, no special meanings are assigned 0890 * @return true if the factory for the key was successfully unregistered 0891 * @stable ICU 2.6 0892 */ 0893 static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status); 0894 0895 /** 0896 * Return a StringEnumeration over the locales available at the time of the call, 0897 * including registered locales. 0898 * @return a StringEnumeration over the locales available at the time of the call 0899 * @stable ICU 2.6 0900 */ 0901 static StringEnumeration* U_EXPORT2 getAvailableLocales(void); 0902 #endif /* UCONFIG_NO_SERVICE */ 0903 0904 /** 0905 * Returns true if grouping is used in this format. For example, 0906 * in the English locale, with grouping on, the number 1234567 0907 * might be formatted as "1,234,567". The grouping separator as 0908 * well as the size of each group is locale dependent and is 0909 * determined by sub-classes of NumberFormat. 0910 * @see setGroupingUsed 0911 * @stable ICU 2.0 0912 */ 0913 UBool isGroupingUsed(void) const; 0914 0915 /** 0916 * Set whether or not grouping will be used in this format. 0917 * @param newValue True, grouping will be used in this format. 0918 * @see getGroupingUsed 0919 * @stable ICU 2.0 0920 */ 0921 virtual void setGroupingUsed(UBool newValue); 0922 0923 /** 0924 * Returns the maximum number of digits allowed in the integer portion of a 0925 * number. 0926 * @return the maximum number of digits allowed in the integer portion of a 0927 * number. 0928 * @see setMaximumIntegerDigits 0929 * @stable ICU 2.0 0930 */ 0931 int32_t getMaximumIntegerDigits(void) const; 0932 0933 /** 0934 * Sets the maximum number of digits allowed in the integer portion of a 0935 * number. maximumIntegerDigits must be >= minimumIntegerDigits. If the 0936 * new value for maximumIntegerDigits is less than the current value 0937 * of minimumIntegerDigits, then minimumIntegerDigits will also be set to 0938 * the new value. 0939 * 0940 * @param newValue the new value for the maximum number of digits 0941 * allowed in the integer portion of a number. 0942 * @see getMaximumIntegerDigits 0943 * @stable ICU 2.0 0944 */ 0945 virtual void setMaximumIntegerDigits(int32_t newValue); 0946 0947 /** 0948 * Returns the minimum number of digits allowed in the integer portion of a 0949 * number. 0950 * @return the minimum number of digits allowed in the integer portion of a 0951 * number. 0952 * @see setMinimumIntegerDigits 0953 * @stable ICU 2.0 0954 */ 0955 int32_t getMinimumIntegerDigits(void) const; 0956 0957 /** 0958 * Sets the minimum number of digits allowed in the integer portion of a 0959 * number. minimumIntegerDigits must be <= maximumIntegerDigits. If the 0960 * new value for minimumIntegerDigits exceeds the current value 0961 * of maximumIntegerDigits, then maximumIntegerDigits will also be set to 0962 * the new value. 0963 * @param newValue the new value to be set. 0964 * @see getMinimumIntegerDigits 0965 * @stable ICU 2.0 0966 */ 0967 virtual void setMinimumIntegerDigits(int32_t newValue); 0968 0969 /** 0970 * Returns the maximum number of digits allowed in the fraction portion of a 0971 * number. 0972 * @return the maximum number of digits allowed in the fraction portion of a 0973 * number. 0974 * @see setMaximumFractionDigits 0975 * @stable ICU 2.0 0976 */ 0977 int32_t getMaximumFractionDigits(void) const; 0978 0979 /** 0980 * Sets the maximum number of digits allowed in the fraction portion of a 0981 * number. maximumFractionDigits must be >= minimumFractionDigits. If the 0982 * new value for maximumFractionDigits is less than the current value 0983 * of minimumFractionDigits, then minimumFractionDigits will also be set to 0984 * the new value. 0985 * @param newValue the new value to be set. 0986 * @see getMaximumFractionDigits 0987 * @stable ICU 2.0 0988 */ 0989 virtual void setMaximumFractionDigits(int32_t newValue); 0990 0991 /** 0992 * Returns the minimum number of digits allowed in the fraction portion of a 0993 * number. 0994 * @return the minimum number of digits allowed in the fraction portion of a 0995 * number. 0996 * @see setMinimumFractionDigits 0997 * @stable ICU 2.0 0998 */ 0999 int32_t getMinimumFractionDigits(void) const; 1000 1001 /** 1002 * Sets the minimum number of digits allowed in the fraction portion of a 1003 * number. minimumFractionDigits must be <= maximumFractionDigits. If the 1004 * new value for minimumFractionDigits exceeds the current value 1005 * of maximumFractionDigits, then maximumIntegerDigits will also be set to 1006 * the new value 1007 * @param newValue the new value to be set. 1008 * @see getMinimumFractionDigits 1009 * @stable ICU 2.0 1010 */ 1011 virtual void setMinimumFractionDigits(int32_t newValue); 1012 1013 /** 1014 * Sets the currency used to display currency 1015 * amounts. This takes effect immediately, if this format is a 1016 * currency format. If this format is not a currency format, then 1017 * the currency is used if and when this object becomes a 1018 * currency format. 1019 * @param theCurrency a 3-letter ISO code indicating new currency 1020 * to use. It need not be null-terminated. May be the empty 1021 * string or nullptr to indicate no currency. 1022 * @param ec input-output error code 1023 * @stable ICU 3.0 1024 */ 1025 virtual void setCurrency(const char16_t* theCurrency, UErrorCode& ec); 1026 1027 /** 1028 * Gets the currency used to display currency 1029 * amounts. This may be an empty string for some subclasses. 1030 * @return a 3-letter null-terminated ISO code indicating 1031 * the currency in use, or a pointer to the empty string. 1032 * @stable ICU 2.6 1033 */ 1034 const char16_t* getCurrency() const; 1035 1036 /** 1037 * Set a particular UDisplayContext value in the formatter, such as 1038 * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. 1039 * @param value The UDisplayContext value to set. 1040 * @param status Input/output status. If at entry this indicates a failure 1041 * status, the function will do nothing; otherwise this will be 1042 * updated with any new status from the function. 1043 * @stable ICU 53 1044 */ 1045 virtual void setContext(UDisplayContext value, UErrorCode& status); 1046 1047 /** 1048 * Get the formatter's UDisplayContext value for the specified UDisplayContextType, 1049 * such as UDISPCTX_TYPE_CAPITALIZATION. 1050 * @param type The UDisplayContextType whose value to return 1051 * @param status Input/output status. If at entry this indicates a failure 1052 * status, the function will do nothing; otherwise this will be 1053 * updated with any new status from the function. 1054 * @return The UDisplayContextValue for the specified type. 1055 * @stable ICU 53 1056 */ 1057 virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const; 1058 1059 /** 1060 * Get the rounding mode. This will always return NumberFormat::ERoundingMode::kRoundUnnecessary 1061 * if the subclass does not support rounding. 1062 * @return A rounding mode 1063 * @stable ICU 60 1064 */ 1065 virtual ERoundingMode getRoundingMode(void) const; 1066 1067 /** 1068 * Set the rounding mode. If a subclass does not support rounding, this will do nothing. 1069 * @param roundingMode A rounding mode 1070 * @stable ICU 60 1071 */ 1072 virtual void setRoundingMode(ERoundingMode roundingMode); 1073 1074 public: 1075 1076 /** 1077 * Return the class ID for this class. This is useful for 1078 * comparing to a return value from getDynamicClassID(). Note that, 1079 * because NumberFormat is an abstract base class, no fully constructed object 1080 * will have the class ID returned by NumberFormat::getStaticClassID(). 1081 * @return The class ID for all objects of this class. 1082 * @stable ICU 2.0 1083 */ 1084 static UClassID U_EXPORT2 getStaticClassID(void); 1085 1086 /** 1087 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. 1088 * This method is to implement a simple version of RTTI, since not all 1089 * C++ compilers support genuine RTTI. Polymorphic operator==() and 1090 * clone() methods call this method. 1091 * <P> 1092 * @return The class ID for this object. All objects of a 1093 * given class have the same class ID. Objects of 1094 * other classes have different class IDs. 1095 * @stable ICU 2.0 1096 */ 1097 virtual UClassID getDynamicClassID(void) const override = 0; 1098 1099 protected: 1100 1101 /** 1102 * Default constructor for subclass use only. 1103 * @stable ICU 2.0 1104 */ 1105 NumberFormat(); 1106 1107 /** 1108 * Copy constructor. 1109 * @stable ICU 2.0 1110 */ 1111 NumberFormat(const NumberFormat&); 1112 1113 /** 1114 * Assignment operator. 1115 * @stable ICU 2.0 1116 */ 1117 NumberFormat& operator=(const NumberFormat&); 1118 1119 /** 1120 * Returns the currency in effect for this formatter. Subclasses 1121 * should override this method as needed. Unlike getCurrency(), 1122 * this method should never return "". 1123 * @result output parameter for null-terminated result, which must 1124 * have a capacity of at least 4 1125 * @internal 1126 */ 1127 virtual void getEffectiveCurrency(char16_t* result, UErrorCode& ec) const; 1128 1129 #ifndef U_HIDE_INTERNAL_API 1130 /** 1131 * Creates the specified number format style of the desired locale. 1132 * If mustBeDecimalFormat is true, then the returned pointer is 1133 * either a DecimalFormat or it is nullptr. 1134 * @internal 1135 */ 1136 static NumberFormat* makeInstance(const Locale& desiredLocale, 1137 UNumberFormatStyle style, 1138 UBool mustBeDecimalFormat, 1139 UErrorCode& errorCode); 1140 #endif /* U_HIDE_INTERNAL_API */ 1141 1142 private: 1143 1144 static UBool isStyleSupported(UNumberFormatStyle style); 1145 1146 /** 1147 * Creates the specified decimal format style of the desired locale. 1148 * @param desiredLocale the given locale. 1149 * @param style the given style. 1150 * @param errorCode Output param filled with success/failure status. 1151 * @return A new NumberFormat instance. 1152 */ 1153 static NumberFormat* makeInstance(const Locale& desiredLocale, 1154 UNumberFormatStyle style, 1155 UErrorCode& errorCode); 1156 1157 UBool fGroupingUsed; 1158 int32_t fMaxIntegerDigits; 1159 int32_t fMinIntegerDigits; 1160 int32_t fMaxFractionDigits; 1161 int32_t fMinFractionDigits; 1162 1163 protected: 1164 /** \internal */ 1165 static const int32_t gDefaultMaxIntegerDigits; 1166 /** \internal */ 1167 static const int32_t gDefaultMinIntegerDigits; 1168 1169 private: 1170 UBool fParseIntegerOnly; 1171 UBool fLenient; // true => lenient parse is enabled 1172 1173 // ISO currency code 1174 char16_t fCurrency[4]; 1175 1176 UDisplayContext fCapitalizationContext; 1177 1178 friend class ICUNumberFormatFactory; // access to makeInstance 1179 friend class ICUNumberFormatService; 1180 friend class ::NumberFormatTest; // access to isStyleSupported() 1181 }; 1182 1183 #if !UCONFIG_NO_SERVICE 1184 /** 1185 * A NumberFormatFactory is used to register new number formats. The factory 1186 * should be able to create any of the predefined formats for each locale it 1187 * supports. When registered, the locales it supports extend or override the 1188 * locale already supported by ICU. 1189 * 1190 * @stable ICU 2.6 1191 */ 1192 class U_I18N_API NumberFormatFactory : public UObject { 1193 public: 1194 1195 /** 1196 * Destructor 1197 * @stable ICU 3.0 1198 */ 1199 virtual ~NumberFormatFactory(); 1200 1201 /** 1202 * Return true if this factory will be visible. Default is true. 1203 * If not visible, the locales supported by this factory will not 1204 * be listed by getAvailableLocales. 1205 * @stable ICU 2.6 1206 */ 1207 virtual UBool visible(void) const = 0; 1208 1209 /** 1210 * Return the locale names directly supported by this factory. The number of names 1211 * is returned in count; 1212 * @stable ICU 2.6 1213 */ 1214 virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const = 0; 1215 1216 /** 1217 * Return a number format of the appropriate type. If the locale 1218 * is not supported, return null. If the locale is supported, but 1219 * the type is not provided by this service, return null. Otherwise 1220 * return an appropriate instance of NumberFormat. 1221 * @stable ICU 2.6 1222 */ 1223 virtual NumberFormat* createFormat(const Locale& loc, UNumberFormatStyle formatType) = 0; 1224 }; 1225 1226 /** 1227 * A NumberFormatFactory that supports a single locale. It can be visible or invisible. 1228 * @stable ICU 2.6 1229 */ 1230 class U_I18N_API SimpleNumberFormatFactory : public NumberFormatFactory { 1231 protected: 1232 /** 1233 * True if the locale supported by this factory is visible. 1234 * @stable ICU 2.6 1235 */ 1236 const UBool _visible; 1237 1238 /** 1239 * The locale supported by this factory, as a UnicodeString. 1240 * @stable ICU 2.6 1241 */ 1242 UnicodeString _id; 1243 1244 public: 1245 /** 1246 * @stable ICU 2.6 1247 */ 1248 SimpleNumberFormatFactory(const Locale& locale, UBool visible = true); 1249 1250 /** 1251 * @stable ICU 3.0 1252 */ 1253 virtual ~SimpleNumberFormatFactory(); 1254 1255 /** 1256 * @stable ICU 2.6 1257 */ 1258 virtual UBool visible(void) const override; 1259 1260 /** 1261 * @stable ICU 2.6 1262 */ 1263 virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const override; 1264 }; 1265 #endif /* #if !UCONFIG_NO_SERVICE */ 1266 1267 // ------------------------------------- 1268 1269 inline UBool 1270 NumberFormat::isParseIntegerOnly() const 1271 { 1272 return fParseIntegerOnly; 1273 } 1274 1275 inline UBool 1276 NumberFormat::isLenient() const 1277 { 1278 return fLenient; 1279 } 1280 1281 U_NAMESPACE_END 1282 1283 #endif /* #if !UCONFIG_NO_FORMATTING */ 1284 1285 #endif /* U_SHOW_CPLUSPLUS_API */ 1286 1287 #endif // _NUMFMT 1288 //eof
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |