Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

NumberFormat Class Reference

Abstract base class for all number formats. More...

#include <numfmt.h>

Inheritance diagram for NumberFormat::

Format UObject UMemory ChoiceFormat DecimalFormat RuleBasedNumberFormat List of all members.

Public Types

enum  EAlignmentFields { kIntegerField, kFractionField, INTEGER_FIELD = kIntegerField, FRACTION_FIELD = kFractionField }
 Alignment Field constants used to construct a FieldPosition object. More...


Public Methods

virtual ~NumberFormat ()
 Destructor. More...

virtual UBool operator== (const Format &other) const
 Return true if the given Format objects are semantically equal. More...

virtual UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format an object to produce a string. More...

virtual void parseObject (const UnicodeString &source, Formattable &result, ParsePosition &parse_pos) const
 Parse a string to produce an object. More...

UnicodeStringformat (double number, UnicodeString &appendTo) const
 Format a double number. More...

UnicodeStringformat (int32_t number, UnicodeString &appendTo) const
 Format a long number. More...

UnicodeStringformat (int64_t number, UnicodeString &appendTo) const
 Format an int64 number. More...

virtual UnicodeStringformat (double number, UnicodeString &appendTo, FieldPosition &pos) const=0
 Format a double number. More...

virtual UnicodeStringformat (int32_t number, UnicodeString &appendTo, FieldPosition &pos) const=0
 Format a long number. More...

virtual UnicodeStringformat (int64_t number, UnicodeString &appendTo, FieldPosition &pos) const
 Format an int64 number. More...

UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
 Redeclared Format method. More...

