decimfmt.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 DECIMFMT.H
*
* Modification History:
*
* Date Name Description
* 02/19/97 aliu Converted from java.
* 03/20/97 clhuang Updated per C++ implementation.
* 04/03/97 aliu Rewrote parsing and formatting completely, and
* cleaned up and debugged. Actually works now.
* 04/17/97 aliu Changed DigitCount to int per code review.
* 07/10/97 helena Made ParsePosition a class and get rid of the function
* hiding problems.
* 09/09/97 aliu Ported over support for exponential formats.
* 07/20/98 stephen Changed documentation
* 01/30/13 emmons Added Scaling methods
********************************************************************************
*/
#ifndef DECIMFMT_H
#define DECIMFMT_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_FORMATTING
#include "unicode/dcfmtsym.h"
#include "unicode/numfmt.h"
#include "unicode/locid.h"
#include "unicode/fpositer.h"
#include "unicode/stringpiece.h"
#include "unicode/curramt.h"
#include "unicode/enumset.h"
U_NAMESPACE_BEGIN
class CurrencyPluralInfo;
class CompactDecimalFormat;
namespace number {
class LocalizedNumberFormatter;
namespace impl {
class DecimalQuantity;
struct DecimalFormatFields;
class UFormattedNumberData;
}
}
namespace numparse::impl {
class NumberParserImpl;
}
class U_I18N_API DecimalFormat : public NumberFormat {
public:
enum EPadPosition {
kPadBeforePrefix, kPadAfterPrefix, kPadBeforeSuffix, kPadAfterSuffix
};
DecimalFormat(UErrorCode& status);
DecimalFormat(const UnicodeString& pattern, UErrorCode& status);
DecimalFormat(const UnicodeString& pattern, DecimalFormatSymbols* symbolsToAdopt, UErrorCode& status);
#ifndef U_HIDE_INTERNAL_API
DecimalFormat(const UnicodeString& pattern, DecimalFormatSymbols* symbolsToAdopt,
UNumberFormatStyle style, UErrorCode& status);
#if UCONFIG_HAVE_PARSEALLINPUT
void setParseAllInput(UNumberFormatAttributeValue value);
#endif
#endif /* U_HIDE_INTERNAL_API */
private:
DecimalFormat(const DecimalFormatSymbols* symbolsToAdopt, UErrorCode& status);
public:
virtual DecimalFormat& setAttribute(UNumberFormatAttribute attr, int32_t newValue, UErrorCode& status);
virtual int32_t getAttribute(UNumberFormatAttribute attr, UErrorCode& status) const;
void setGroupingUsed(UBool newValue) override;
void setParseIntegerOnly(UBool value) override;
void setLenient(UBool enable) override;
DecimalFormat(const UnicodeString& pattern, DecimalFormatSymbols* symbolsToAdopt,
UParseError& parseError, UErrorCode& status);
DecimalFormat(const UnicodeString& pattern, const DecimalFormatSymbols& symbols, UErrorCode& status);
DecimalFormat(const DecimalFormat& source);
DecimalFormat& operator=(const DecimalFormat& rhs);
~DecimalFormat() override;
DecimalFormat* clone() const override;
bool operator==(const Format& other) const override;
using NumberFormat::format;
UnicodeString& format(double number, UnicodeString& appendTo, FieldPosition& pos) const override;
#ifndef U_HIDE_INTERNAL_API
UnicodeString& format(double number, UnicodeString& appendTo, FieldPosition& pos,
UErrorCode& status) const override;
#endif /* U_HIDE_INTERNAL_API */
UnicodeString& format(double number, UnicodeString& appendTo, FieldPositionIterator* posIter,
UErrorCode& status) const override;
UnicodeString& format(int32_t number, UnicodeString& appendTo, FieldPosition& pos) const override;
#ifndef U_HIDE_INTERNAL_API
UnicodeString& format(int32_t number, UnicodeString& appendTo, FieldPosition& pos,
UErrorCode& status) const override;
#endif /* U_HIDE_INTERNAL_API */
UnicodeString& format(int32_t number, UnicodeString& appendTo, FieldPositionIterator* posIter,
UErrorCode& status) const override;
UnicodeString& format(int64_t number, UnicodeString& appendTo, FieldPosition& pos) const override;
#ifndef U_HIDE_INTERNAL_API
UnicodeString& format(int64_t number, UnicodeString& appendTo, FieldPosition& pos,
UErrorCode& status) const override;
#endif /* U_HIDE_INTERNAL_API */
UnicodeString& format(int64_t number, UnicodeString& appendTo, FieldPositionIterator* posIter,
UErrorCode& status) const override;
UnicodeString& format(StringPiece number, UnicodeString& appendTo, FieldPositionIterator* posIter,
UErrorCode& status) const override;
#ifndef U_HIDE_INTERNAL_API
UnicodeString& format(const number::impl::DecimalQuantity& number, UnicodeString& appendTo,
FieldPositionIterator* posIter, UErrorCode& status) const override;
UnicodeString& format(const number::impl::DecimalQuantity& number, UnicodeString& appendTo,
FieldPosition& pos, UErrorCode& status) const override;
#endif // U_HIDE_INTERNAL_API
using NumberFormat::parse;
void parse(const UnicodeString& text, Formattable& result,
ParsePosition& parsePosition) const override;
CurrencyAmount* parseCurrency(const UnicodeString& text, ParsePosition& pos) const override;
virtual const DecimalFormatSymbols* getDecimalFormatSymbols() const;
virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt);
virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols);
virtual const CurrencyPluralInfo* getCurrencyPluralInfo() const;
virtual void adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt);
virtual void setCurrencyPluralInfo(const CurrencyPluralInfo& info);
UnicodeString& getPositivePrefix(UnicodeString& result) const;
virtual void setPositivePrefix(const UnicodeString& newValue);
UnicodeString& getNegativePrefix(UnicodeString& result) const;
virtual void setNegativePrefix(const UnicodeString& newValue);
UnicodeString& getPositiveSuffix(UnicodeString& result) const;
virtual void setPositiveSuffix(const UnicodeString& newValue);
UnicodeString& getNegativeSuffix(UnicodeString& result) const;
virtual void setNegativeSuffix(const UnicodeString& newValue);
UBool isSignAlwaysShown() const;
void setSignAlwaysShown(UBool value);
int32_t getMultiplier() const;
virtual void setMultiplier(int32_t newValue);
int32_t getMultiplierScale() const;
void setMultiplierScale(int32_t newValue);
virtual double getRoundingIncrement() const;
virtual void setRoundingIncrement(double newValue);
virtual ERoundingMode getRoundingMode() const override;
virtual void setRoundingMode(ERoundingMode roundingMode) override;
virtual int32_t getFormatWidth() const;
virtual void setFormatWidth(int32_t width);
virtual UnicodeString getPadCharacterString() const;
virtual void setPadCharacter(const UnicodeString& padChar);
virtual EPadPosition getPadPosition() const;
virtual void setPadPosition(EPadPosition padPos);
virtual UBool isScientificNotation() const;
virtual void setScientificNotation(UBool useScientific);
virtual int8_t getMinimumExponentDigits() const;
virtual void setMinimumExponentDigits(int8_t minExpDig);
virtual UBool isExponentSignAlwaysShown() const;
virtual void setExponentSignAlwaysShown(UBool expSignAlways);
int32_t getGroupingSize() const;
virtual void setGroupingSize(int32_t newValue);
int32_t getSecondaryGroupingSize() const;
virtual void setSecondaryGroupingSize(int32_t newValue);
int32_t getMinimumGroupingDigits() const;
void setMinimumGroupingDigits(int32_t newValue);
UBool isDecimalSeparatorAlwaysShown() const;
virtual void setDecimalSeparatorAlwaysShown(UBool newValue);
UBool isDecimalPatternMatchRequired() const;
virtual void setDecimalPatternMatchRequired(UBool newValue);
UBool isParseNoExponent() const;
void setParseNoExponent(UBool value);
UBool isParseCaseSensitive() const;
void setParseCaseSensitive(UBool value);
UBool isFormatFailIfMoreThanMaxDigits() const;
void setFormatFailIfMoreThanMaxDigits(UBool value);
virtual UnicodeString& toPattern(UnicodeString& result) const;
virtual UnicodeString& toLocalizedPattern(UnicodeString& result) const;
virtual void applyPattern(const UnicodeString& pattern, UParseError& parseError, UErrorCode& status);
virtual void applyPattern(const UnicodeString& pattern, UErrorCode& status);
virtual void applyLocalizedPattern(const UnicodeString& pattern, UParseError& parseError,
UErrorCode& status);
virtual void applyLocalizedPattern(const UnicodeString& pattern, UErrorCode& status);
void setMaximumIntegerDigits(int32_t newValue) override;
void setMinimumIntegerDigits(int32_t newValue) override;
void setMaximumFractionDigits(int32_t newValue) override;
void setMinimumFractionDigits(int32_t newValue) override;
int32_t getMinimumSignificantDigits() const;
int32_t getMaximumSignificantDigits() const;
void setMinimumSignificantDigits(int32_t min);
void setMaximumSignificantDigits(int32_t max);
UBool areSignificantDigitsUsed() const;
void setSignificantDigitsUsed(UBool useSignificantDigits);
void setCurrency(const char16_t* theCurrency, UErrorCode& ec) override;
#ifndef U_FORCE_HIDE_DEPRECATED_API
virtual void setCurrency(const char16_t* theCurrency);
#endif // U_FORCE_HIDE_DEPRECATED_API
void setCurrencyUsage(UCurrencyUsage newUsage, UErrorCode* ec);
UCurrencyUsage getCurrencyUsage() const;
#ifndef U_HIDE_INTERNAL_API
void formatToDecimalQuantity(double number, number::impl::DecimalQuantity& output,
UErrorCode& status) const;
void formatToDecimalQuantity(const Formattable& number, number::impl::DecimalQuantity& output,
UErrorCode& status) const;
#endif /* U_HIDE_INTERNAL_API */
const number::LocalizedNumberFormatter* toNumberFormatter(UErrorCode& status) const;
static UClassID U_EXPORT2 getStaticClassID();
UClassID getDynamicClassID() const override;
private:
void touch(UErrorCode& status);
void touchNoError();
void setPropertiesFromPattern(const UnicodeString& pattern, int32_t ignoreRounding,
UErrorCode& status);
const numparse::impl::NumberParserImpl* getParser(UErrorCode& status) const;
const numparse::impl::NumberParserImpl* getCurrencyParser(UErrorCode& status) const;
static void fieldPositionHelper(
const number::impl::UFormattedNumberData& formatted,
FieldPosition& fieldPosition,
int32_t offset,
UErrorCode& status);
static void fieldPositionIteratorHelper(
const number::impl::UFormattedNumberData& formatted,
FieldPositionIterator* fpi,
int32_t offset,
UErrorCode& status);
void setupFastFormat();
bool fastFormatDouble(double input, UnicodeString& output) const;
bool fastFormatInt64(int64_t input, UnicodeString& output) const;
void doFastFormatInt32(int32_t input, bool isNegative, UnicodeString& output) const;
//=====================================================================================//
// INSTANCE FIELDS //
//=====================================================================================//
// One instance field for the implementation, keep all fields inside of an implementation
// class defined in number_mapper.h
number::impl::DecimalFormatFields* fields = nullptr;
// Allow child class CompactDecimalFormat to access fProperties:
friend class CompactDecimalFormat;
// Allow MeasureFormat to use fieldPositionHelper:
friend class MeasureFormat;
};
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // _DECIMFMT
//eof
icu::CompactDecimalFormat
IMPORTANT: New users are strongly encouraged to see if numberformatter.h fits their use case.
Definition compactdecimalformat.h:63
icu::CurrencyAmount
A currency together with a numeric amount, such as 200 USD.
Definition curramt.h:39
icu::CurrencyPluralInfo
This class represents the information needed by DecimalFormat to format currency plural,...
Definition currpinf.h:48
icu::DecimalFormatSymbols
This class represents the set of symbols needed by DecimalFormat to format numbers.
Definition dcfmtsym.h:86
icu::DecimalFormat
IMPORTANT: New users are strongly encouraged to see if numberformatter.h fits their use case.
Definition decimfmt.h:666
icu::DecimalFormat::getNegativePrefix
UnicodeString & getNegativePrefix(UnicodeString &result) const
Get the negative prefix.
icu::DecimalFormat::isDecimalSeparatorAlwaysShown
UBool isDecimalSeparatorAlwaysShown() const
Allows you to get the behavior of the decimal separator with integers.
icu::DecimalFormat::setMinimumSignificantDigits
void setMinimumSignificantDigits(int32_t min)
Sets the minimum number of significant digits that will be displayed.
icu::DecimalFormat::setParseCaseSensitive
void setParseCaseSensitive(UBool value)
Whether to pay attention to case when parsing; default is to ignore case (perform case-folding).
icu::DecimalFormat::DecimalFormat
DecimalFormat(UErrorCode &status)
Create a DecimalFormat using the default pattern and symbols for the default locale.
icu::DecimalFormat::setSecondaryGroupingSize
virtual void setSecondaryGroupingSize(int32_t newValue)
Set the secondary grouping size.
icu::DecimalFormat::format
UnicodeString & format(const number::impl::DecimalQuantity &number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const override
Format a decimal number.
icu::DecimalFormat::getMaximumSignificantDigits
int32_t getMaximumSignificantDigits() const
Returns the maximum number of significant digits that will be displayed.
icu::DecimalFormat::setDecimalPatternMatchRequired
virtual void setDecimalPatternMatchRequired(UBool newValue)
Allows you to set the parse behavior of the pattern decimal mark.
icu::DecimalFormat::format
UnicodeString & format(int64_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const override
Format an int64 number using base-10 representation.
icu::DecimalFormat::setMaximumIntegerDigits
void setMaximumIntegerDigits(int32_t newValue) override
Sets the maximum number of digits allowed in the integer portion of a number.
icu::DecimalFormat::~DecimalFormat
~DecimalFormat() override
Destructor.
icu::DecimalFormat::applyLocalizedPattern
virtual void applyLocalizedPattern(const UnicodeString &pattern, UErrorCode &status)
Apply the given pattern to this Format object.
icu::DecimalFormat::setPositivePrefix
virtual void setPositivePrefix(const UnicodeString &newValue)
Set the positive prefix.
icu::DecimalFormat::setDecimalSeparatorAlwaysShown
virtual void setDecimalSeparatorAlwaysShown(UBool newValue)
Allows you to set the behavior of the decimal separator with integers.
icu::DecimalFormat::applyPattern
virtual void applyPattern(const UnicodeString &pattern, UParseError &parseError, UErrorCode &status)
Apply the given pattern to this Format object.
icu::DecimalFormat::format
UnicodeString & format(double number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const override
Format a double or long number using base-10 representation.
icu::DecimalFormat::getGroupingSize
int32_t getGroupingSize() const
Return the grouping size.
icu::DecimalFormat::isFormatFailIfMoreThanMaxDigits
UBool isFormatFailIfMoreThanMaxDigits() const
Returns whether truncation of high-order integer digits should result in an error.
icu::DecimalFormat::getPadPosition
virtual EPadPosition getPadPosition() const
Get the position at which padding will take place.
icu::DecimalFormat::getPositivePrefix
UnicodeString & getPositivePrefix(UnicodeString &result) const
Get the positive prefix.
icu::DecimalFormat::operator==
bool operator==(const Format &other) const override
Return true if the given Format objects are semantically equal.
icu::DecimalFormat::setSignificantDigitsUsed
void setSignificantDigitsUsed(UBool useSignificantDigits)
Sets whether significant digits are in use, or integer and fraction digit counts are in use.
icu::DecimalFormat::getRoundingIncrement
virtual double getRoundingIncrement() const
Get the rounding increment.
icu::DecimalFormat::setParseNoExponent
void setParseNoExponent(UBool value)
Specifies whether to stop parsing when an exponent separator is encountered.
icu::DecimalFormat::toLocalizedPattern
virtual UnicodeString & toLocalizedPattern(UnicodeString &result) const
Synthesizes a localized pattern string that represents the current state of this Format object.
icu::DecimalFormat::getMinimumSignificantDigits
int32_t getMinimumSignificantDigits() const
Returns the minimum number of significant digits that will be displayed.
icu::DecimalFormat::getPositiveSuffix
UnicodeString & getPositiveSuffix(UnicodeString &result) const
Get the positive suffix.
icu::DecimalFormat::getMultiplier
int32_t getMultiplier() const
Get the multiplier for use in percent, permill, etc.
icu::DecimalFormat::getDynamicClassID
UClassID getDynamicClassID() const override
Returns a unique class ID POLYMORPHICALLY.
icu::DecimalFormat::format
UnicodeString & format(int64_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const override
Format an int64 number using base-10 representation.
icu::DecimalFormat::setPadPosition
virtual void setPadPosition(EPadPosition padPos)
Set the position at which padding will take place.
icu::DecimalFormat::setNegativePrefix
virtual void setNegativePrefix(const UnicodeString &newValue)
Set the negative prefix.
icu::DecimalFormat::setRoundingIncrement
virtual void setRoundingIncrement(double newValue)
Set the rounding increment.
icu::DecimalFormat::setCurrencyPluralInfo
virtual void setCurrencyPluralInfo(const CurrencyPluralInfo &info)
Sets the currency plural format information, which is generally not changed by the programmer or user...
icu::DecimalFormat::setDecimalFormatSymbols
virtual void setDecimalFormatSymbols(const DecimalFormatSymbols &symbols)
Sets the decimal format symbols, which is generally not changed by the programmer or user.
icu::DecimalFormat::setMinimumGroupingDigits
void setMinimumGroupingDigits(int32_t newValue)
Sets the minimum grouping digits.
icu::DecimalFormat::format
UnicodeString & format(double number, UnicodeString &appendTo, FieldPosition &pos) const override
Format a double or long number using base-10 representation.
icu::DecimalFormat::getStaticClassID
static UClassID getStaticClassID()
Return the class ID for this class.
icu::DecimalFormat::DecimalFormat
DecimalFormat(const UnicodeString &pattern, DecimalFormatSymbols *symbolsToAdopt, UErrorCode &status)
Create a DecimalFormat from the given pattern and symbols.
icu::DecimalFormat::getMinimumExponentDigits
virtual int8_t getMinimumExponentDigits() const
Return the minimum exponent digits that will be shown.
icu::DecimalFormat::setCurrency
virtual void setCurrency(const char16_t *theCurrency)
Sets the currency used to display currency amounts.
icu::DecimalFormat::getMinimumGroupingDigits
int32_t getMinimumGroupingDigits() const
Returns the minimum number of grouping digits.
icu::DecimalFormat::setMinimumFractionDigits
void setMinimumFractionDigits(int32_t newValue) override
Sets the minimum number of digits allowed in the fraction portion of a number.
icu::DecimalFormat::format
UnicodeString & format(int32_t number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const override
Format a long number using base-10 representation.
icu::DecimalFormat::setMaximumSignificantDigits
void setMaximumSignificantDigits(int32_t max)
Sets the maximum number of significant digits that will be displayed.
icu::DecimalFormat::setFormatWidth
virtual void setFormatWidth(int32_t width)
Set the width to which the output of format() is padded.
icu::DecimalFormat::formatToDecimalQuantity
void formatToDecimalQuantity(const Formattable &number, number::impl::DecimalQuantity &output, UErrorCode &status) const
Get a DecimalQuantity corresponding to a formattable as it would be formatted by this DecimalFormat.
icu::DecimalFormat::setSignAlwaysShown
void setSignAlwaysShown(UBool value)
Set whether to show the plus sign on positive (non-negative) numbers; for example,...
icu::DecimalFormat::format
UnicodeString & format(int64_t number, UnicodeString &appendTo, FieldPosition &pos) const override
Format an int64 number using base-10 representation.
icu::DecimalFormat::format
UnicodeString & format(int32_t number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const override
Format a long number using base-10 representation.
icu::DecimalFormat::getMultiplierScale
int32_t getMultiplierScale() const
Gets the power of ten by which number should be multiplied before formatting, which can be combined w...
icu::DecimalFormat::format
UnicodeString & format(double number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const override
Format a double or long number using base-10 representation.
icu::DecimalFormat::setExponentSignAlwaysShown
virtual void setExponentSignAlwaysShown(UBool expSignAlways)
Set whether the exponent sign is always shown.
icu::DecimalFormat::getCurrencyUsage
UCurrencyUsage getCurrencyUsage() const
Returns the Currency Usage object used to display currency.
icu::DecimalFormat::format
UnicodeString & format(int32_t number, UnicodeString &appendTo, FieldPosition &pos) const override
Format a long number using base-10 representation.
icu::DecimalFormat::getDecimalFormatSymbols
virtual const DecimalFormatSymbols * getDecimalFormatSymbols() const
Returns the decimal format symbols, which is generally not changed by the programmer or user.
icu::DecimalFormat::isScientificNotation
virtual UBool isScientificNotation() const
Return whether or not scientific notation is used.
icu::DecimalFormat::setGroupingUsed
void setGroupingUsed(UBool newValue) override
Set whether or not grouping will be used in this format.
icu::DecimalFormat::DecimalFormat
DecimalFormat(const UnicodeString &pattern, UErrorCode &status)
Create a DecimalFormat from the given pattern and the symbols for the default locale.
icu::DecimalFormat::isParseCaseSensitive
UBool isParseCaseSensitive() const
Returns whether parsing is sensitive to case (lowercase/uppercase).
icu::DecimalFormat::setMaximumFractionDigits
void setMaximumFractionDigits(int32_t newValue) override
Sets the maximum number of digits allowed in the fraction portion of a number.
icu::DecimalFormat::setNegativeSuffix
virtual void setNegativeSuffix(const UnicodeString &newValue)
Set the negative suffix.
icu::DecimalFormat::getFormatWidth
virtual int32_t getFormatWidth() const
Get the width to which the output of format() is padded.
icu::DecimalFormat::setScientificNotation
virtual void setScientificNotation(UBool useScientific)
Set whether or not scientific notation is used.
icu::DecimalFormat::DecimalFormat
DecimalFormat(const DecimalFormat &source)
Copy constructor.
icu::DecimalFormat::formatToDecimalQuantity
void formatToDecimalQuantity(double number, number::impl::DecimalQuantity &output, UErrorCode &status) const
Format a number and save it into the given DecimalQuantity.
icu::DecimalFormat::clone
DecimalFormat * clone() const override
Clone this Format object polymorphically.
icu::DecimalFormat::isSignAlwaysShown
UBool isSignAlwaysShown() const
Whether to show the plus sign on positive (non-negative) numbers; for example, "+12".
icu::DecimalFormat::setFormatFailIfMoreThanMaxDigits
void setFormatFailIfMoreThanMaxDigits(UBool value)
Sets whether truncation of high-order integer digits should result in an error.
icu::DecimalFormat::setPositiveSuffix
virtual void setPositiveSuffix(const UnicodeString &newValue)
Set the positive suffix.
icu::DecimalFormat::setGroupingSize
virtual void setGroupingSize(int32_t newValue)
Set the grouping size.
icu::DecimalFormat::parseCurrency
CurrencyAmount * parseCurrency(const UnicodeString &text, ParsePosition &pos) const override
Parses text from the given string as a currency amount.
icu::DecimalFormat::areSignificantDigitsUsed
UBool areSignificantDigitsUsed() const
Returns true if significant digits are in use, or false if integer and fraction digit counts are in u...
icu::DecimalFormat::setMultiplierScale
void setMultiplierScale(int32_t newValue)
Sets a power of ten by which number should be multiplied before formatting, which can be combined wit...
icu::DecimalFormat::DecimalFormat
DecimalFormat(const UnicodeString &pattern, DecimalFormatSymbols *symbolsToAdopt, UParseError &parseError, UErrorCode &status)
Create a DecimalFormat from the given pattern and symbols.
icu::DecimalFormat::setAttribute
virtual DecimalFormat & setAttribute(UNumberFormatAttribute attr, int32_t newValue, UErrorCode &status)
Set an integer attribute on this DecimalFormat.
icu::DecimalFormat::format
UnicodeString & format(StringPiece number, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const override
Format a decimal number.
icu::DecimalFormat::setMinimumExponentDigits
virtual void setMinimumExponentDigits(int8_t minExpDig)
Set the minimum exponent digits that will be shown.
icu::DecimalFormat::applyPattern
virtual void applyPattern(const UnicodeString &pattern, UErrorCode &status)
Sets the pattern.
icu::DecimalFormat::getRoundingMode
virtual ERoundingMode getRoundingMode() const override
Get the rounding mode.
icu::DecimalFormat::toNumberFormatter
const number::LocalizedNumberFormatter * toNumberFormatter(UErrorCode &status) const
Converts this DecimalFormat to a (Localized)NumberFormatter.
icu::DecimalFormat::setLenient
void setLenient(UBool enable) override
Sets whether lenient parsing should be enabled (it is off by default).
icu::DecimalFormat::setCurrencyUsage
void setCurrencyUsage(UCurrencyUsage newUsage, UErrorCode *ec)
Sets the Currency Usage object used to display currency.
icu::DecimalFormat::isDecimalPatternMatchRequired
UBool isDecimalPatternMatchRequired() const
Allows you to get the parse behavior of the pattern decimal mark.
icu::DecimalFormat::setCurrency
void setCurrency(const char16_t *theCurrency, UErrorCode &ec) override
Sets the currency used to display currency amounts.
icu::DecimalFormat::getAttribute
virtual int32_t getAttribute(UNumberFormatAttribute attr, UErrorCode &status) const
Get an integer May return U_UNSUPPORTED_ERROR if this instance does not support the specified attribu...
icu::DecimalFormat::setMinimumIntegerDigits
void setMinimumIntegerDigits(int32_t newValue) override
Sets the minimum number of digits allowed in the integer portion of a number.
icu::DecimalFormat::adoptDecimalFormatSymbols
virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols *symbolsToAdopt)
Sets the decimal format symbols, which is generally not changed by the programmer or user.
icu::DecimalFormat::getPadCharacterString
virtual UnicodeString getPadCharacterString() const
Get the pad character used to pad to the format width.
icu::DecimalFormat::setMultiplier
virtual void setMultiplier(int32_t newValue)
Set the multiplier for use in percent, permill, etc.
icu::DecimalFormat::applyLocalizedPattern
virtual void applyLocalizedPattern(const UnicodeString &pattern, UParseError &parseError, UErrorCode &status)
Apply the given pattern to this Format object.
icu::DecimalFormat::EPadPosition
EPadPosition
Pad position.
Definition decimfmt.h:672
icu::DecimalFormat::getSecondaryGroupingSize
int32_t getSecondaryGroupingSize() const
Return the secondary grouping size.
icu::DecimalFormat::getNegativeSuffix
UnicodeString & getNegativeSuffix(UnicodeString &result) const
Get the negative suffix.
icu::DecimalFormat::isParseNoExponent
UBool isParseNoExponent() const
Returns whether to ignore exponents when parsing.
icu::DecimalFormat::setParseIntegerOnly
void setParseIntegerOnly(UBool value) override
Sets whether or not numbers should be parsed as integers only.
icu::DecimalFormat::operator=
DecimalFormat & operator=(const DecimalFormat &rhs)
Assignment operator.
icu::DecimalFormat::getCurrencyPluralInfo
virtual const CurrencyPluralInfo * getCurrencyPluralInfo() const
Returns the currency plural format information, which is generally not changed by the programmer or u...
icu::DecimalFormat::toPattern
virtual UnicodeString & toPattern(UnicodeString &result) const
Synthesizes a pattern string that represents the current state of this Format object.
icu::DecimalFormat::adoptCurrencyPluralInfo
virtual void adoptCurrencyPluralInfo(CurrencyPluralInfo *toAdopt)
Sets the currency plural format information, which is generally not changed by the programmer or user...
icu::DecimalFormat::isExponentSignAlwaysShown
virtual UBool isExponentSignAlwaysShown() const
Return whether the exponent sign is always shown.
icu::DecimalFormat::setRoundingMode
virtual void setRoundingMode(ERoundingMode roundingMode) override
Set the rounding mode.
icu::DecimalFormat::format
UnicodeString & format(const number::impl::DecimalQuantity &number, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const override
Format a decimal number.
icu::DecimalFormat::setPadCharacter
virtual void setPadCharacter(const UnicodeString &padChar)
Set the character used to pad to the format width.
icu::DecimalFormat::DecimalFormat
DecimalFormat(const UnicodeString &pattern, const DecimalFormatSymbols &symbols, UErrorCode &status)
Create a DecimalFormat from the given pattern and symbols.
icu::DecimalFormat::parse
void parse(const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const override
Parse the given string using this object's choices.
icu::DecimalFormat::DecimalFormat
DecimalFormat(const UnicodeString &pattern, DecimalFormatSymbols *symbolsToAdopt, UNumberFormatStyle style, UErrorCode &status)
This API is for ICU use only.
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:63
icu::LocalPointerBase
"Smart pointer" base class; do not use directly: use LocalPointer etc.
Definition localpointer.h:68
icu::MeasureFormat
Definition measfmt.h:101
icu::NumberFormat
Definition numfmt.h:175
icu::NumberFormat::ERoundingMode
ERoundingMode
Rounding mode.
Definition numfmt.h:186
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::StringPiece
A string-like object that points to a sized piece of memory.
Definition stringpiece.h:61
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:296
icu::number::LocalizedNumberFormatter
A NumberFormatter that has a locale associated with it; this means .format() methods are available.
Definition numberformatter.h:2521
curramt.h
C++ API: Currency Amount Object.
dcfmtsym.h
C++ API: Symbols for formatting numbers.
enumset.h
C++: internal template EnumSet<>
fpositer.h
C++ API: FieldPosition Iterator.
locid.h
C++ API: Locale ID object.
numfmt.h
C++ API: Compatibility APIs for number formatting.
stringpiece.h
C++ API: StringPiece: Read-only byte string wrapper class.
UParseError
A UParseError struct is used to returned detailed information about parsing errors.
Definition parseerr.h:58
UCurrencyUsage
UCurrencyUsage
Currency Usage used for Decimal Format.
Definition ucurr.h:41
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:247
UNumberFormatAttribute
UNumberFormatAttribute
The possible UNumberFormat numeric attributes.
Definition unum.h:970
UNumberFormatStyle
UNumberFormatStyle
The possible number format styles.
Definition unum.h:150
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:430
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