1999-12-28 23:57:50 +00:00
|
|
|
/*
|
2006-02-02 03:48:14 +00:00
|
|
|
********************************************************************************
|
2014-01-14 07:31:30 +00:00
|
|
|
* Copyright (C) 1997-2014, International Business Machines Corporation and others.
|
2006-01-18 04:19:45 +00:00
|
|
|
* All Rights Reserved.
|
1999-12-28 23:57:50 +00:00
|
|
|
********************************************************************************
|
|
|
|
*
|
|
|
|
* File NUMFMT.H
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 02/19/97 aliu Converted from java.
|
|
|
|
* 03/18/97 clhuang Updated per C++ implementation.
|
|
|
|
* 04/17/97 aliu Changed DigitCount to int per code review.
|
|
|
|
* 07/20/98 stephen JDK 1.2 sync up. Added scientific support.
|
|
|
|
* Changed naming conventions to match C++ guidelines
|
|
|
|
* Derecated Java style constants (eg, INTEGER_FIELD)
|
|
|
|
********************************************************************************
|
|
|
|
*/
|
2001-03-22 00:09:10 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#ifndef NUMFMT_H
|
|
|
|
#define NUMFMT_H
|
2001-03-22 00:09:10 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
2002-09-20 01:54:48 +00:00
|
|
|
|
2005-06-22 22:39:36 +00:00
|
|
|
/**
|
2010-01-28 19:39:24 +00:00
|
|
|
* \file
|
2005-06-22 22:39:36 +00:00
|
|
|
* \brief C++ API: Abstract base class for all number formats.
|
|
|
|
*/
|
2010-01-28 19:39:24 +00:00
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#if !UCONFIG_NO_FORMATTING
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/unistr.h"
|
|
|
|
#include "unicode/format.h"
|
2003-02-25 23:36:48 +00:00
|
|
|
#include "unicode/unum.h" // UNumberFormatStyle
|
|
|
|
#include "unicode/locid.h"
|
2010-01-15 22:28:39 +00:00
|
|
|
#include "unicode/stringpiece.h"
|
2012-02-19 06:45:47 +00:00
|
|
|
#include "unicode/curramt.h"
|
2014-01-14 07:31:30 +00:00
|
|
|
#include "unicode/udisplaycontext.h"
|
2001-10-08 23:26:58 +00:00
|
|
|
|
2011-04-29 00:00:47 +00:00
|
|
|
class NumberFormatTest;
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2014-02-10 19:13:50 +00:00
|
|
|
class SharedNumberFormat;
|
|
|
|
|
2004-07-18 02:02:06 +00:00
|
|
|
#if !UCONFIG_NO_SERVICE
|
2003-02-25 23:36:48 +00:00
|
|
|
class NumberFormatFactory;
|
|
|
|
class StringEnumeration;
|
2004-07-18 02:02:06 +00:00
|
|
|
#endif
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
2005-06-22 22:39:36 +00:00
|
|
|
*
|
1999-12-28 23:57:50 +00:00
|
|
|
* Abstract base class for all number formats. Provides interface for
|
|
|
|
* formatting and parsing a number. Also provides methods for
|
|
|
|
* determining which locales have number formats, and what their names
|
|
|
|
* are.
|
|
|
|
* <P>
|
|
|
|
* NumberFormat helps you to format and parse numbers for any locale.
|
|
|
|
* Your code can be completely independent of the locale conventions
|
|
|
|
* for decimal points, thousands-separators, or even the particular
|
|
|
|
* decimal digits used, or whether the number format is even decimal.
|
|
|
|
* <P>
|
|
|
|
* To format a number for the current Locale, use one of the static
|
|
|
|
* factory methods:
|
|
|
|
* <pre>
|
2000-12-08 18:46:55 +00:00
|
|
|
* \code
|
|
|
|
* double myNumber = 7.0;
|
|
|
|
* UnicodeString myString;
|
|
|
|
* UErrorCode success = U_ZERO_ERROR;
|
|
|
|
* NumberFormat* nf = NumberFormat::createInstance(success)
|
|
|
|
* nf->format(myNumber, myString);
|
2001-03-19 22:30:38 +00:00
|
|
|
* cout << " Example 1: " << myString << endl;
|
2000-12-08 18:46:55 +00:00
|
|
|
* \endcode
|
1999-12-28 23:57:50 +00:00
|
|
|
* </pre>
|
2012-11-14 18:49:38 +00:00
|
|
|
* Note that there are additional factory methods within subclasses of
|
|
|
|
* NumberFormat.
|
|
|
|
* <P>
|
1999-12-28 23:57:50 +00:00
|
|
|
* If you are formatting multiple numbers, it is more efficient to get
|
|
|
|
* the format and use it multiple times so that the system doesn't
|
|
|
|
* have to fetch the information about the local language and country
|
|
|
|
* conventions multiple times.
|
|
|
|
* <pre>
|
2001-03-22 00:09:10 +00:00
|
|
|
* \code
|
2000-12-08 18:46:55 +00:00
|
|
|
* UnicodeString myString;
|
|
|
|
* UErrorCode success = U_ZERO_ERROR;
|
|
|
|
* nf = NumberFormat::createInstance( success );
|
|
|
|
* int32_t a[] = { 123, 3333, -1234567 };
|
|
|
|
* const int32_t a_len = sizeof(a) / sizeof(a[0]);
|
|
|
|
* myString.remove();
|
|
|
|
* for (int32_t i = 0; i < a_len; i++) {
|
|
|
|
* nf->format(a[i], myString);
|
|
|
|
* myString += " ; ";
|
|
|
|
* }
|
2001-03-19 22:30:38 +00:00
|
|
|
* cout << " Example 2: " << myString << endl;
|
2004-06-23 17:04:41 +00:00
|
|
|
* \endcode
|
1999-12-28 23:57:50 +00:00
|
|
|
* </pre>
|
|
|
|
* To format a number for a different Locale, specify it in the
|
|
|
|
* call to createInstance().
|
|
|
|
* <pre>
|
2000-12-08 18:46:55 +00:00
|
|
|
* \code
|
|
|
|
* nf = NumberFormat::createInstance( Locale::FRENCH, success );
|
|
|
|
* \endcode
|
1999-12-28 23:57:50 +00:00
|
|
|
* </pre>
|
|
|
|
* You can use a NumberFormat to parse also.
|
|
|
|
* <pre>
|
2000-12-08 18:46:55 +00:00
|
|
|
* \code
|
|
|
|
* UErrorCode success;
|
|
|
|
* Formattable result(-999); // initialized with error code
|
|
|
|
* nf->parse(myString, result, success);
|
|
|
|
* \endcode
|
1999-12-28 23:57:50 +00:00
|
|
|
* </pre>
|
|
|
|
* Use createInstance to get the normal number format for that country.
|
|
|
|
* There are other static factory methods available. Use getCurrency
|
|
|
|
* to get the currency number format for that country. Use getPercent
|
|
|
|
* to get a format for displaying percentages. With this format, a
|
|
|
|
* fraction from 0.53 is displayed as 53%.
|
|
|
|
* <P>
|
2009-02-12 22:55:29 +00:00
|
|
|
* Starting from ICU 4.2, you can use createInstance() by passing in a 'style'
|
2010-01-28 19:39:24 +00:00
|
|
|
* as parameter to get the correct instance.
|
|
|
|
* For example,
|
2009-02-12 22:55:29 +00:00
|
|
|
* use createInstance(...kNumberStyle...) to get the normal number format,
|
2010-01-28 19:39:24 +00:00
|
|
|
* createInstance(...kPercentStyle...) to get a format for displaying
|
2009-02-12 22:55:29 +00:00
|
|
|
* percentage,
|
2010-01-28 19:39:24 +00:00
|
|
|
* createInstance(...kScientificStyle...) to get a format for displaying
|
2009-02-12 22:55:29 +00:00
|
|
|
* scientific number,
|
2010-01-28 19:39:24 +00:00
|
|
|
* createInstance(...kCurrencyStyle...) to get the currency number format,
|
2009-02-12 22:55:29 +00:00
|
|
|
* in which the currency is represented by its symbol, for example, "$3.00".
|
2010-01-28 19:39:24 +00:00
|
|
|
* createInstance(...kIsoCurrencyStyle...) to get the currency number format,
|
2009-02-12 22:55:29 +00:00
|
|
|
* in which the currency is represented by its ISO code, for example "USD3.00".
|
|
|
|
* createInstance(...kPluralCurrencyStyle...) to get the currency number format,
|
|
|
|
* in which the currency is represented by its full name in plural format,
|
|
|
|
* for example, "3.00 US dollars" or "1.00 US dollar".
|
|
|
|
* <P>
|
1999-12-28 23:57:50 +00:00
|
|
|
* You can also control the display of numbers with such methods as
|
|
|
|
* getMinimumFractionDigits. If you want even more control over the
|
|
|
|
* format or parsing, or want to give your users more control, you can
|
|
|
|
* try casting the NumberFormat you get from the factory methods to a
|
|
|
|
* DecimalNumberFormat. This will work for the vast majority of
|
|
|
|
* countries; just remember to put it in a try block in case you
|
|
|
|
* encounter an unusual one.
|
|
|
|
* <P>
|
|
|
|
* You can also use forms of the parse and format methods with
|
|
|
|
* ParsePosition and FieldPosition to allow you to:
|
|
|
|
* <ul type=round>
|
|
|
|
* <li>(a) progressively parse through pieces of a string.
|
|
|
|
* <li>(b) align the decimal point and other areas.
|
|
|
|
* </ul>
|
|
|
|
* For example, you can align numbers in two ways.
|
|
|
|
* <P>
|
|
|
|
* If you are using a monospaced font with spacing for alignment, you
|
|
|
|
* can pass the FieldPosition in your format call, with field =
|
|
|
|
* INTEGER_FIELD. On output, getEndIndex will be set to the offset
|
|
|
|
* between the last character of the integer and the decimal. Add
|
|
|
|
* (desiredSpaceCount - getEndIndex) spaces at the front of the
|
|
|
|
* string.
|
|
|
|
* <P>
|
|
|
|
* If you are using proportional fonts, instead of padding with
|
|
|
|
* spaces, measure the width of the string in pixels from the start to
|
|
|
|
* getEndIndex. Then move the pen by (desiredPixelWidth -
|
|
|
|
* widthToAlignmentPoint) before drawing the text. It also works
|
|
|
|
* where there is no decimal, but possibly additional characters at
|
|
|
|
* the end, e.g. with parentheses in negative numbers: "(12)" for -12.
|
2004-04-01 19:05:57 +00:00
|
|
|
* <p>
|
|
|
|
* <em>User subclasses are not supported.</em> While clients may write
|
|
|
|
* subclasses, such code will not necessarily work and will not be
|
|
|
|
* guaranteed to work stably from release to release.
|
|
|
|
*
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
class U_I18N_API NumberFormat : public Format {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Alignment Field constants used to construct a FieldPosition object.
|
|
|
|
* Signifies that the position of the integer part or fraction part of
|
|
|
|
* a formatted number should be returned.
|
|
|
|
*
|
2009-12-17 22:15:20 +00:00
|
|
|
* Note: as of ICU 4.4, the values in this enum have been extended to
|
|
|
|
* support identification of all number format fields, not just those
|
|
|
|
* pertaining to alignment.
|
|
|
|
*
|
2012-02-10 00:38:34 +00:00
|
|
|
* These constants are provided for backwards compatibility only.
|
|
|
|
* Please use the C style constants defined in the header file unum.h.
|
|
|
|
*
|
1999-12-28 23:57:50 +00:00
|
|
|
* @see FieldPosition
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
enum EAlignmentFields {
|
2012-02-10 00:38:34 +00:00
|
|
|
/** @stable ICU 2.0 */
|
|
|
|
kIntegerField = UNUM_INTEGER_FIELD,
|
|
|
|
/** @stable ICU 2.0 */
|
|
|
|
kFractionField = UNUM_FRACTION_FIELD,
|
|
|
|
/** @stable ICU 2.0 */
|
|
|
|
kDecimalSeparatorField = UNUM_DECIMAL_SEPARATOR_FIELD,
|
|
|
|
/** @stable ICU 2.0 */
|
|
|
|
kExponentSymbolField = UNUM_EXPONENT_SYMBOL_FIELD,
|
|
|
|
/** @stable ICU 2.0 */
|
|
|
|
kExponentSignField = UNUM_EXPONENT_SIGN_FIELD,
|
|
|
|
/** @stable ICU 2.0 */
|
|
|
|
kExponentField = UNUM_EXPONENT_FIELD,
|
|
|
|
/** @stable ICU 2.0 */
|
|
|
|
kGroupingSeparatorField = UNUM_GROUPING_SEPARATOR_FIELD,
|
|
|
|
/** @stable ICU 2.0 */
|
|
|
|
kCurrencyField = UNUM_CURRENCY_FIELD,
|
|
|
|
/** @stable ICU 2.0 */
|
|
|
|
kPercentField = UNUM_PERCENT_FIELD,
|
|
|
|
/** @stable ICU 2.0 */
|
|
|
|
kPermillField = UNUM_PERMILL_FIELD,
|
|
|
|
/** @stable ICU 2.0 */
|
|
|
|
kSignField = UNUM_SIGN_FIELD,
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
2002-12-12 00:20:45 +00:00
|
|
|
* These constants are provided for backwards compatibility only.
|
2012-02-10 00:38:34 +00:00
|
|
|
* Please use the constants defined in the header file unum.h.
|
2001-03-22 00:09:10 +00:00
|
|
|
*/
|
2012-02-10 00:38:34 +00:00
|
|
|
/** @stable ICU 2.0 */
|
|
|
|
INTEGER_FIELD = UNUM_INTEGER_FIELD,
|
|
|
|
/** @stable ICU 2.0 */
|
|
|
|
FRACTION_FIELD = UNUM_FRACTION_FIELD
|
1999-12-28 23:57:50 +00:00
|
|
|
};
|
|
|
|
|
2001-11-14 01:55:08 +00:00
|
|
|
/**
|
|
|
|
* Destructor.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
2001-11-14 01:55:08 +00:00
|
|
|
*/
|
1999-12-28 23:57:50 +00:00
|
|
|
virtual ~NumberFormat();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the given Format objects are semantically equal.
|
|
|
|
* Objects of different subclasses are considered unequal.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @return true if the given Format objects are semantically equal.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
virtual UBool operator==(const Format& other) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2010-02-24 23:52:27 +00:00
|
|
|
|
|
|
|
using Format::format;
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Format an object to produce a string. This method handles
|
|
|
|
* Formattable objects with numeric types. If the Formattable
|
|
|
|
* object type is not a numeric type, then it returns a failing
|
|
|
|
* UErrorCode.
|
|
|
|
*
|
2002-11-23 01:11:50 +00:00
|
|
|
* @param obj The object to format.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param pos On input: an alignment field, if desired.
|
|
|
|
* On output: the offsets of the alignment field.
|
|
|
|
* @param status Output param filled with success/failure status.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual UnicodeString& format(const Formattable& obj,
|
2002-11-23 01:11:50 +00:00
|
|
|
UnicodeString& appendTo,
|
1999-12-28 23:57:50 +00:00
|
|
|
FieldPosition& pos,
|
|
|
|
UErrorCode& status) const;
|
|
|
|
|
2009-12-17 22:15:20 +00:00
|
|
|
/**
|
|
|
|
* Format an object to produce a string. This method handles
|
|
|
|
* Formattable objects with numeric types. If the Formattable
|
|
|
|
* object type is not a numeric type, then it returns a failing
|
|
|
|
* UErrorCode.
|
|
|
|
*
|
|
|
|
* @param obj The object to format.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param posIter On return, can be used to iterate over positions
|
2010-02-24 23:52:27 +00:00
|
|
|
* of fields generated by this format call. Can be
|
2010-01-28 19:39:24 +00:00
|
|
|
* NULL.
|
2009-12-17 22:15:20 +00:00
|
|
|
* @param status Output param filled with success/failure status.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable 4.4
|
2009-12-17 22:15:20 +00:00
|
|
|
*/
|
|
|
|
virtual UnicodeString& format(const Formattable& obj,
|
|
|
|
UnicodeString& appendTo,
|
2010-01-28 19:39:24 +00:00
|
|
|
FieldPositionIterator* posIter,
|
2009-12-17 22:15:20 +00:00
|
|
|
UErrorCode& status) const;
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Parse a string to produce an object. This methods handles
|
|
|
|
* parsing of numeric strings into Formattable objects with numeric
|
|
|
|
* types.
|
|
|
|
* <P>
|
|
|
|
* Before calling, set parse_pos.index to the offset you want to
|
|
|
|
* start parsing at in the source. After calling, parse_pos.index
|
2004-04-15 06:20:42 +00:00
|
|
|
* indicates the position after the successfully parsed text. If
|
|
|
|
* an error occurs, parse_pos.index is unchanged.
|
1999-12-28 23:57:50 +00:00
|
|
|
* <P>
|
|
|
|
* When parsing, leading whitespace is discarded (with successful
|
|
|
|
* parse), while trailing whitespace is left as is.
|
|
|
|
* <P>
|
|
|
|
* See Format::parseObject() for more.
|
|
|
|
*
|
|
|
|
* @param source The string to be parsed into an object.
|
|
|
|
* @param result Formattable to be set to the parse result.
|
|
|
|
* If parse fails, return contents are undefined.
|
|
|
|
* @param parse_pos The position to start parsing at. Upon return
|
|
|
|
* this param is set to the position after the
|
|
|
|
* last character successfully parsed. If the
|
|
|
|
* source is not parsed successfully, this param
|
|
|
|
* will remain unchanged.
|
|
|
|
* @return A newly created Formattable* object, or NULL
|
|
|
|
* on failure. The caller owns this and should
|
|
|
|
* delete it when done.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual void parseObject(const UnicodeString& source,
|
|
|
|
Formattable& result,
|
|
|
|
ParsePosition& parse_pos) const;
|
|
|
|
|
|
|
|
/**
|
2001-11-14 01:55:08 +00:00
|
|
|
* Format a double number. These methods call the NumberFormat
|
1999-12-28 23:57:50 +00:00
|
|
|
* pure virtual format() methods with the default FieldPosition.
|
|
|
|
*
|
|
|
|
* @param number The value to be formatted.
|
2002-11-23 01:11:50 +00:00
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
UnicodeString& format( double number,
|
2002-11-23 01:11:50 +00:00
|
|
|
UnicodeString& appendTo) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2001-11-14 01:55:08 +00:00
|
|
|
/**
|
|
|
|
* Format a long number. These methods call the NumberFormat
|
|
|
|
* pure virtual format() methods with the default FieldPosition.
|
|
|
|
*
|
|
|
|
* @param number The value to be formatted.
|
2002-11-23 01:11:50 +00:00
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
2001-11-14 01:55:08 +00:00
|
|
|
*/
|
1999-12-28 23:57:50 +00:00
|
|
|
UnicodeString& format( int32_t number,
|
2002-11-23 01:11:50 +00:00
|
|
|
UnicodeString& appendTo) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2003-10-31 22:47:25 +00:00
|
|
|
/**
|
|
|
|
* Format an int64 number. These methods call the NumberFormat
|
|
|
|
* pure virtual format() methods with the default FieldPosition.
|
|
|
|
*
|
|
|
|
* @param number The value to be formatted.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
2005-06-22 23:38:06 +00:00
|
|
|
* @stable ICU 2.8
|
2003-10-31 22:47:25 +00:00
|
|
|
*/
|
|
|
|
UnicodeString& format( int64_t number,
|
|
|
|
UnicodeString& appendTo) const;
|
|
|
|
|
2002-11-23 01:11:50 +00:00
|
|
|
/**
|
|
|
|
* Format a double number. Concrete subclasses must implement
|
|
|
|
* these pure virtual methods.
|
|
|
|
*
|
|
|
|
* @param number The value to be formatted.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param pos On input: an alignment field, if desired.
|
|
|
|
* On output: the offsets of the alignment field.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
2002-11-23 01:11:50 +00:00
|
|
|
*/
|
1999-12-28 23:57:50 +00:00
|
|
|
virtual UnicodeString& format(double number,
|
2002-11-23 01:11:50 +00:00
|
|
|
UnicodeString& appendTo,
|
1999-12-28 23:57:50 +00:00
|
|
|
FieldPosition& pos) const = 0;
|
2012-10-12 19:52:43 +00:00
|
|
|
/**
|
|
|
|
* Format a double number. By default, the parent function simply
|
|
|
|
* calls the base class and does not return an error status.
|
|
|
|
* Therefore, the status may be ignored in some subclasses.
|
|
|
|
*
|
|
|
|
* @param number The value to be formatted.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param pos On input: an alignment field, if desired.
|
|
|
|
* On output: the offsets of the alignment field.
|
|
|
|
* @param status error status
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
virtual UnicodeString& format(double number,
|
|
|
|
UnicodeString& appendTo,
|
|
|
|
FieldPosition& pos,
|
|
|
|
UErrorCode &status) const;
|
2009-12-17 22:15:20 +00:00
|
|
|
/**
|
|
|
|
* Format a double number. Subclasses must implement
|
|
|
|
* this method.
|
|
|
|
*
|
|
|
|
* @param number The value to be formatted.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param posIter On return, can be used to iterate over positions
|
|
|
|
* of fields generated by this format call.
|
2010-01-28 19:39:24 +00:00
|
|
|
* Can be NULL.
|
2009-12-17 22:15:20 +00:00
|
|
|
* @param status Output param filled with success/failure status.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable 4.4
|
2009-12-17 22:15:20 +00:00
|
|
|
*/
|
|
|
|
virtual UnicodeString& format(double number,
|
|
|
|
UnicodeString& appendTo,
|
2010-01-28 19:39:24 +00:00
|
|
|
FieldPositionIterator* posIter,
|
2009-12-17 22:15:20 +00:00
|
|
|
UErrorCode& status) const;
|
2002-11-23 01:11:50 +00:00
|
|
|
/**
|
|
|
|
* Format a long number. Concrete subclasses must implement
|
|
|
|
* these pure virtual methods.
|
|
|
|
*
|
|
|
|
* @param number The value to be formatted.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param pos On input: an alignment field, if desired.
|
|
|
|
* On output: the offsets of the alignment field.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
2001-11-14 01:55:08 +00:00
|
|
|
*/
|
1999-12-28 23:57:50 +00:00
|
|
|
virtual UnicodeString& format(int32_t number,
|
2002-11-23 01:11:50 +00:00
|
|
|
UnicodeString& appendTo,
|
1999-12-28 23:57:50 +00:00
|
|
|
FieldPosition& pos) const = 0;
|
|
|
|
|
2012-10-12 19:52:43 +00:00
|
|
|
/**
|
|
|
|
* Format a long number. Concrete subclasses may override
|
|
|
|
* this function to provide status return.
|
|
|
|
*
|
|
|
|
* @param number The value to be formatted.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param pos On input: an alignment field, if desired.
|
|
|
|
* On output: the offsets of the alignment field.
|
|
|
|
* @param status the output status.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
virtual UnicodeString& format(int32_t number,
|
|
|
|
UnicodeString& appendTo,
|
|
|
|
FieldPosition& pos,
|
|
|
|
UErrorCode &status) const;
|
|
|
|
|
2009-12-17 22:15:20 +00:00
|
|
|
/**
|
|
|
|
* Format an int32 number. Subclasses must implement
|
|
|
|
* this method.
|
|
|
|
*
|
|
|
|
* @param number The value to be formatted.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param posIter On return, can be used to iterate over positions
|
|
|
|
* of fields generated by this format call.
|
2010-01-28 19:39:24 +00:00
|
|
|
* Can be NULL.
|
2009-12-17 22:15:20 +00:00
|
|
|
* @param status Output param filled with success/failure status.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable 4.4
|
2009-12-17 22:15:20 +00:00
|
|
|
*/
|
|
|
|
virtual UnicodeString& format(int32_t number,
|
|
|
|
UnicodeString& appendTo,
|
2010-01-28 19:39:24 +00:00
|
|
|
FieldPositionIterator* posIter,
|
2009-12-17 22:15:20 +00:00
|
|
|
UErrorCode& status) const;
|
2003-10-31 22:47:25 +00:00
|
|
|
/**
|
|
|
|
* Format an int64 number. (Not abstract to retain compatibility
|
2004-11-11 23:34:58 +00:00
|
|
|
* with earlier releases, however subclasses should override this
|
|
|
|
* method as it just delegates to format(int32_t number...);
|
2003-10-31 22:47:25 +00:00
|
|
|
*
|
|
|
|
* @param number The value to be formatted.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param pos On input: an alignment field, if desired.
|
|
|
|
* On output: the offsets of the alignment field.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
2005-06-22 23:38:06 +00:00
|
|
|
* @stable ICU 2.8
|
2003-10-31 22:47:25 +00:00
|
|
|
*/
|
|
|
|
virtual UnicodeString& format(int64_t number,
|
|
|
|
UnicodeString& appendTo,
|
|
|
|
FieldPosition& pos) const;
|
2012-10-12 19:52:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Format an int64 number. (Not abstract to retain compatibility
|
|
|
|
* with earlier releases, however subclasses should override this
|
|
|
|
* method as it just delegates to format(int32_t number...);
|
|
|
|
*
|
|
|
|
* @param number The value to be formatted.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param pos On input: an alignment field, if desired.
|
|
|
|
* On output: the offsets of the alignment field.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
virtual UnicodeString& format(int64_t number,
|
|
|
|
UnicodeString& appendTo,
|
|
|
|
FieldPosition& pos,
|
|
|
|
UErrorCode& status) const;
|
2009-12-17 22:15:20 +00:00
|
|
|
/**
|
|
|
|
* Format an int64 number. Subclasses must implement
|
|
|
|
* this method.
|
|
|
|
*
|
|
|
|
* @param number The value to be formatted.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param posIter On return, can be used to iterate over positions
|
|
|
|
* of fields generated by this format call.
|
2010-01-28 19:39:24 +00:00
|
|
|
* Can be NULL.
|
2009-12-17 22:15:20 +00:00
|
|
|
* @param status Output param filled with success/failure status.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable 4.4
|
2009-12-17 22:15:20 +00:00
|
|
|
*/
|
|
|
|
virtual UnicodeString& format(int64_t number,
|
|
|
|
UnicodeString& appendTo,
|
2010-01-28 19:39:24 +00:00
|
|
|
FieldPositionIterator* posIter,
|
2009-12-17 22:15:20 +00:00
|
|
|
UErrorCode& status) const;
|
2010-01-15 22:28:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Format a decimal number. Subclasses must implement
|
|
|
|
* this method. The syntax of the unformatted number is a "numeric string"
|
|
|
|
* as defined in the Decimal Arithmetic Specification, available at
|
|
|
|
* http://speleotrove.com/decimal
|
|
|
|
*
|
|
|
|
* @param number The unformatted number, as a string, to be formatted.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param posIter On return, can be used to iterate over positions
|
|
|
|
* of fields generated by this format call.
|
2010-01-28 19:39:24 +00:00
|
|
|
* Can be NULL.
|
2010-01-15 22:28:39 +00:00
|
|
|
* @param status Output param filled with success/failure status.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable 4.4
|
2010-01-15 22:28:39 +00:00
|
|
|
*/
|
|
|
|
virtual UnicodeString& format(const StringPiece &number,
|
|
|
|
UnicodeString& appendTo,
|
2010-01-28 19:39:24 +00:00
|
|
|
FieldPositionIterator* posIter,
|
2010-01-15 22:28:39 +00:00
|
|
|
UErrorCode& status) const;
|
2010-02-26 02:29:00 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Format a decimal number.
|
|
|
|
* The number is a DigitList wrapper onto a floating point decimal number.
|
|
|
|
* The default implementation in NumberFormat converts the decimal number
|
|
|
|
* to a double and formats that. Subclasses of NumberFormat that want
|
|
|
|
* to specifically handle big decimal numbers must override this method.
|
|
|
|
* class DecimalFormat does so.
|
|
|
|
*
|
|
|
|
* @param number The number, a DigitList format Decimal Floating Point.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param posIter On return, can be used to iterate over positions
|
|
|
|
* of fields generated by this format call.
|
|
|
|
* @param status Output param filled with success/failure status.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
virtual UnicodeString& format(const DigitList &number,
|
|
|
|
UnicodeString& appendTo,
|
|
|
|
FieldPositionIterator* posIter,
|
|
|
|
UErrorCode& status) const;
|
2010-01-15 22:28:39 +00:00
|
|
|
|
2010-02-26 02:29:00 +00:00
|
|
|
/**
|
|
|
|
* Format a decimal number.
|
|
|
|
* The number is a DigitList wrapper onto a floating point decimal number.
|
|
|
|
* The default implementation in NumberFormat converts the decimal number
|
|
|
|
* to a double and formats that. Subclasses of NumberFormat that want
|
|
|
|
* to specifically handle big decimal numbers must override this method.
|
|
|
|
* class DecimalFormat does so.
|
|
|
|
*
|
|
|
|
* @param number The number, a DigitList format Decimal Floating Point.
|
|
|
|
* @param appendTo Output parameter to receive result.
|
|
|
|
* Result is appended to existing contents.
|
|
|
|
* @param pos On input: an alignment field, if desired.
|
|
|
|
* On output: the offsets of the alignment field.
|
|
|
|
* @param status Output param filled with success/failure status.
|
|
|
|
* @return Reference to 'appendTo' parameter.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
virtual UnicodeString& format(const DigitList &number,
|
|
|
|
UnicodeString& appendTo,
|
|
|
|
FieldPosition& pos,
|
|
|
|
UErrorCode& status) const;
|
|
|
|
|
|
|
|
public:
|
2010-01-15 22:28:39 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Return a long if possible (e.g. within range LONG_MAX,
|
|
|
|
* LONG_MAX], and with no decimals), otherwise a double. If
|
|
|
|
* IntegerOnly is set, will stop at a decimal point (or equivalent;
|
|
|
|
* e.g. for rational numbers "1 2/3", will stop after the 1).
|
|
|
|
* <P>
|
|
|
|
* If no object can be parsed, index is unchanged, and NULL is
|
|
|
|
* returned.
|
|
|
|
* <P>
|
|
|
|
* This is a pure virtual which concrete subclasses must implement.
|
|
|
|
*
|
|
|
|
* @param text The text to be parsed.
|
|
|
|
* @param result Formattable to be set to the parse result.
|
|
|
|
* If parse fails, return contents are undefined.
|
|
|
|
* @param parsePosition The position to start parsing at on input.
|
|
|
|
* On output, moved to after the last successfully
|
|
|
|
* parse character. On parse failure, does not change.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual void parse(const UnicodeString& text,
|
|
|
|
Formattable& result,
|
|
|
|
ParsePosition& parsePosition) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse a string as a numeric value, and return a Formattable
|
|
|
|
* numeric object. This method parses integers only if IntegerOnly
|
|
|
|
* is set.
|
|
|
|
*
|
|
|
|
* @param text The text to be parsed.
|
|
|
|
* @param result Formattable to be set to the parse result.
|
|
|
|
* If parse fails, return contents are undefined.
|
2003-06-09 06:13:14 +00:00
|
|
|
* @param status Output parameter set to a failure error code
|
|
|
|
* when a failure occurs.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @see NumberFormat::isParseIntegerOnly
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2012-10-08 22:41:13 +00:00
|
|
|
virtual void parse(const UnicodeString& text,
|
|
|
|
Formattable& result,
|
|
|
|
UErrorCode& status) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2004-04-15 06:20:42 +00:00
|
|
|
/**
|
|
|
|
* Parses text from the given string as a currency amount. Unlike
|
|
|
|
* the parse() method, this method will attempt to parse a generic
|
|
|
|
* currency name, searching for a match of this object's locale's
|
|
|
|
* currency display names, or for a 3-letter ISO currency code.
|
|
|
|
* This method will fail if this format is not a currency format,
|
|
|
|
* that is, if it does not contain the currency pattern symbol
|
|
|
|
* (U+00A4) in its prefix or suffix.
|
|
|
|
*
|
|
|
|
* @param text the string to parse
|
2012-02-19 06:45:47 +00:00
|
|
|
* @param pos input-output position; on input, the position within text
|
|
|
|
* to match; must have 0 <= pos.getIndex() < text.length();
|
|
|
|
* on output, the position after the last matched character.
|
|
|
|
* If the parse fails, the position in unchanged upon output.
|
|
|
|
* @return if parse succeeds, a pointer to a newly-created CurrencyAmount
|
|
|
|
* object (owned by the caller) containing information about
|
|
|
|
* the parsed currency; if parse fails, this is NULL.
|
2013-02-22 20:15:50 +00:00
|
|
|
* @stable ICU 49
|
2012-02-19 06:45:47 +00:00
|
|
|
*/
|
|
|
|
virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
|
|
|
|
ParsePosition& pos) const;
|
2004-04-15 06:20:42 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Return true if this format will parse numbers as integers
|
|
|
|
* only. For example in the English locale, with ParseIntegerOnly
|
|
|
|
* true, the string "1234." would be parsed as the integer value
|
|
|
|
* 1234 and parsing would stop at the "." character. Of course,
|
|
|
|
* the exact format accepted by the parse operation is locale
|
|
|
|
* dependant and determined by sub-classes of NumberFormat.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @return true if this format will parse numbers as integers
|
2004-08-24 17:38:33 +00:00
|
|
|
* only.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool isParseIntegerOnly(void) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether or not numbers should be parsed as integers only.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @param value set True, this format will parse numbers as integers
|
|
|
|
* only.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @see isParseIntegerOnly
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
virtual void setParseIntegerOnly(UBool value);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2011-05-04 12:23:42 +00:00
|
|
|
/**
|
|
|
|
* Sets whether lenient parsing should be enabled (it is off by default).
|
|
|
|
*
|
|
|
|
* @param enable <code>TRUE</code> if lenient parsing should be used,
|
|
|
|
* <code>FALSE</code> otherwise.
|
2012-02-20 04:28:17 +00:00
|
|
|
* @stable ICU 4.8
|
2011-05-04 12:23:42 +00:00
|
|
|
*/
|
|
|
|
virtual void setLenient(UBool enable);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether lenient parsing is enabled (it is off by default).
|
|
|
|
*
|
|
|
|
* @return <code>TRUE</code> if lenient parsing is enabled,
|
|
|
|
* <code>FALSE</code> otherwise.
|
|
|
|
* @see #setLenient
|
2012-02-20 04:28:17 +00:00
|
|
|
* @stable ICU 4.8
|
2011-05-04 12:23:42 +00:00
|
|
|
*/
|
|
|
|
virtual UBool isLenient(void) const;
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Returns the default number format for the current default
|
|
|
|
* locale. The default format is one of the styles provided by
|
|
|
|
* the other factory methods: getNumberInstance,
|
|
|
|
* getCurrencyInstance or getPercentInstance. Exactly which one
|
|
|
|
* is locale dependant.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static NumberFormat* U_EXPORT2 createInstance(UErrorCode&);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the default number format for the specified locale.
|
|
|
|
* The default format is one of the styles provided by the other
|
|
|
|
* factory methods: getNumberInstance, getCurrencyInstance or
|
|
|
|
* getPercentInstance. Exactly which one is locale dependant.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @param inLocale the given locale.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static NumberFormat* U_EXPORT2 createInstance(const Locale& inLocale,
|
1999-12-28 23:57:50 +00:00
|
|
|
UErrorCode&);
|
|
|
|
|
2009-02-12 22:55:29 +00:00
|
|
|
/**
|
|
|
|
* Creates the specified decimal format style of the desired locale.
|
|
|
|
* @param desiredLocale the given locale.
|
2011-04-29 00:00:47 +00:00
|
|
|
* @param style the given style.
|
|
|
|
* @param errorCode Output param filled with success/failure status.
|
2009-02-12 22:55:29 +00:00
|
|
|
* @return A new NumberFormat instance.
|
2012-02-20 04:28:17 +00:00
|
|
|
* @stable ICU 4.8
|
2009-02-12 22:55:29 +00:00
|
|
|
*/
|
2011-04-29 00:00:47 +00:00
|
|
|
static NumberFormat* U_EXPORT2 createInstance(const Locale& desiredLocale,
|
|
|
|
UNumberFormatStyle style,
|
|
|
|
UErrorCode& errorCode);
|
2009-02-12 22:55:29 +00:00
|
|
|
|
2014-02-10 19:13:50 +00:00
|
|
|
#ifndef U_HIDE_INTERNAL_API
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ICU use only.
|
|
|
|
* Creates NumberFormat instance without using the cache.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
static NumberFormat* internalCreateInstance(
|
|
|
|
const Locale& desiredLocale,
|
|
|
|
UNumberFormatStyle style,
|
|
|
|
UErrorCode& errorCode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ICU use only.
|
|
|
|
* Returns handle to the shared, cached NumberFormat instance for given
|
|
|
|
* locale. On success, caller must call removeRef() on returned value
|
|
|
|
* once it is done with the shared instance.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
static const SharedNumberFormat* U_EXPORT2 createSharedInstance(
|
|
|
|
const Locale& inLocale, UNumberFormatStyle style, UErrorCode& status);
|
|
|
|
|
2014-09-16 08:09:06 +00:00
|
|
|
#endif /* U_HIDE_INTERNAL_API */
|
2014-02-10 19:13:50 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Returns a currency format for the current default locale.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static NumberFormat* U_EXPORT2 createCurrencyInstance(UErrorCode&);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a currency format for the specified locale.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @param inLocale the given locale.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static NumberFormat* U_EXPORT2 createCurrencyInstance(const Locale& inLocale,
|
1999-12-28 23:57:50 +00:00
|
|
|
UErrorCode&);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a percentage format for the current default locale.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static NumberFormat* U_EXPORT2 createPercentInstance(UErrorCode&);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a percentage format for the specified locale.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @param inLocale the given locale.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static NumberFormat* U_EXPORT2 createPercentInstance(const Locale& inLocale,
|
1999-12-28 23:57:50 +00:00
|
|
|
UErrorCode&);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a scientific format for the current default locale.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static NumberFormat* U_EXPORT2 createScientificInstance(UErrorCode&);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a scientific format for the specified locale.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @param inLocale the given locale.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static NumberFormat* U_EXPORT2 createScientificInstance(const Locale& inLocale,
|
1999-12-28 23:57:50 +00:00
|
|
|
UErrorCode&);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the set of Locales for which NumberFormats are installed.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @param count Output param to receive the size of the locales
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2004-07-18 01:37:13 +00:00
|
|
|
#if !UCONFIG_NO_SERVICE
|
2003-02-25 23:36:48 +00:00
|
|
|
/**
|
|
|
|
* Register a new NumberFormatFactory. The factory will be adopted.
|
2014-02-12 23:37:47 +00:00
|
|
|
* Because ICU may choose to cache NumberFormat objects internally,
|
|
|
|
* this must be called at application startup, prior to any calls to
|
|
|
|
* NumberFormat::createInstance to avoid undefined behavior.
|
2003-02-25 23:36:48 +00:00
|
|
|
* @param toAdopt the NumberFormatFactory instance to be adopted
|
|
|
|
* @param status the in/out status code, no special meanings are assigned
|
|
|
|
* @return a registry key that can be used to unregister this factory
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-02-25 23:36:48 +00:00
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static URegistryKey U_EXPORT2 registerFactory(NumberFormatFactory* toAdopt, UErrorCode& status);
|
2003-02-25 23:36:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregister a previously-registered NumberFormatFactory using the key returned from the
|
|
|
|
* register call. Key becomes invalid after a successful call and should not be used again.
|
|
|
|
* The NumberFormatFactory corresponding to the key will be deleted.
|
2014-02-12 23:37:47 +00:00
|
|
|
* Because ICU may choose to cache NumberFormat objects internally,
|
|
|
|
* this should be called during application shutdown, after all calls to
|
|
|
|
* NumberFormat::createInstance to avoid undefined behavior.
|
2003-02-25 23:36:48 +00:00
|
|
|
* @param key the registry key returned by a previous call to registerFactory
|
|
|
|
* @param status the in/out status code, no special meanings are assigned
|
|
|
|
* @return TRUE if the factory for the key was successfully unregistered
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-02-25 23:36:48 +00:00
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
|
2003-02-25 23:36:48 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:38:33 +00:00
|
|
|
* Return a StringEnumeration over the locales available at the time of the call,
|
2003-02-25 23:36:48 +00:00
|
|
|
* including registered locales.
|
|
|
|
* @return a StringEnumeration over the locales available at the time of the call
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-02-25 23:36:48 +00:00
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
|
2004-07-18 01:37:13 +00:00
|
|
|
#endif /* UCONFIG_NO_SERVICE */
|
2003-02-25 23:36:48 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Returns true if grouping is used in this format. For example,
|
|
|
|
* in the English locale, with grouping on, the number 1234567
|
|
|
|
* might be formatted as "1,234,567". The grouping separator as
|
|
|
|
* well as the size of each group is locale dependant and is
|
|
|
|
* determined by sub-classes of NumberFormat.
|
|
|
|
* @see setGroupingUsed
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool isGroupingUsed(void) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set whether or not grouping will be used in this format.
|
2004-08-24 17:38:33 +00:00
|
|
|
* @param newValue True, grouping will be used in this format.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @see getGroupingUsed
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
virtual void setGroupingUsed(UBool newValue);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the maximum number of digits allowed in the integer portion of a
|
|
|
|
* number.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @return the maximum number of digits allowed in the integer portion of a
|
|
|
|
* number.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @see setMaximumIntegerDigits
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
int32_t getMaximumIntegerDigits(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the maximum number of digits allowed in the integer portion of a
|
|
|
|
* number. maximumIntegerDigits must be >= minimumIntegerDigits. If the
|
|
|
|
* new value for maximumIntegerDigits is less than the current value
|
|
|
|
* of minimumIntegerDigits, then minimumIntegerDigits will also be set to
|
|
|
|
* the new value.
|
|
|
|
*
|
2004-08-24 17:38:33 +00:00
|
|
|
* @param newValue the new value for the maximum number of digits
|
2002-07-01 11:04:45 +00:00
|
|
|
* allowed in the integer portion of a number.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @see getMaximumIntegerDigits
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual void setMaximumIntegerDigits(int32_t newValue);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the minimum number of digits allowed in the integer portion of a
|
|
|
|
* number.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @return the minimum number of digits allowed in the integer portion of a
|
|
|
|
* number.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @see setMinimumIntegerDigits
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
int32_t getMinimumIntegerDigits(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the minimum number of digits allowed in the integer portion of a
|
|
|
|
* number. minimumIntegerDigits must be <= maximumIntegerDigits. If the
|
|
|
|
* new value for minimumIntegerDigits exceeds the current value
|
|
|
|
* of maximumIntegerDigits, then maximumIntegerDigits will also be set to
|
|
|
|
* the new value.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @param newValue the new value to be set.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @see getMinimumIntegerDigits
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual void setMinimumIntegerDigits(int32_t newValue);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the maximum number of digits allowed in the fraction portion of a
|
|
|
|
* number.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @return the maximum number of digits allowed in the fraction portion of a
|
|
|
|
* number.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @see setMaximumFractionDigits
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
int32_t getMaximumFractionDigits(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the maximum number of digits allowed in the fraction portion of a
|
|
|
|
* number. maximumFractionDigits must be >= minimumFractionDigits. If the
|
|
|
|
* new value for maximumFractionDigits is less than the current value
|
|
|
|
* of minimumFractionDigits, then minimumFractionDigits will also be set to
|
|
|
|
* the new value.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @param newValue the new value to be set.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @see getMaximumFractionDigits
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual void setMaximumFractionDigits(int32_t newValue);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the minimum number of digits allowed in the fraction portion of a
|
|
|
|
* number.
|
2002-07-01 11:04:45 +00:00
|
|
|
* @return the minimum number of digits allowed in the fraction portion of a
|
|
|
|
* number.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @see setMinimumFractionDigits
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
int32_t getMinimumFractionDigits(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the minimum number of digits allowed in the fraction portion of a
|
|
|
|
* number. minimumFractionDigits must be <= maximumFractionDigits. If the
|
|
|
|
* new value for minimumFractionDigits exceeds the current value
|
|
|
|
* of maximumFractionDigits, then maximumIntegerDigits will also be set to
|
|
|
|
* the new value
|
2002-07-01 11:04:45 +00:00
|
|
|
* @param newValue the new value to be set.
|
1999-12-28 23:57:50 +00:00
|
|
|
* @see getMinimumFractionDigits
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
virtual void setMinimumFractionDigits(int32_t newValue);
|
|
|
|
|
2003-04-24 22:58:04 +00:00
|
|
|
/**
|
|
|
|
* Sets the currency used to display currency
|
|
|
|
* amounts. This takes effect immediately, if this format is a
|
|
|
|
* currency format. If this format is not a currency format, then
|
|
|
|
* the currency is used if and when this object becomes a
|
|
|
|
* currency format.
|
|
|
|
* @param theCurrency a 3-letter ISO code indicating new currency
|
|
|
|
* to use. It need not be null-terminated. May be the empty
|
|
|
|
* string or NULL to indicate no currency.
|
2004-02-13 01:56:38 +00:00
|
|
|
* @param ec input-output error code
|
2006-07-31 20:52:01 +00:00
|
|
|
* @stable ICU 3.0
|
2003-04-24 22:58:04 +00:00
|
|
|
*/
|
2004-02-13 01:56:38 +00:00
|
|
|
virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
|
2003-04-24 22:58:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the currency used to display currency
|
|
|
|
* amounts. This may be an empty string for some subclasses.
|
|
|
|
* @return a 3-letter null-terminated ISO code indicating
|
|
|
|
* the currency in use, or a pointer to the empty string.
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-04-24 22:58:04 +00:00
|
|
|
*/
|
|
|
|
const UChar* getCurrency() const;
|
2014-06-12 21:40:34 +00:00
|
|
|
|
2014-01-14 07:31:30 +00:00
|
|
|
/* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */
|
|
|
|
/**
|
|
|
|
* Set a particular UDisplayContext value in the formatter, such as
|
|
|
|
* UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
|
|
|
|
* @param value The UDisplayContext value to set.
|
|
|
|
* @param status Input/output status. If at entry this indicates a failure
|
|
|
|
* status, the function will do nothing; otherwise this will be
|
|
|
|
* updated with any new status from the function.
|
|
|
|
* @draft ICU 53
|
|
|
|
*/
|
|
|
|
virtual void setContext(UDisplayContext value, UErrorCode& status);
|
|
|
|
|
|
|
|
/* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */
|
|
|
|
/**
|
|
|
|
* Get the formatter's UDisplayContext value for the specified UDisplayContextType,
|
|
|
|
* such as UDISPCTX_TYPE_CAPITALIZATION.
|
|
|
|
* @param type The UDisplayContextType whose value to return
|
|
|
|
* @param status Input/output status. If at entry this indicates a failure
|
|
|
|
* status, the function will do nothing; otherwise this will be
|
|
|
|
* updated with any new status from the function.
|
|
|
|
* @return The UDisplayContextValue for the specified type.
|
|
|
|
* @draft ICU 53
|
|
|
|
*/
|
|
|
|
virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const;
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
public:
|
|
|
|
|
2004-05-28 20:13:11 +00:00
|
|
|
/**
|
|
|
|
* Return the class ID for this class. This is useful for
|
|
|
|
* comparing to a return value from getDynamicClassID(). Note that,
|
|
|
|
* because NumberFormat is an abstract base class, no fully constructed object
|
|
|
|
* will have the class ID returned by NumberFormat::getStaticClassID().
|
|
|
|
* @return The class ID for all objects of this class.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static UClassID U_EXPORT2 getStaticClassID(void);
|
2004-05-28 20:13:11 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
/**
|
|
|
|
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override.
|
|
|
|
* This method is to implement a simple version of RTTI, since not all
|
|
|
|
* C++ compilers support genuine RTTI. Polymorphic operator==() and
|
|
|
|
* clone() methods call this method.
|
|
|
|
* <P>
|
|
|
|
* @return The class ID for this object. All objects of a
|
|
|
|
* given class have the same class ID. Objects of
|
|
|
|
* other classes have different class IDs.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
2004-06-04 01:16:05 +00:00
|
|
|
virtual UClassID getDynamicClassID(void) const = 0;
|
1999-12-28 23:57:50 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default constructor for subclass use only.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
NumberFormat();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy constructor.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
NumberFormat(const NumberFormat&);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assignment operator.
|
2002-12-04 23:46:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:57:50 +00:00
|
|
|
*/
|
|
|
|
NumberFormat& operator=(const NumberFormat&);
|
|
|
|
|
2004-03-25 02:23:52 +00:00
|
|
|
/**
|
2004-04-15 06:20:42 +00:00
|
|
|
* Returns the currency in effect for this formatter. Subclasses
|
|
|
|
* should override this method as needed. Unlike getCurrency(),
|
|
|
|
* this method should never return "".
|
|
|
|
* @result output parameter for null-terminated result, which must
|
|
|
|
* have a capacity of at least 4
|
2004-03-25 02:23:52 +00:00
|
|
|
* @internal
|
|
|
|
*/
|
2004-04-15 06:20:42 +00:00
|
|
|
virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
|
2004-03-25 02:23:52 +00:00
|
|
|
|
2013-03-05 01:38:48 +00:00
|
|
|
#ifndef U_HIDE_INTERNAL_API
|
2012-11-14 18:49:38 +00:00
|
|
|
/**
|
|
|
|
* Creates the specified number format style of the desired locale.
|
|
|
|
* If mustBeDecimalFormat is TRUE, then the returned pointer is
|
|
|
|
* either a DecimalFormat or it is NULL.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
static NumberFormat* makeInstance(const Locale& desiredLocale,
|
|
|
|
UNumberFormatStyle style,
|
|
|
|
UBool mustBeDecimalFormat,
|
|
|
|
UErrorCode& errorCode);
|
2013-03-05 01:38:48 +00:00
|
|
|
#endif /* U_HIDE_INTERNAL_API */
|
2012-11-14 18:49:38 +00:00
|
|
|
|
2003-11-21 08:09:14 +00:00
|
|
|
private:
|
|
|
|
|
2011-04-29 00:00:47 +00:00
|
|
|
static UBool isStyleSupported(UNumberFormatStyle style);
|
|
|
|
|
2003-02-25 23:36:48 +00:00
|
|
|
/**
|
|
|
|
* Creates the specified decimal format style of the desired locale.
|
|
|
|
* @param desiredLocale the given locale.
|
2011-04-29 00:00:47 +00:00
|
|
|
* @param style the given style.
|
|
|
|
* @param errorCode Output param filled with success/failure status.
|
2003-02-25 23:36:48 +00:00
|
|
|
* @return A new NumberFormat instance.
|
|
|
|
*/
|
2011-04-29 00:00:47 +00:00
|
|
|
static NumberFormat* makeInstance(const Locale& desiredLocale,
|
|
|
|
UNumberFormatStyle style,
|
|
|
|
UErrorCode& errorCode);
|
1999-12-28 23:57:50 +00:00
|
|
|
|
2014-01-14 07:31:30 +00:00
|
|
|
UBool fGroupingUsed;
|
1999-12-28 23:57:50 +00:00
|
|
|
int32_t fMaxIntegerDigits;
|
|
|
|
int32_t fMinIntegerDigits;
|
|
|
|
int32_t fMaxFractionDigits;
|
|
|
|
int32_t fMinFractionDigits;
|
2013-09-17 21:56:23 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static const int32_t gDefaultMaxIntegerDigits;
|
|
|
|
static const int32_t gDefaultMinIntegerDigits;
|
|
|
|
|
|
|
|
private:
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool fParseIntegerOnly;
|
2011-05-04 12:23:42 +00:00
|
|
|
UBool fLenient; // TRUE => lenient parse is enabled
|
2003-02-25 23:36:48 +00:00
|
|
|
|
2003-04-24 22:58:04 +00:00
|
|
|
// ISO currency code
|
2004-02-13 01:56:38 +00:00
|
|
|
UChar fCurrency[4];
|
2003-04-24 22:58:04 +00:00
|
|
|
|
2014-01-14 07:31:30 +00:00
|
|
|
UDisplayContext fCapitalizationContext;
|
|
|
|
|
2011-04-29 00:00:47 +00:00
|
|
|
friend class ICUNumberFormatFactory; // access to makeInstance
|
2003-08-31 20:53:46 +00:00
|
|
|
friend class ICUNumberFormatService;
|
2011-04-29 00:00:47 +00:00
|
|
|
friend class ::NumberFormatTest; // access to isStyleSupported()
|
2003-02-25 23:36:48 +00:00
|
|
|
};
|
|
|
|
|
2004-07-18 01:37:13 +00:00
|
|
|
#if !UCONFIG_NO_SERVICE
|
2003-02-25 23:36:48 +00:00
|
|
|
/**
|
|
|
|
* A NumberFormatFactory is used to register new number formats. The factory
|
|
|
|
* should be able to create any of the predefined formats for each locale it
|
|
|
|
* supports. When registered, the locales it supports extend or override the
|
|
|
|
* locale already supported by ICU.
|
|
|
|
*
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-02-25 23:36:48 +00:00
|
|
|
*/
|
|
|
|
class U_I18N_API NumberFormatFactory : public UObject {
|
|
|
|
public:
|
|
|
|
|
2004-04-08 19:11:25 +00:00
|
|
|
/**
|
|
|
|
* Destructor
|
2006-01-18 04:19:45 +00:00
|
|
|
* @stable ICU 3.0
|
2004-04-08 19:11:25 +00:00
|
|
|
*/
|
|
|
|
virtual ~NumberFormatFactory();
|
|
|
|
|
2003-02-25 23:36:48 +00:00
|
|
|
/**
|
|
|
|
* Return true if this factory will be visible. Default is true.
|
|
|
|
* If not visible, the locales supported by this factory will not
|
|
|
|
* be listed by getAvailableLocales.
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-02-25 23:36:48 +00:00
|
|
|
*/
|
|
|
|
virtual UBool visible(void) const = 0;
|
|
|
|
|
|
|
|
/**
|
2003-02-27 20:14:51 +00:00
|
|
|
* Return the locale names directly supported by this factory. The number of names
|
|
|
|
* is returned in count;
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-02-25 23:36:48 +00:00
|
|
|
*/
|
2003-09-15 21:09:21 +00:00
|
|
|
virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const = 0;
|
2003-02-25 23:36:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a number format of the appropriate type. If the locale
|
|
|
|
* is not supported, return null. If the locale is supported, but
|
|
|
|
* the type is not provided by this service, return null. Otherwise
|
|
|
|
* return an appropriate instance of NumberFormat.
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-02-25 23:36:48 +00:00
|
|
|
*/
|
|
|
|
virtual NumberFormat* createFormat(const Locale& loc, UNumberFormatStyle formatType) = 0;
|
|
|
|
};
|
|
|
|
|
2004-04-07 21:58:43 +00:00
|
|
|
/**
|
|
|
|
* A NumberFormatFactory that supports a single locale. It can be visible or invisible.
|
2006-01-18 04:19:45 +00:00
|
|
|
* @stable ICU 2.6
|
2004-04-07 21:58:43 +00:00
|
|
|
*/
|
2003-02-25 23:36:48 +00:00
|
|
|
class U_I18N_API SimpleNumberFormatFactory : public NumberFormatFactory {
|
|
|
|
protected:
|
2003-06-11 18:13:44 +00:00
|
|
|
/**
|
2003-06-10 17:41:46 +00:00
|
|
|
* True if the locale supported by this factory is visible.
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-06-10 17:41:46 +00:00
|
|
|
*/
|
2003-02-25 23:36:48 +00:00
|
|
|
const UBool _visible;
|
2003-06-10 17:41:46 +00:00
|
|
|
|
2003-06-11 18:13:44 +00:00
|
|
|
/**
|
2003-06-10 17:41:46 +00:00
|
|
|
* The locale supported by this factory, as a UnicodeString.
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-06-10 17:41:46 +00:00
|
|
|
*/
|
2003-02-27 20:14:51 +00:00
|
|
|
UnicodeString _id;
|
2003-02-25 23:36:48 +00:00
|
|
|
|
|
|
|
public:
|
2003-06-03 01:58:15 +00:00
|
|
|
/**
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-06-03 01:58:15 +00:00
|
|
|
*/
|
2004-08-31 21:14:59 +00:00
|
|
|
SimpleNumberFormatFactory(const Locale& locale, UBool visible = TRUE);
|
2003-02-25 23:36:48 +00:00
|
|
|
|
2004-04-07 05:20:22 +00:00
|
|
|
/**
|
2006-01-18 04:19:45 +00:00
|
|
|
* @stable ICU 3.0
|
2004-04-07 05:20:22 +00:00
|
|
|
*/
|
2004-04-07 21:58:43 +00:00
|
|
|
virtual ~SimpleNumberFormatFactory();
|
2004-04-07 05:20:22 +00:00
|
|
|
|
2003-06-03 01:58:15 +00:00
|
|
|
/**
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-06-03 01:58:15 +00:00
|
|
|
*/
|
2004-04-07 21:58:43 +00:00
|
|
|
virtual UBool visible(void) const;
|
2003-02-25 23:36:48 +00:00
|
|
|
|
2003-06-03 01:58:15 +00:00
|
|
|
/**
|
2004-11-03 01:25:51 +00:00
|
|
|
* @stable ICU 2.6
|
2003-06-03 01:58:15 +00:00
|
|
|
*/
|
2004-04-07 21:58:43 +00:00
|
|
|
virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const;
|
1999-12-28 23:57:50 +00:00
|
|
|
};
|
2004-07-18 01:37:13 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_SERVICE */
|
2003-02-25 23:36:48 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
// -------------------------------------
|
2001-03-22 00:09:10 +00:00
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool
|
1999-12-28 23:57:50 +00:00
|
|
|
NumberFormat::isParseIntegerOnly() const
|
|
|
|
{
|
|
|
|
return fParseIntegerOnly;
|
|
|
|
}
|
|
|
|
|
2011-05-04 12:23:42 +00:00
|
|
|
inline UBool
|
|
|
|
NumberFormat::isLenient() const
|
|
|
|
{
|
2012-02-19 06:45:47 +00:00
|
|
|
return fLenient;
|
2011-05-04 12:23:42 +00:00
|
|
|
}
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#endif // _NUMFMT
|
|
|
|
//eof
|