virtual void parse (const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const=0
 Return a long if possible (e.g. More...

virtual void parse (const UnicodeString &text, Formattable &result, UErrorCode &status) const
 Parse a string as a numeric value, and return a Formattable numeric object. More...

UBool isParseIntegerOnly (void) const
 Return true if this format will parse numbers as integers only. More...

virtual void setParseIntegerOnly (UBool value)
 Sets whether or not numbers should be parsed as integers only. More...

UBool isGroupingUsed (void) const
 Returns true if grouping is used in this format. More...

virtual void setGroupingUsed (UBool newValue)
 Set whether or not grouping will be used in this format. More...

int32_t getMaximumIntegerDigits (void) const
 Returns the maximum number of digits allowed in the integer portion of a number. More...

virtual void setMaximumIntegerDigits (int32_t newValue)
 Sets the maximum number of digits allowed in the integer portion of a number. More...

int32_t getMinimumIntegerDigits (void) const
 Returns the minimum number of digits allowed in the integer portion of a number. More...

virtual void setMinimumIntegerDigits (int32_t newValue)
 Sets the minimum number of digits allowed in the integer portion of a number. More...

int32_t getMaximumFractionDigits (void) const
 Returns the maximum number of digits allowed in the fraction portion of a number. More...

virtual void setMaximumFractionDigits (int32_t newValue)
 Sets the maximum number of digits allowed in the fraction portion of a number. More...

int32_t getMinimumFractionDigits (void) const
 Returns the minimum number of digits allowed in the fraction portion of a number. More...

virtual void setMinimumFractionDigits (int32_t newValue)
 Sets the minimum number of digits allowed in the fraction portion of a number. More...

virtual void setCurrency (const UChar *theCurrency)
 Sets the currency used to display currency amounts. More...

const UChar * getCurrency () const
 Gets the currency used to display currency amounts. More...

virtual Locale getLocale (ULocDataLocaleType type, UErrorCode &status) const
 Get the locale for this numeric format object. More...

virtual const char * getLocaleInternal (ULocDataLocaleType type, UErrorCode &status) const
 Get the locale for this numeric format object. More...

virtual UClassID getDynamicClassID (void) const=0
 Returns a unique class ID POLYMORPHICALLY. More...


Static Public Methods

NumberFormat * createInstance (UErrorCode &)
 Returns the default number format for the current default locale. More...

NumberFormat * createInstance (const Locale &inLocale, UErrorCode &)
 Returns the default number format for the specified locale. More...

NumberFormat * createCurrencyInstance (UErrorCode &)
 Returns a currency format for the current default locale. More...

NumberFormat * createCurrencyInstance (const Locale &inLocale, UErrorCode &)
 Returns a currency format for the specified locale. More...

NumberFormat * createPercentInstance (UErrorCode &)
 Returns a percentage format for the current default locale. More...

NumberFormat * createPercentInstance (const Locale &inLocale, UErrorCode &)
 Returns a percentage format for the specified locale. More...

NumberFormat * createScientificInstance (UErrorCode &)
 Returns a scientific format for the current default locale. More...

NumberFormat * createScientificInstance (const Locale &inLocale, UErrorCode &)
 Returns a scientific format for the specified locale. More...

const LocalegetAvailableLocales (int32_t &count)
 Get the set of Locales for which NumberFormats are installed. More...

URegistryKey registerFactory (NumberFormatFactory *toAdopt, UErrorCode &status)
 Register a new NumberFormatFactory. More...

UBool unregister (URegistryKey key, UErrorCode &status)
 Unregister a previously-registered NumberFormatFactory using the key returned from the register call. More...

StringEnumerationgetAvailableLocales (void)
 Return a StringEnumeration over the locales available at the time of the call, including registered locales. More...


Protected Methods

 NumberFormat ()
 Default constructor for subclass use only. More...

 NumberFormat (const NumberFormat &)
 Copy constructor. More...

NumberFormat & operator= (const NumberFormat &)
 Assignment operator. More...


Protected Attributes

char validLocale [50]
char actualLocale [50]

Private Types

enum  EStyles {
  kNumberStyle, kCurrencyStyle, kPercentStyle, kScientificStyle,
  kStyleCount
}

Static Private Methods

NumberFormat * createInstance (const Locale &desiredLocale, EStyles choice, UErrorCode &success)
 Creates the specified decimal format style of the desired locale. More...

NumberFormat * makeInstance (const Locale &desiredLocale, EStyles choice, UErrorCode &success)
 Creates the specified decimal format style of the desired locale. More...


Private Attributes

UBool fGroupingUsed
int32_t fMaxIntegerDigits
int32_t fMinIntegerDigits
int32_t fMaxFractionDigits
int32_t fMinFractionDigits
UBool fParseIntegerOnly
UChar currency [4]

Static Private Attributes

const int32_t fgMaxIntegerDigits
const int32_t fgMinIntegerDigits
const int32_t fgNumberPatternsCount
const UChar *const fgLastResortNumberPatterns []

Friends

class ICUNumberFormatFactory
class ICUNumberFormatService

Detailed Description

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.

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.

To format a number for the current Locale, use one of the static factory methods:

 
    double myNumber = 7.0;
    UnicodeString myString;
    UErrorCode success = U_ZERO_ERROR;
    NumberFormat* nf = NumberFormat::createInstance(success)
    nf->format(myNumber, myString);
    cout << " Example 1: " << myString << endl;
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.
 
     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 += " ; ";
     }
     cout << " Example 2: " << myString << endl;
 \endcide
 </PRE>
 To format a number for a different Locale, specify it in the
 call to createInstance().
 <PRE>
 \code
     nf = NumberFormat::createInstance( Locale::FRENCH, success );
You can use a NumberFormat to parse also.
 
    UErrorCode success;
    Formattable result(-999);  // initialized with error code
    nf->parse(myString, result, success);
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%.

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.

You can also use forms of the parse and format methods with ParsePosition and FieldPosition to allow you to:

For example, you can align numbers in two ways.

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.

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.

Stable:
ICU 2.0

Definition at line 133 of file numfmt.h.


Member Enumeration Documentation

enum NumberFormat::EAlignmentFields
 

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.

See also:
FieldPosition
Stable:
ICU 2.0
Enumeration values:
kIntegerField 
kFractionField 
INTEGER_FIELD  These constants are provided for backwards compatibility only.

Please use the C++ style constants defined above.

Stable:
ICU 2.0
FRACTION_FIELD 

Definition at line 144 of file numfmt.h.

enum NumberFormat::EStyles [private]
 

Enumeration values:
kNumberStyle 
kCurrencyStyle 
kPercentStyle 
kScientificStyle 
kStyleCount 

Definition at line 680 of file numfmt.h.


Constructor & Destructor Documentation

virtual NumberFormat::~NumberFormat   [virtual]
 

Destructor.

Stable:
ICU 2.0

NumberFormat::NumberFormat   [protected]
 

Default constructor for subclass use only.

Stable:
ICU 2.0

NumberFormat::NumberFormat const NumberFormat &    [protected]
 

Copy constructor.

Stable:
ICU 2.0


Member Function Documentation

NumberFormat* NumberFormat::createCurrencyInstance const Locale   inLocale,
UErrorCode  
[static]
 

Returns a currency format for the specified locale.

Parameters:
inLocale  the given locale.
Stable:
ICU 2.0

NumberFormat* NumberFormat::createCurrencyInstance UErrorCode   [static]
 

Returns a currency format for the current default locale.

Stable:
ICU 2.0

NumberFormat* NumberFormat::createInstance const Locale   desiredLocale,
EStyles    choice,
UErrorCode   success
[static, private]
 

Creates the specified decimal format style of the desired locale.

Hook for service registration, uses makeInstance directly if no services registered.

Parameters:
desiredLocale  the given locale.
choice  the given style.
success  Output param filled with success/failure status.
Returns:
A new NumberFormat instance.

NumberFormat* NumberFormat::createInstance const Locale   inLocale,
UErrorCode  
[static]
 

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.

Parameters:
inLocale  the given locale.
Stable:
ICU 2.0

NumberFormat* NumberFormat::createInstance UErrorCode   [static]
 

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.

Stable:
ICU 2.0

NumberFormat* NumberFormat::createPercentInstance const Locale   inLocale,
UErrorCode  
[static]
 

Returns a percentage format for the specified locale.

Parameters:
inLocale  the given locale.
Stable:
ICU 2.0

NumberFormat* NumberFormat::createPercentInstance UErrorCode   [static]
 

Returns a percentage format for the current default locale.

Stable:
ICU 2.0

NumberFormat* NumberFormat::createScientificInstance const Locale   inLocale,
UErrorCode  
[static]
 

Returns a scientific format for the specified locale.

Parameters:
inLocale  the given locale.
Stable:
ICU 2.0

NumberFormat* NumberFormat::createScientificInstance UErrorCode   [static]
 

Returns a scientific format for the current default locale.

Stable:
ICU 2.0

UnicodeString & NumberFormat::format const Formattable   obj,
UnicodeString   result,
UErrorCode   status
const [inline]
 

Redeclared Format method.

Parameters:
obj  The object to be formatted.
appendTo  Output parameter to receive result. Result is appended to existing contents.
status  Output parameter set to a failure error code when a failure occurs.
Returns:
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

Reimplemented from Format.

Reimplemented in ChoiceFormat, DecimalFormat, and RuleBasedNumberFormat.

Definition at line 819 of file numfmt.h.

virtual UnicodeString& NumberFormat::format int64_t    number,
UnicodeString   toAppendTo,
FieldPosition   pos
const [virtual]
 

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...);

