Loading...
Searching...
No Matches
numfmt.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************
* Copyright (C) 1997-2016, International Business Machines Corporation and others.
* All Rights Reserved.
********************************************************************************
*
* 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
* Deprecated Java style constants (eg, INTEGER_FIELD)
********************************************************************************
*/
#ifndef NUMFMT_H
#define NUMFMT_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_FORMATTING
#include "unicode/unistr.h"
#include "unicode/format.h"
#include "unicode/unum.h" // UNumberFormatStyle
#include "unicode/locid.h"
#include "unicode/stringpiece.h"
#include "unicode/curramt.h"
#include "unicode/udisplaycontext.h"
class NumberFormatTest;
U_NAMESPACE_BEGIN
class SharedNumberFormat;
#if !UCONFIG_NO_SERVICE
class NumberFormatFactory;
class StringEnumeration;
#endif
class U_I18N_API NumberFormat : public Format {
public:
enum ERoundingMode {
kRoundCeiling,
kRoundFloor,
kRoundDown,
kRoundUp,
kRoundHalfEven,
kRoundHalfDown,
kRoundHalfUp,
kRoundUnnecessary,
kRoundHalfOdd,
kRoundHalfCeiling,
kRoundHalfFloor,
};
enum EAlignmentFields {
kIntegerField = UNUM_INTEGER_FIELD,
kFractionField = UNUM_FRACTION_FIELD,
kDecimalSeparatorField = UNUM_DECIMAL_SEPARATOR_FIELD,
kExponentSymbolField = UNUM_EXPONENT_SYMBOL_FIELD,
kExponentSignField = UNUM_EXPONENT_SIGN_FIELD,
kExponentField = UNUM_EXPONENT_FIELD,
kGroupingSeparatorField = UNUM_GROUPING_SEPARATOR_FIELD,
kCurrencyField = UNUM_CURRENCY_FIELD,
kPercentField = UNUM_PERCENT_FIELD,
kPermillField = UNUM_PERMILL_FIELD,
kSignField = UNUM_SIGN_FIELD,
kMeasureUnitField = UNUM_MEASURE_UNIT_FIELD,
kCompactField = UNUM_COMPACT_FIELD,
INTEGER_FIELD = UNUM_INTEGER_FIELD,
FRACTION_FIELD = UNUM_FRACTION_FIELD
};
virtual ~NumberFormat();
virtual NumberFormat* clone() const override = 0;
virtual bool operator==(const Format& other) const override;
using Format::format;
virtual UnicodeString& format(const Formattable& obj,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode& status) const override;
virtual UnicodeString& format(const Formattable& obj,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const override;
virtual void parseObject(const UnicodeString& source,
Formattable& result,
ParsePosition& parse_pos) const override;
UnicodeString& format( double number,
UnicodeString& appendTo) const;
UnicodeString& format( int32_t number,
UnicodeString& appendTo) const;
UnicodeString& format( int64_t number,
UnicodeString& appendTo) const;
virtual UnicodeString& format(double number,
UnicodeString& appendTo,
FieldPosition& pos) const = 0;
virtual UnicodeString& format(double number,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode &status) const;
virtual UnicodeString& format(double number,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
virtual UnicodeString& format(int32_t number,
UnicodeString& appendTo,
FieldPosition& pos) const = 0;
virtual UnicodeString& format(int32_t number,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode &status) const;
virtual UnicodeString& format(int32_t number,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
virtual UnicodeString& format(int64_t number,
UnicodeString& appendTo,
FieldPosition& pos) const;
virtual UnicodeString& format(int64_t number,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode& status) const;
virtual UnicodeString& format(int64_t number,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
virtual UnicodeString& format(StringPiece number,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
// Can't use #ifndef U_HIDE_INTERNAL_API because these are virtual methods
virtual UnicodeString& format(const number::impl::DecimalQuantity &number,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
virtual UnicodeString& format(const number::impl::DecimalQuantity &number,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode& status) const;
virtual void parse(const UnicodeString& text,
Formattable& result,
ParsePosition& parsePosition) const = 0;
virtual void parse(const UnicodeString& text,
Formattable& result,
UErrorCode& status) const;
virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
ParsePosition& pos) const;
UBool isParseIntegerOnly() const;
virtual void setParseIntegerOnly(UBool value);
virtual void setLenient(UBool enable);
virtual UBool isLenient() const;
static NumberFormat* U_EXPORT2 createInstance(UErrorCode&);
static NumberFormat* U_EXPORT2 createInstance(const Locale& inLocale,
UErrorCode&);
static NumberFormat* U_EXPORT2 createInstance(const Locale& desiredLocale,
UNumberFormatStyle style,
UErrorCode& errorCode);
#ifndef U_HIDE_INTERNAL_API
static NumberFormat* internalCreateInstance(
const Locale& desiredLocale,
UNumberFormatStyle style,
UErrorCode& errorCode);
static const SharedNumberFormat* U_EXPORT2 createSharedInstance(
const Locale& inLocale, UNumberFormatStyle style, UErrorCode& status);
#endif /* U_HIDE_INTERNAL_API */
static NumberFormat* U_EXPORT2 createCurrencyInstance(UErrorCode&);
static NumberFormat* U_EXPORT2 createCurrencyInstance(const Locale& inLocale,
UErrorCode&);
static NumberFormat* U_EXPORT2 createPercentInstance(UErrorCode&);
static NumberFormat* U_EXPORT2 createPercentInstance(const Locale& inLocale,
UErrorCode&);
static NumberFormat* U_EXPORT2 createScientificInstance(UErrorCode&);
static NumberFormat* U_EXPORT2 createScientificInstance(const Locale& inLocale,
UErrorCode&);
static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
#if !UCONFIG_NO_SERVICE
static URegistryKey U_EXPORT2 registerFactory(NumberFormatFactory* toAdopt, UErrorCode& status);
static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
static StringEnumeration* U_EXPORT2 getAvailableLocales();
#endif /* UCONFIG_NO_SERVICE */
UBool isGroupingUsed() const;
virtual void setGroupingUsed(UBool newValue);
int32_t getMaximumIntegerDigits() const;
virtual void setMaximumIntegerDigits(int32_t newValue);
int32_t getMinimumIntegerDigits() const;
virtual void setMinimumIntegerDigits(int32_t newValue);
int32_t getMaximumFractionDigits() const;
virtual void setMaximumFractionDigits(int32_t newValue);
int32_t getMinimumFractionDigits() const;
virtual void setMinimumFractionDigits(int32_t newValue);
virtual void setCurrency(const char16_t* theCurrency, UErrorCode& ec);
const char16_t* getCurrency() const;
virtual void setContext(UDisplayContext value, UErrorCode& status);
virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const;
virtual ERoundingMode getRoundingMode() const;
virtual void setRoundingMode(ERoundingMode roundingMode);
public:
static UClassID U_EXPORT2 getStaticClassID();
virtual UClassID getDynamicClassID() const override = 0;
protected:
NumberFormat();
NumberFormat(const NumberFormat&);
NumberFormat& operator=(const NumberFormat&);
virtual void getEffectiveCurrency(char16_t* result, UErrorCode& ec) const;
#ifndef U_HIDE_INTERNAL_API
static NumberFormat* makeInstance(const Locale& desiredLocale,
UNumberFormatStyle style,
UBool mustBeDecimalFormat,
UErrorCode& errorCode);
#endif /* U_HIDE_INTERNAL_API */
private:
static UBool isStyleSupported(UNumberFormatStyle style);
static NumberFormat* makeInstance(const Locale& desiredLocale,
UNumberFormatStyle style,
UErrorCode& errorCode);
UBool fGroupingUsed;
int32_t fMaxIntegerDigits;
int32_t fMinIntegerDigits;
int32_t fMaxFractionDigits;
int32_t fMinFractionDigits;
protected:
static const int32_t gDefaultMaxIntegerDigits;
static const int32_t gDefaultMinIntegerDigits;
private:
UBool fParseIntegerOnly;
UBool fLenient; // true => lenient parse is enabled
// ISO currency code
char16_t fCurrency[4];
UDisplayContext fCapitalizationContext;
friend class ICUNumberFormatFactory; // access to makeInstance
friend class ICUNumberFormatService;
friend class ::NumberFormatTest; // access to isStyleSupported()
};
#if !UCONFIG_NO_SERVICE
class U_I18N_API NumberFormatFactory : public UObject {
public:
virtual ~NumberFormatFactory();
virtual UBool visible() const = 0;
virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const = 0;
virtual NumberFormat* createFormat(const Locale& loc, UNumberFormatStyle formatType) = 0;
};
class U_I18N_API SimpleNumberFormatFactory : public NumberFormatFactory {
protected:
const UBool _visible;
UnicodeString _id;
public:
SimpleNumberFormatFactory(const Locale& locale, UBool visible = true);
virtual ~SimpleNumberFormatFactory();
virtual UBool visible() const override;
virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const override;
};
#endif /* #if !UCONFIG_NO_SERVICE */
// -------------------------------------
inline UBool
NumberFormat::isParseIntegerOnly() const
{
return fParseIntegerOnly;
}
inline UBool
NumberFormat::isLenient() const
{
return fLenient;
}
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // _NUMFMT
//eof
icu::CurrencyAmount
A currency together with a numeric amount, such as 200 USD.
Definition curramt.h:39
icu::FieldPositionIterator
FieldPositionIterator returns the field ids and their start/limit positions generated by a call to Fo...
Definition fpositer.h:58
icu::FieldPosition
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition fieldpos.h:110
icu::Format::Format
U_I18N_API Format()
Default constructor for subclass use only.
icu::Format::format
U_I18N_API UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
Formats an object to produce a string.
icu::Formattable
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition fmtable.h:63
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:198
icu::NumberFormatFactory
A NumberFormatFactory is used to register new number formats.
Definition numfmt.h:1190
icu::NumberFormatFactory::createFormat
virtual NumberFormat * createFormat(const Locale &loc, UNumberFormatStyle formatType)=0
Return a number format of the appropriate type.
icu::NumberFormatFactory::visible
virtual UBool visible() const =0
Return true if this factory will be visible.
icu::NumberFormatFactory::getSupportedIDs
virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode &status) const =0
Return the locale names directly supported by this factory.
icu::NumberFormatFactory::~NumberFormatFactory
virtual ~NumberFormatFactory()
Destructor.
icu::NumberFormat
Definition numfmt.h:175
icu::NumberFormat::getEffectiveCurrency
virtual void getEffectiveCurrency(char16_t *result, UErrorCode &ec) const
Returns the currency in effect for this formatter.
icu::NumberFormat::setMinimumIntegerDigits
virtual void setMinimumIntegerDigits(int32_t newValue)
Sets the minimum number of digits allowed in the integer portion of a number.
icu::NumberFormat::format
virtual UnicodeString & format(double number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
Format a double number.
icu::NumberFormat::setParseIntegerOnly
virtual void setParseIntegerOnly(UBool value)
Sets whether or not numbers should be parsed as integers only.
icu::NumberFormat::setMaximumIntegerDigits
virtual void setMaximumIntegerDigits(int32_t newValue)
Sets the maximum number of digits allowed in the integer portion of a number.
icu::NumberFormat::getContext
virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode &status) const
Get the formatter's UDisplayContext value for the specified UDisplayContextType, such as UDISPCTX_TYP...
icu::NumberFormat::getAvailableLocales
static const Locale * getAvailableLocales(int32_t &count)
Get the set of Locales for which NumberFormats are installed.
icu::NumberFormat::setContext
virtual void setContext(UDisplayContext value, UErrorCode &status)
Set a particular UDisplayContext value in the formatter, such as UDISPCTX_CAPITALIZATION_FOR_STANDALO...
icu::NumberFormat::format
UnicodeString & format(int64_t number, UnicodeString &appendTo) const
Format an int64 number.
icu::NumberFormat::operator=
NumberFormat & operator=(const NumberFormat &)
Assignment operator.
icu::NumberFormat::createCurrencyInstance
static NumberFormat * createCurrencyInstance(UErrorCode &)
Returns a currency format for the current default locale.
icu::NumberFormat::parseObject
virtual void parseObject(const UnicodeString &source, Formattable &result, ParsePosition &parse_pos) const override
Parse a string to produce an object.
icu::NumberFormat::getMinimumFractionDigits
int32_t getMinimumFractionDigits() const
Returns the minimum number of digits allowed in the fraction portion of a number.
icu::NumberFormat::clone
virtual NumberFormat * clone() const override=0
Clones this object polymorphically.
icu::NumberFormat::createPercentInstance
static NumberFormat * createPercentInstance(const Locale &inLocale, UErrorCode &)
Returns a percentage format for the specified locale.
icu::NumberFormat::gDefaultMaxIntegerDigits
static const int32_t gDefaultMaxIntegerDigits
Definition numfmt.h:1163
icu::NumberFormat::setLenient
virtual void setLenient(UBool enable)
Sets whether lenient parsing should be enabled (it is off by default).
icu::NumberFormat::getCurrency
const char16_t * getCurrency() const
Gets the currency used to display currency amounts.
icu::NumberFormat::format
virtual UnicodeString & format(const number::impl::DecimalQuantity &number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
Format a decimal number.
icu::NumberFormat::makeInstance
static NumberFormat * makeInstance(const Locale &desiredLocale, UNumberFormatStyle style, UBool mustBeDecimalFormat, UErrorCode &errorCode)
Creates the specified number format style of the desired locale.
icu::NumberFormat::format
virtual UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const override
Format an object to produce a string.
icu::NumberFormat::~NumberFormat
virtual ~NumberFormat()
Destructor.
icu::NumberFormat::internalCreateInstance
static NumberFormat * internalCreateInstance(const Locale &desiredLocale, UNumberFormatStyle style, UErrorCode &errorCode)
ICU use only.
icu::NumberFormat::setMinimumFractionDigits
virtual void setMinimumFractionDigits(int32_t newValue)
Sets the minimum number of digits allowed in the fraction portion of a number.
icu::NumberFormat::format
virtual UnicodeString & format(int32_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
Format an int32 number.
icu::NumberFormat::format
UnicodeString & format(double number, UnicodeString &appendTo) const
Format a double number.
icu::NumberFormat::NumberFormat
NumberFormat()
Default constructor for subclass use only.
icu::NumberFormat::format
virtual UnicodeString & format(int32_t number, UnicodeString &appendTo, FieldPosition &pos) const =0
Format a long number.
icu::NumberFormat::gDefaultMinIntegerDigits
static const int32_t gDefaultMinIntegerDigits
Definition numfmt.h:1165
icu::NumberFormat::createScientificInstance
static NumberFormat * createScientificInstance(UErrorCode &)
Returns a scientific format for the current default locale.
icu::NumberFormat::format
virtual UnicodeString & format(int64_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Format an int64 number.
icu::NumberFormat::EAlignmentFields
EAlignmentFields
Alignment Field constants used to construct a FieldPosition object.
Definition numfmt.h:234
icu::NumberFormat::kExponentField
@ kExponentField
Definition numfmt.h:246
icu::NumberFormat::kPercentField
@ kPercentField
Definition numfmt.h:252
icu::NumberFormat::kDecimalSeparatorField
@ kDecimalSeparatorField
Definition numfmt.h:240
icu::NumberFormat::kMeasureUnitField
@ kMeasureUnitField
Definition numfmt.h:258
icu::NumberFormat::INTEGER_FIELD
@ INTEGER_FIELD
These constants are provided for backwards compatibility only.
Definition numfmt.h:267
icu::NumberFormat::FRACTION_FIELD
@ FRACTION_FIELD
Definition numfmt.h:269
icu::NumberFormat::kFractionField
@ kFractionField
Definition numfmt.h:238
icu::NumberFormat::kExponentSignField
@ kExponentSignField
Definition numfmt.h:244
icu::NumberFormat::kIntegerField
@ kIntegerField
Definition numfmt.h:236
icu::NumberFormat::kPermillField
@ kPermillField
Definition numfmt.h:254
icu::NumberFormat::kCompactField
@ kCompactField
Definition numfmt.h:260
icu::NumberFormat::kExponentSymbolField
@ kExponentSymbolField
Definition numfmt.h:242
icu::NumberFormat::kCurrencyField
@ kCurrencyField
Definition numfmt.h:250
icu::NumberFormat::kGroupingSeparatorField
@ kGroupingSeparatorField
Definition numfmt.h:248
icu::NumberFormat::kSignField
@ kSignField
Definition numfmt.h:256
icu::NumberFormat::createInstance
static NumberFormat * createInstance(UErrorCode &)
Create a default style NumberFormat for the current default locale.
icu::NumberFormat::getMaximumIntegerDigits
int32_t getMaximumIntegerDigits() const
Returns the maximum number of digits allowed in the integer portion of a number.
icu::NumberFormat::setGroupingUsed
virtual void setGroupingUsed(UBool newValue)
Set whether or not grouping will be used in this format.
icu::NumberFormat::registerFactory
static URegistryKey registerFactory(NumberFormatFactory *toAdopt, UErrorCode &status)
Register a new NumberFormatFactory.
icu::NumberFormat::getAvailableLocales
static StringEnumeration * getAvailableLocales()
Return a StringEnumeration over the locales available at the time of the call, including registered l...
icu::NumberFormat::getStaticClassID
static UClassID getStaticClassID()
Return the class ID for this class.
icu::NumberFormat::setCurrency
virtual void setCurrency(const char16_t *theCurrency, UErrorCode &ec)
Sets the currency used to display currency amounts.
icu::NumberFormat::setMaximumFractionDigits
virtual void setMaximumFractionDigits(int32_t newValue)
Sets the maximum number of digits allowed in the fraction portion of a number.
icu::NumberFormat::format
virtual UnicodeString & format(const number::impl::DecimalQuantity &number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Format a decimal number.
icu::NumberFormat::format
virtual UnicodeString & format(StringPiece number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
Format a decimal number.
icu::NumberFormat::operator==
virtual bool operator==(const Format &other) const override
Return true if the given Format objects are semantically equal.
icu::NumberFormat::getRoundingMode
virtual ERoundingMode getRoundingMode() const
Get the rounding mode.
icu::NumberFormat::ERoundingMode
ERoundingMode
Rounding mode.
Definition numfmt.h:186
icu::NumberFormat::kRoundDown
@ kRoundDown
Round towards zero.
Definition numfmt.h:189
icu::NumberFormat::kRoundHalfDown
@ kRoundHalfDown
Round towards the nearest integer, or towards zero if equidistant.
Definition numfmt.h:193
icu::NumberFormat::kRoundFloor
@ kRoundFloor
Round towards negative infinity.
Definition numfmt.h:188
icu::NumberFormat::kRoundCeiling
@ kRoundCeiling
Round towards positive infinity.
Definition numfmt.h:187
icu::NumberFormat::kRoundHalfEven
@ kRoundHalfEven
Round towards the nearest integer, or towards the nearest even integer if equidistant.
Definition numfmt.h:191
icu::NumberFormat::kRoundUnnecessary
@ kRoundUnnecessary
Return U_FORMAT_INEXACT_ERROR if number does not format exactly.
Definition numfmt.h:201
icu::NumberFormat::kRoundHalfFloor
@ kRoundHalfFloor
Rounds ties toward -∞.
Definition numfmt.h:216
icu::NumberFormat::kRoundHalfOdd
@ kRoundHalfOdd
Rounds ties toward the odd number.
Definition numfmt.h:206
icu::NumberFormat::kRoundHalfCeiling
@ kRoundHalfCeiling
Rounds ties toward +∞.
Definition numfmt.h:211
icu::NumberFormat::kRoundUp
@ kRoundUp
Round away from zero.
Definition numfmt.h:190
icu::NumberFormat::kRoundHalfUp
@ kRoundHalfUp
Round towards the nearest integer, or away from zero if equidistant.
Definition numfmt.h:195
icu::NumberFormat::format
UnicodeString & format(int32_t number, UnicodeString &appendTo) const
Format a long number.
icu::NumberFormat::format
virtual UnicodeString & format(int64_t number, UnicodeString &appendTo, FieldPosition &pos) const
Format an int64 number.
icu::NumberFormat::format
virtual UnicodeString & format(double number, UnicodeString &appendTo, FieldPosition &pos) const =0
Format a double number.
icu::NumberFormat::createScientificInstance
static NumberFormat * createScientificInstance(const Locale &inLocale, UErrorCode &)
Returns a scientific format for the specified locale.
icu::NumberFormat::createInstance
static NumberFormat * createInstance(const Locale &inLocale, UErrorCode &)
Create a default style NumberFormat for the specified locale.
icu::NumberFormat::createCurrencyInstance
static NumberFormat * createCurrencyInstance(const Locale &inLocale, UErrorCode &)
Returns a currency format for the specified locale.
icu::NumberFormat::setRoundingMode
virtual void setRoundingMode(ERoundingMode roundingMode)
Set the rounding mode.
icu::NumberFormat::isGroupingUsed
UBool isGroupingUsed() const
Returns true if grouping is used in this format.
icu::NumberFormat::format
virtual UnicodeString & format(int32_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Format a long number.
icu::NumberFormat::format
virtual UnicodeString & format(int64_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
Format an int64 number.
icu::NumberFormat::unregister
static UBool unregister(URegistryKey key, UErrorCode &status)
Unregister a previously-registered NumberFormatFactory using the key returned from the register call.
icu::NumberFormat::getDynamicClassID
virtual UClassID getDynamicClassID() const override=0
Returns a unique class ID POLYMORPHICALLY.
icu::NumberFormat::createInstance
static NumberFormat * createInstance(const Locale &desiredLocale, UNumberFormatStyle style, UErrorCode &errorCode)
Create a specific style NumberFormat for the specified locale.
icu::NumberFormat::getMaximumFractionDigits
int32_t getMaximumFractionDigits() const
Returns the maximum number of digits allowed in the fraction portion of a number.
icu::NumberFormat::parse
virtual void parse(const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const =0
Return a long if possible (e.g.
icu::NumberFormat::createPercentInstance
static NumberFormat * createPercentInstance(UErrorCode &)
Returns a percentage format for the current default locale.
icu::NumberFormat::createSharedInstance
static const SharedNumberFormat * createSharedInstance(const Locale &inLocale, UNumberFormatStyle style, UErrorCode &status)
ICU use only.
icu::NumberFormat::format
virtual UnicodeString & format(double number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Format a double number.
icu::NumberFormat::format
virtual UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const override
Format an object to produce a string.
icu::NumberFormat::parseCurrency
virtual CurrencyAmount * parseCurrency(const UnicodeString &text, ParsePosition &pos) const
Parses text from the given string as a currency amount.
icu::NumberFormat::isLenient
virtual UBool isLenient() const
Returns whether lenient parsing is enabled (it is off by default).
Definition numfmt.h:1274
icu::NumberFormat::NumberFormat
NumberFormat(const NumberFormat &)
Copy constructor.
icu::NumberFormat::getMinimumIntegerDigits
int32_t getMinimumIntegerDigits() const
Returns the minimum number of digits allowed in the integer portion of a number.
icu::NumberFormat::parse
virtual void parse(const UnicodeString &text, Formattable &result, UErrorCode &status) const
Parse a string as a numeric value, and return a Formattable numeric object.
icu::NumberFormat::isParseIntegerOnly
UBool isParseIntegerOnly() const
Return true if this format will parse numbers as integers only.
Definition numfmt.h:1268
icu::ParsePosition
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition parsepos.h:52
icu::SimpleNumberFormatFactory::SimpleNumberFormatFactory
SimpleNumberFormatFactory(const Locale &locale, UBool visible=true)
icu::SimpleNumberFormatFactory::visible
virtual UBool visible() const override
icu::SimpleNumberFormatFactory::getSupportedIDs
virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode &status) const override
icu::SimpleNumberFormatFactory::~SimpleNumberFormatFactory
virtual ~SimpleNumberFormatFactory()
icu::SimpleNumberFormatFactory::_id
UnicodeString _id
The locale supported by this factory, as a UnicodeString.
Definition numfmt.h:1240
icu::SimpleNumberFormatFactory::_visible
const UBool _visible
True if the locale supported by this factory is visible.
Definition numfmt.h:1234
icu::StringEnumeration
Base class for 'pure' C++ implementations of uenum api.
Definition strenum.h:61
icu::StringPiece
A string-like object that points to a sized piece of memory.
Definition stringpiece.h:61
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition uobject.h:222
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
curramt.h
C++ API: Currency Amount Object.
format.h
C++ API: Base class for all formats.
locid.h
C++ API: Locale ID object.
stringpiece.h
C++ API: StringPiece: Read-only byte string wrapper class.
udisplaycontext.h
C API: Display context types (enum values).
UDisplayContextType
UDisplayContextType
Display context types, for getting values of a particular setting.
Definition udisplaycontext.h:27
UDisplayContext
UDisplayContext
Display context settings.
Definition udisplaycontext.h:64
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
URegistryKey
const void * URegistryKey
Opaque type returned by registerInstance, registerFactory and unregister for service registration.
Definition umisc.h:57
unistr.h
C++ API: Unicode String.
unum.h
C API: Compatibility APIs for number formatting.
UNumberFormatStyle
UNumberFormatStyle
The possible number format styles.
Definition unum.h:150
UNUM_MEASURE_UNIT_FIELD
@ UNUM_MEASURE_UNIT_FIELD
Definition unum.h:351
UNUM_COMPACT_FIELD
@ UNUM_COMPACT_FIELD
Definition unum.h:353
UNUM_INTEGER_FIELD
@ UNUM_INTEGER_FIELD
Definition unum.h:329
UNUM_PERCENT_FIELD
@ UNUM_PERCENT_FIELD
Definition unum.h:345
UNUM_PERMILL_FIELD
@ UNUM_PERMILL_FIELD
Definition unum.h:347
UNUM_EXPONENT_SYMBOL_FIELD
@ UNUM_EXPONENT_SYMBOL_FIELD
Definition unum.h:335
UNUM_GROUPING_SEPARATOR_FIELD
@ UNUM_GROUPING_SEPARATOR_FIELD
Definition unum.h:341
UNUM_DECIMAL_SEPARATOR_FIELD
@ UNUM_DECIMAL_SEPARATOR_FIELD
Definition unum.h:333
UNUM_SIGN_FIELD
@ UNUM_SIGN_FIELD
Definition unum.h:349
UNUM_CURRENCY_FIELD
@ UNUM_CURRENCY_FIELD
Definition unum.h:343
UNUM_FRACTION_FIELD
@ UNUM_FRACTION_FIELD
Definition unum.h:331
UNUM_EXPONENT_SIGN_FIELD
@ UNUM_EXPONENT_SIGN_FIELD
Definition unum.h:337
UNUM_EXPONENT_FIELD
@ UNUM_EXPONENT_FIELD
Definition unum.h:339
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:316