ICU 74.2: i18n/unicode/numfmt.h Source File

ICU 74.2 74.2

numfmt.h
Go to the documentation of this file.
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/*
4********************************************************************************
5* Copyright (C) 1997-2016, International Business Machines Corporation and others.
6* All Rights Reserved.
7********************************************************************************
8*
9* File NUMFMT.H
10*
11* Modification History:
12*
13* Date Name Description
14* 02/19/97 aliu Converted from java.
15* 03/18/97 clhuang Updated per C++ implementation.
16* 04/17/97 aliu Changed DigitCount to int per code review.
17* 07/20/98 stephen JDK 1.2 sync up. Added scientific support.
18* Changed naming conventions to match C++ guidelines
19* Deprecated Java style constants (eg, INTEGER_FIELD)
20********************************************************************************
21*/
22
23#ifndef NUMFMT_H
24#define NUMFMT_H
25
26
27#include "unicode/utypes.h"
28
29#if U_SHOW_CPLUSPLUS_API
30
36#if !UCONFIG_NO_FORMATTING
37
38#include "unicode/unistr.h"
39#include "unicode/format.h"
40#include "unicode/unum.h" // UNumberFormatStyle
41#include "unicode/locid.h"
42#include "unicode/stringpiece.h"
43#include "unicode/curramt.h"
44#include "unicode/udisplaycontext.h"
45
46class NumberFormatTest;
47
48U_NAMESPACE_BEGIN
49
50class SharedNumberFormat;
51
52#if !UCONFIG_NO_SERVICE
53class NumberFormatFactory;
54class StringEnumeration;
55#endif
56
175 class U_I18N_API NumberFormat : public Format {
176public:
186 enum ERoundingMode {
187 kRoundCeiling,
188 kRoundFloor,
189 kRoundDown,
190 kRoundUp,
191 kRoundHalfEven,
193 kRoundHalfDown,
195 kRoundHalfUp,
201 kRoundUnnecessary,
202#ifndef U_HIDE_DRAFT_API
207 kRoundHalfOdd,
212 kRoundHalfCeiling,
217 kRoundHalfFloor,
218#endif /* U_HIDE_DRAFT_API */
219 };
220
236 enum EAlignmentFields {
238 kIntegerField = UNUM_INTEGER_FIELD,
240 kFractionField = UNUM_FRACTION_FIELD,
242 kDecimalSeparatorField = UNUM_DECIMAL_SEPARATOR_FIELD,
244 kExponentSymbolField = UNUM_EXPONENT_SYMBOL_FIELD,
246 kExponentSignField = UNUM_EXPONENT_SIGN_FIELD,
248 kExponentField = UNUM_EXPONENT_FIELD,
250 kGroupingSeparatorField = UNUM_GROUPING_SEPARATOR_FIELD,
252 kCurrencyField = UNUM_CURRENCY_FIELD,
254 kPercentField = UNUM_PERCENT_FIELD,
256 kPermillField = UNUM_PERMILL_FIELD,
258 kSignField = UNUM_SIGN_FIELD,
260 kMeasureUnitField = UNUM_MEASURE_UNIT_FIELD,
262 kCompactField = UNUM_COMPACT_FIELD,
263
269 INTEGER_FIELD = UNUM_INTEGER_FIELD,
271 FRACTION_FIELD = UNUM_FRACTION_FIELD
272 };
273
278 virtual ~NumberFormat();
279
286 virtual NumberFormat* clone() const override = 0;
287
294 virtual bool operator==(const Format& other) const override;
295
296
297 using Format::format;
298
314 virtual UnicodeString& format(const Formattable& obj,
315 UnicodeString& appendTo,
316 FieldPosition& pos,
317 UErrorCode& status) const override;
318
335 virtual UnicodeString& format(const Formattable& obj,
336 UnicodeString& appendTo,
337 FieldPositionIterator* posIter,
338 UErrorCode& status) const override;
339
368 virtual void parseObject(const UnicodeString& source,
369 Formattable& result,
370 ParsePosition& parse_pos) const override;
371
382 UnicodeString& format( double number,
383 UnicodeString& appendTo) const;
384
395 UnicodeString& format( int32_t number,
396 UnicodeString& appendTo) const;
397
408 UnicodeString& format( int64_t number,
409 UnicodeString& appendTo) const;
410
423 virtual UnicodeString& format(double number,
424 UnicodeString& appendTo,
425 FieldPosition& pos) const = 0;
440 virtual UnicodeString& format(double number,
441 UnicodeString& appendTo,
442 FieldPosition& pos,
443 UErrorCode &status) const;
458 virtual UnicodeString& format(double number,
459 UnicodeString& appendTo,
460 FieldPositionIterator* posIter,
461 UErrorCode& status) const;
474 virtual UnicodeString& format(int32_t number,
475 UnicodeString& appendTo,
476 FieldPosition& pos) const = 0;
477
491 virtual UnicodeString& format(int32_t number,
492 UnicodeString& appendTo,
493 FieldPosition& pos,
494 UErrorCode &status) const;
495
510 virtual UnicodeString& format(int32_t number,
511 UnicodeString& appendTo,
512 FieldPositionIterator* posIter,
513 UErrorCode& status) const;
527 virtual UnicodeString& format(int64_t number,
528 UnicodeString& appendTo,
529 FieldPosition& pos) const;
530
545 virtual UnicodeString& format(int64_t number,
546 UnicodeString& appendTo,
547 FieldPosition& pos,
548 UErrorCode& status) const;
563 virtual UnicodeString& format(int64_t number,
564 UnicodeString& appendTo,
565 FieldPositionIterator* posIter,
566 UErrorCode& status) const;
567
584 virtual UnicodeString& format(StringPiece number,
585 UnicodeString& appendTo,
586 FieldPositionIterator* posIter,
587 UErrorCode& status) const;
588
589// Can't use #ifndef U_HIDE_INTERNAL_API because these are virtual methods
590
608 virtual UnicodeString& format(const number::impl::DecimalQuantity &number,
609 UnicodeString& appendTo,
610 FieldPositionIterator* posIter,
611 UErrorCode& status) const;
612
630 virtual UnicodeString& format(const number::impl::DecimalQuantity &number,
631 UnicodeString& appendTo,
632 FieldPosition& pos,
633 UErrorCode& status) const;
634
654 virtual void parse(const UnicodeString& text,
655 Formattable& result,
656 ParsePosition& parsePosition) const = 0;
657
673 virtual void parse(const UnicodeString& text,
674 Formattable& result,
675 UErrorCode& status) const;
676
696 virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
697 ParsePosition& pos) const;
698
710 UBool isParseIntegerOnly(void) const;
711
719 virtual void setParseIntegerOnly(UBool value);
720
728 virtual void setLenient(UBool enable);
729
738 virtual UBool isLenient(void) const;
739
748 static NumberFormat* U_EXPORT2 createInstance(UErrorCode&);
749
759 static NumberFormat* U_EXPORT2 createInstance(const Locale& inLocale,
760 UErrorCode&);
761
773 static NumberFormat* U_EXPORT2 createInstance(const Locale& desiredLocale,
774 UNumberFormatStyle style,
775 UErrorCode& errorCode);
776
777#ifndef U_HIDE_INTERNAL_API
778
784 static NumberFormat* internalCreateInstance(
785 const Locale& desiredLocale,
786 UNumberFormatStyle style,
787 UErrorCode& errorCode);
788
796 static const SharedNumberFormat* U_EXPORT2 createSharedInstance(
797 const Locale& inLocale, UNumberFormatStyle style, UErrorCode& status);
798
799#endif /* U_HIDE_INTERNAL_API */
800
808 static NumberFormat* U_EXPORT2 createCurrencyInstance(UErrorCode&);
809
818 static NumberFormat* U_EXPORT2 createCurrencyInstance(const Locale& inLocale,
819 UErrorCode&);
820
828 static NumberFormat* U_EXPORT2 createPercentInstance(UErrorCode&);
829
838 static NumberFormat* U_EXPORT2 createPercentInstance(const Locale& inLocale,
839 UErrorCode&);
840
848 static NumberFormat* U_EXPORT2 createScientificInstance(UErrorCode&);
849
858 static NumberFormat* U_EXPORT2 createScientificInstance(const Locale& inLocale,
859 UErrorCode&);
860
866 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
867
868#if !UCONFIG_NO_SERVICE
879 static URegistryKey U_EXPORT2 registerFactory(NumberFormatFactory* toAdopt, UErrorCode& status);
880
893 static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
894
901 static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
902#endif /* UCONFIG_NO_SERVICE */
903
913 UBool isGroupingUsed(void) const;
914
921 virtual void setGroupingUsed(UBool newValue);
922
931 int32_t getMaximumIntegerDigits(void) const;
932
945 virtual void setMaximumIntegerDigits(int32_t newValue);
946
955 int32_t getMinimumIntegerDigits(void) const;
956
967 virtual void setMinimumIntegerDigits(int32_t newValue);
968
977 int32_t getMaximumFractionDigits(void) const;
978
989 virtual void setMaximumFractionDigits(int32_t newValue);
990
999 int32_t getMinimumFractionDigits(void) const;
1000
1011 virtual void setMinimumFractionDigits(int32_t newValue);
1012
1025 virtual void setCurrency(const char16_t* theCurrency, UErrorCode& ec);
1026
1034 const char16_t* getCurrency() const;
1035
1045 virtual void setContext(UDisplayContext value, UErrorCode& status);
1046
1057 virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const;
1058
1065 virtual ERoundingMode getRoundingMode(void) const;
1066
1072 virtual void setRoundingMode(ERoundingMode roundingMode);
1073
1074public:
1075
1084 static UClassID U_EXPORT2 getStaticClassID(void);
1085
1097 virtual UClassID getDynamicClassID(void) const override = 0;
1098
1099protected:
1100
1105 NumberFormat();
1106
1111 NumberFormat(const NumberFormat&);
1112
1117 NumberFormat& operator=(const NumberFormat&);
1118
1127 virtual void getEffectiveCurrency(char16_t* result, UErrorCode& ec) const;
1128
1129#ifndef U_HIDE_INTERNAL_API
1136 static NumberFormat* makeInstance(const Locale& desiredLocale,
1137 UNumberFormatStyle style,
1138 UBool mustBeDecimalFormat,
1139 UErrorCode& errorCode);
1140#endif /* U_HIDE_INTERNAL_API */
1141
1142private:
1143
1144 static UBool isStyleSupported(UNumberFormatStyle style);
1145
1153 static NumberFormat* makeInstance(const Locale& desiredLocale,
1154 UNumberFormatStyle style,
1155 UErrorCode& errorCode);
1156
1157 UBool fGroupingUsed;
1158 int32_t fMaxIntegerDigits;
1159 int32_t fMinIntegerDigits;
1160 int32_t fMaxFractionDigits;
1161 int32_t fMinFractionDigits;
1162
1163 protected:
1165 static const int32_t gDefaultMaxIntegerDigits;
1167 static const int32_t gDefaultMinIntegerDigits;
1168
1169 private:
1170 UBool fParseIntegerOnly;
1171 UBool fLenient; // true => lenient parse is enabled
1172
1173 // ISO currency code
1174 char16_t fCurrency[4];
1175
1176 UDisplayContext fCapitalizationContext;
1177
1178 friend class ICUNumberFormatFactory; // access to makeInstance
1179 friend class ICUNumberFormatService;
1180 friend class ::NumberFormatTest; // access to isStyleSupported()
1181};
1182
1183#if !UCONFIG_NO_SERVICE
1192 class U_I18N_API NumberFormatFactory : public UObject {
1193public:
1194
1199 virtual ~NumberFormatFactory();
1200
1207 virtual UBool visible(void) const = 0;
1208
1214 virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const = 0;
1215
1223 virtual NumberFormat* createFormat(const Locale& loc, UNumberFormatStyle formatType) = 0;
1224};
1225
1230 class U_I18N_API SimpleNumberFormatFactory : public NumberFormatFactory {
1231protected:
1236 const UBool _visible;
1237
1242 UnicodeString _id;
1243
1244public:
1248 SimpleNumberFormatFactory(const Locale& locale, UBool visible = true);
1249
1253 virtual ~SimpleNumberFormatFactory();
1254
1258 virtual UBool visible(void) const override;
1259
1263 virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const override;
1264};
1265#endif /* #if !UCONFIG_NO_SERVICE */
1266
1267// -------------------------------------
1268
1269inline UBool
1270NumberFormat::isParseIntegerOnly() const
1271{
1272 return fParseIntegerOnly;
1273}
1274
1275inline UBool
1276NumberFormat::isLenient() const
1277{
1278 return fLenient;
1279}
1280
1281U_NAMESPACE_END
1282
1283#endif /* #if !UCONFIG_NO_FORMATTING */
1284
1285#endif /* U_SHOW_CPLUSPLUS_API */
1286
1287#endif // _NUMFMT
1288//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
Base class for all formats.
Definition format.h:98
icu::Formattable
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition fmtable.h:64
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:195
icu::NumberFormatFactory
A NumberFormatFactory is used to register new number formats.
Definition numfmt.h:1192
icu::NumberFormatFactory::createFormat
virtual NumberFormat * createFormat(const Locale &loc, UNumberFormatStyle formatType)=0
Return a number format of the appropriate type.
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::NumberFormatFactory::visible
virtual UBool visible(void) const =0
Return true if this factory will be visible.
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::getRoundingMode
virtual ERoundingMode getRoundingMode(void) const
Get the rounding mode.
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:1165
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::getMinimumFractionDigits
int32_t getMinimumFractionDigits(void) const
Returns the minimum number of digits allowed in the fraction portion of a 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:1167
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:236
icu::NumberFormat::createInstance
static NumberFormat * createInstance(UErrorCode &)
Create a default style NumberFormat for the current default locale.
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::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::getDynamicClassID
virtual UClassID getDynamicClassID(void) const override=0
Returns a unique class ID POLYMORPHICALLY.
icu::NumberFormat::ERoundingMode
ERoundingMode
Rounding mode.
Definition numfmt.h:186
icu::NumberFormat::kRoundDown
@ kRoundDown
Round towards zero.
Definition numfmt.h:189
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::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:217
icu::NumberFormat::kRoundHalfOdd
@ kRoundHalfOdd
Rounds ties toward the odd number.
Definition numfmt.h:207
icu::NumberFormat::kRoundHalfCeiling
@ kRoundHalfCeiling
Rounds ties toward +∞.
Definition numfmt.h:212
icu::NumberFormat::kRoundUp
@ kRoundUp
Round away from zero.
Definition numfmt.h:190
icu::NumberFormat::format
UnicodeString & format(int32_t number, UnicodeString &appendTo) const
Format a long number.
icu::NumberFormat::getMaximumIntegerDigits
int32_t getMaximumIntegerDigits(void) const
Returns the maximum number of digits allowed in the integer portion of a number.
icu::NumberFormat::getAvailableLocales
static StringEnumeration * getAvailableLocales(void)
Return a StringEnumeration over the locales available at the time of the call, including registered l...
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::getMaximumFractionDigits
int32_t getMaximumFractionDigits(void) const
Returns the maximum number of digits allowed in the fraction portion of a number.
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::createInstance
static NumberFormat * createInstance(const Locale &desiredLocale, UNumberFormatStyle style, UErrorCode &errorCode)
Create a specific style NumberFormat for the specified locale.
icu::NumberFormat::parse
virtual void parse(const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const =0
Return a long if possible (e.g.
icu::NumberFormat::isGroupingUsed
UBool isGroupingUsed(void) const
Returns true if grouping is used in this format.
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::NumberFormat
NumberFormat(const NumberFormat &)
Copy constructor.
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::getStaticClassID
static UClassID getStaticClassID(void)
Return the class ID for this class.
icu::NumberFormat::getMinimumIntegerDigits
int32_t getMinimumIntegerDigits(void) const
Returns the minimum number of digits allowed in the integer portion of a number.
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
A NumberFormatFactory that supports a single locale.
Definition numfmt.h:1230
icu::SimpleNumberFormatFactory::SimpleNumberFormatFactory
SimpleNumberFormatFactory(const Locale &locale, UBool visible=true)
icu::SimpleNumberFormatFactory::visible
virtual UBool visible(void) 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:1242
icu::SimpleNumberFormatFactory::_visible
const UBool _visible
True if the locale supported by this factory is visible.
Definition numfmt.h:1236
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:60
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition uobject.h:223
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:296
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:247
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:415
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:301