Parameters:
number  The value to be formatted.
appendTo  Output parameter to receive result. Result is appended to existing contents.
pos  On input: an alignment field, if desired. On output: the offsets of the alignment field.
Returns:
Reference to 'appendTo' parameter.
Draft:
This API has been introduced in ICU 2.8. It is still in draft state and may be modified in a future release.

Reimplemented in ChoiceFormat, DecimalFormat, and RuleBasedNumberFormat.

virtual UnicodeString& NumberFormat::format int32_t    number,
UnicodeString   toAppendTo,
FieldPosition   pos
const [pure virtual]
 

Format a long number.

Concrete subclasses must implement these pure virtual methods.

Parameters:
number  The value to be formatted.
appendTo  Output parameter to receive result. Result is appended to existing contents.
pos  On input: an alignment field, if desired. On output: the offsets of the alignment field.
Returns:
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

Reimplemented in ChoiceFormat, DecimalFormat, and RuleBasedNumberFormat.

virtual UnicodeString& NumberFormat::format double    number,
UnicodeString   toAppendTo,
FieldPosition   pos
const [pure virtual]
 

Format a double number.

Concrete subclasses must implement these pure virtual methods.

Parameters:
number  The value to be formatted.
appendTo  Output parameter to receive result. Result is appended to existing contents.
pos  On input: an alignment field, if desired. On output: the offsets of the alignment field.
Returns:
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

Reimplemented in ChoiceFormat, DecimalFormat, and RuleBasedNumberFormat.

UnicodeString& NumberFormat::format int64_t    number,
UnicodeString   appendTo
const
 

Format an int64 number.

These methods call the NumberFormat pure virtual format() methods with the default FieldPosition.

Parameters:
number  The value to be formatted.
appendTo  Output parameter to receive result. Result is appended to existing contents.
Returns:
Reference to 'appendTo' parameter.
Draft:
This API has been introduced in ICU 2.8. It is still in draft state and may be modified in a future release.

Reimplemented in DecimalFormat.

UnicodeString& NumberFormat::format int32_t    number,
UnicodeString   output
const
 

Format a long number.

These methods call the NumberFormat pure virtual format() methods with the default FieldPosition.

Parameters:
number  The value to be formatted.
appendTo  Output parameter to receive result. Result is appended to existing contents.
Returns:
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

Reimplemented in ChoiceFormat, DecimalFormat, and RuleBasedNumberFormat.

UnicodeString& NumberFormat::format double    number,
UnicodeString   output
const
 

Format a double number.

These methods call the NumberFormat pure virtual format() methods with the default FieldPosition.

Parameters:
number  The value to be formatted.
appendTo  Output parameter to receive result. Result is appended to existing contents.
Returns:
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

Reimplemented in ChoiceFormat, DecimalFormat, and RuleBasedNumberFormat.

virtual UnicodeString& NumberFormat::format const Formattable   obj,
UnicodeString   toAppendTo,
FieldPosition   pos,
UErrorCode   status
const [virtual]
 

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.

Parameters:
obj  The object to format.
appendTo  Output parameter to receive result. Result is appended to existing contents.
pos  On input: an alignment field, if desired. On output: the offsets of the alignment field.
status  Output param filled with success/failure status.
Returns:
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

Reimplemented from Format.

Reimplemented in ChoiceFormat, DecimalFormat, and RuleBasedNumberFormat.

Referenced by RuleBasedNumberFormat::format(), DecimalFormat::format(), and ChoiceFormat::format().

StringEnumeration* NumberFormat::getAvailableLocales void    [static]
 

Return a StringEnumeration over the locales available at the time of the call, including registered locales.

Returns:
a StringEnumeration over the locales available at the time of the call
Draft:
This API has been introduced in ICU 2.6. It is still in draft state and may be modified in a future release.

const Locale* NumberFormat::getAvailableLocales int32_t &    numLocales [static]
 

Get the set of Locales for which NumberFormats are installed.

Parameters:
count  Output param to receive the size of the locales
Stable:
ICU 2.0

const UChar* NumberFormat::getCurrency   const
 

Gets the currency used to display currency amounts.

This may be an empty string for some subclasses.

Returns:
a 3-letter null-terminated ISO code indicating the currency in use, or a pointer to the empty string.
Draft:
This API has been introduced in ICU 2.6. It is still in draft state and may be modified in a future release.

virtual UClassID NumberFormat::getDynamicClassID void    const [pure virtual]
 

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.

Returns:
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.
Stable:
ICU 2.0

Reimplemented from Format.

Reimplemented in ChoiceFormat, DecimalFormat, and RuleBasedNumberFormat.

virtual Locale NumberFormat::getLocale ULocDataLocaleType    type,
UErrorCode   status
const [virtual]
 

Get the locale for this numeric format object.

You can choose between valid and actual locale.

Parameters:
type  type of the locale we're looking for (valid or actual)
status  error code for the operation
Returns:
the locale
Draft:
This API has been introduced in ICU 2.8. It is still in draft state and may be modified in a future release.

Reimplemented from Format.

virtual const char* NumberFormat::getLocaleInternal ULocDataLocaleType    type,
UErrorCode   status
const [virtual]
 

Get the locale for this numeric format object.

You can choose between valid and actual locale.

Parameters:
type  type of the locale we're looking for (valid or actual)
status  error code for the operation
Returns:
the locale
Internal:
For internal use only.

Reimplemented from Format.

int32_t NumberFormat::getMaximumFractionDigits void    const
 

Returns the maximum number of digits allowed in the fraction portion of a number.

Returns:
the maximum number of digits allowed in the fraction portion of a number.
See also:
setMaximumFractionDigits
Stable:
ICU 2.0

int32_t NumberFormat::getMaximumIntegerDigits void    const
 

Returns the maximum number of digits allowed in the integer portion of a number.

Returns:
the maximum number of digits allowed in the integer portion of a number.
See also:
setMaximumIntegerDigits
Stable:
ICU 2.0

int32_t NumberFormat::getMinimumFractionDigits void    const
 

Returns the minimum number of digits allowed in the fraction portion of a number.

Returns:
the minimum number of digits allowed in the fraction portion of a number.
See also:
setMinimumFractionDigits
Stable:
ICU 2.0

int32_t NumberFormat::getMinimumIntegerDigits void    const
 

Returns the minimum number of digits allowed in the integer portion of a number.

Returns:
the minimum number of digits allowed in the integer portion of a number.
See also:
setMinimumIntegerDigits
Stable:
ICU 2.0

UBool NumberFormat::isGroupingUsed void    const
 

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 also:
setGroupingUsed
Stable:
ICU 2.0

UBool NumberFormat::isParseIntegerOnly void    const [inline]
 

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.

Returns:
true if this format will parse numbers as integers only.
Stable:
ICU 2.0

Definition at line 813 of file numfmt.h.

NumberFormat* NumberFormat::makeInstance const Locale   desiredLocale,
EStyles    choice,
UErrorCode   success
[static, private]
 

Creates the specified decimal format style of the desired locale.

Parameters:
desiredLocale  the given locale.
choice  the given style.
success  Output param filled with success/failure status.
Returns:
A new NumberFormat instance.

NumberFormat& NumberFormat::operator= const NumberFormat &    [protected]
 

Assignment operator.

Stable:
ICU 2.0

virtual UBool NumberFormat::operator== const Format   other const [virtual]
 

Return true if the given Format objects are semantically equal.

Objects of different subclasses are considered unequal.

Returns:
true if the given Format objects are semantically equal.
Stable:
ICU 2.0

Reimplemented from Format.

Reimplemented in ChoiceFormat, DecimalFormat, and RuleBasedNumberFormat.

virtual void NumberFormat::parse const UnicodeString   text,
Formattable   result,
UErrorCode   status
const [virtual]
 

Parse a string as a numeric value, and return a Formattable numeric object.

This method parses integers only if IntegerOnly is set.

Parameters:
text  The text to be parsed.
result  Formattable to be set to the parse result. If parse fails, return contents are undefined.
status  Output parameter set to a failure error code when a failure occurs.
Returns:
A Formattable object of numeric type. The caller owns this an must delete it. NULL on failure.
See also:
NumberFormat::isParseIntegerOnly
Stable:
ICU 2.0

Reimplemented in ChoiceFormat, DecimalFormat, and RuleBasedNumberFormat.

virtual void NumberFormat::parse const UnicodeString   text,
Formattable   result,
ParsePosition   parsePosition
const [pure virtual]
 

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).

If no object can be parsed, index is unchanged, and NULL is returned.

This is a pure virtual which concrete subclasses must implement.

Parameters:
text  The text to be parsed.
result  Formattable to be set to the parse result. If parse fails, return contents are undefined.
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.
Returns:
A Formattable object of numeric type. The caller owns this an must delete it. NULL on failure.
Stable:
ICU 2.0

Reimplemented in ChoiceFormat, DecimalFormat, and RuleBasedNumberFormat.

Referenced by RuleBasedNumberFormat::parse().

virtual void NumberFormat::parseObject const UnicodeString   source,
Formattable   result,
ParsePosition   parse_pos
const [virtual]
 

Parse a string to produce an object.

This methods handles parsing of numeric strings into Formattable objects with numeric types.

Before calling, set parse_pos.index to the offset you want to start parsing at in the source. After calling, parse_pos.index is the end of the text you parsed. If error occurs, index is unchanged.

When parsing, leading whitespace is discarded (with successful parse), while trailing whitespace is left as is.

See Format::parseObject() for more.

Parameters:
source  The string to be parsed into an object.
result  Formattable to be set to the parse result. If parse fails, return contents are undefined.
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.
Returns:
A newly created Formattable* object, or NULL on failure. The caller owns this and should delete it when done.
Stable:
ICU 2.0

Reimplemented from Format.

URegistryKey NumberFormat::registerFactory NumberFormatFactory   toAdopt,
UErrorCode   status
[static]
 

Register a new NumberFormatFactory.

The factory will be adopted.

Parameters:
toAdopt  the NumberFormatFactory instance to be adopted
status  the in/out status code, no special meanings are assigned
Returns:
a registry key that can be used to unregister this factory
Draft:
This API has been introduced in ICU 2.6. It is still in draft state and may be modified in a future release.

virtual void NumberFormat::setCurrency const UChar *    theCurrency [virtual]
 

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.

Parameters:
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.
Draft:
This API has been introduced in ICU 2.6. It is still in draft state and may be modified in a future release.

Reimplemented in DecimalFormat.

virtual void NumberFormat::setGroupingUsed UBool    newValue [virtual]
 

Set whether or not grouping will be used in this format.

Parameters:
newValue  True, grouping will be used in this format.
See also:
getGroupingUsed
Stable:
ICU 2.0

virtual void NumberFormat::setMaximumFractionDigits int32_t    newValue [virtual]
 

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.

Parameters:
newValue  the new value to be set.
See also:
getMaximumFractionDigits
Stable:
ICU 2.0

Reimplemented in DecimalFormat.

virtual void NumberFormat::setMaximumIntegerDigits int32_t    newValue [virtual]
 

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.

Parameters:
newValue  the new value for the maximum number of digits allowed in the integer portion of a number.
See also:
getMaximumIntegerDigits
Stable:
ICU 2.0

Reimplemented in DecimalFormat.

virtual void NumberFormat::setMinimumFractionDigits int32_t    newValue [virtual]
 

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

Parameters:
newValue  the new value to be set.
See also:
getMinimumFractionDigits
Stable:
ICU 2.0

Reimplemented in DecimalFormat.

virtual void NumberFormat::setMinimumIntegerDigits int32_t    newValue [virtual]
 

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.

Parameters:
newValue  the new value to be set.
See also:
getMinimumIntegerDigits
Stable:
ICU 2.0

Reimplemented in DecimalFormat.

virtual void NumberFormat::setParseIntegerOnly UBool    value [virtual]
 

Sets whether or not numbers should be parsed as integers only.

Parameters:
value  set True, this format will parse numbers as integers only.
See also:
isParseIntegerOnly
Stable:
ICU 2.0

UBool NumberFormat::unregister URegistryKey    key,
UErrorCode   status
[static]
 

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.

Parameters:
key  the registry key returned by a previous call to registerFactory
status  the in/out status code, no special meanings are assigned
Returns:
TRUE if the factory for the key was successfully unregistered
Draft:
This API has been introduced in ICU 2.6. It is still in draft state and may be modified in a future release.


Friends And Related Function Documentation

friend class ICUNumberFormatFactory [friend]
 

Definition at line 720 of file numfmt.h.

friend class ICUNumberFormatService [friend]
 

Definition at line 721 of file numfmt.h.


Member Data Documentation

char NumberFormat::actualLocale[50] [protected]
 

Definition at line 676 of file numfmt.h.

UChar NumberFormat::currency[4] [private]
 

Definition at line 718 of file numfmt.h.

UBool NumberFormat::fGroupingUsed [private]
 

Definition at line 710 of file numfmt.h.

int32_t NumberFormat::fMaxFractionDigits [private]
 

Definition at line 713 of file numfmt.h.

int32_t NumberFormat::fMaxIntegerDigits [private]
 

Definition at line 711 of file numfmt.h.

int32_t NumberFormat::fMinFractionDigits [private]
 

Definition at line 714 of file numfmt.h.

int32_t NumberFormat::fMinIntegerDigits [private]
 

Definition at line 712 of file numfmt.h.

UBool NumberFormat::fParseIntegerOnly [private]
 

Definition at line 715 of file numfmt.h.

const UChar* const NumberFormat::fgLastResortNumberPatterns[] [static, private]
 

Definition at line 708 of file numfmt.h.

const int32_t NumberFormat::fgMaxIntegerDigits [static, private]
 

Definition at line 671 of file numfmt.h.

const int32_t NumberFormat::fgMinIntegerDigits [static, private]
 

Definition at line 672 of file numfmt.h.

const int32_t NumberFormat::fgNumberPatternsCount [static, private]
 

Definition at line 707 of file numfmt.h.

char NumberFormat::validLocale[50] [protected]
 

Definition at line 675 of file numfmt.h.


The documentation for this class was generated from the following file:
Generated on Mon Nov 24 14:36:41 2003 for ICU 2.8 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001