4#ifndef __NUMBERFORMATTER_H__ 
    5#define __NUMBERFORMATTER_H__ 
    9#if U_SHOW_CPLUSPLUS_API 
   11#if !UCONFIG_NO_FORMATTING 
   93class FieldPositionIteratorHandler;
 
   94class FormattedStringBuilder;
 
   96namespace numparse::impl {
 
   99class NumberParserImpl;
 
  100class MultiplierParseHandler;
 
  114class UnlocalizedNumberFormatter;
 
  115class LocalizedNumberFormatter;
 
  116class SimpleNumberFormatter;
 
  117class FormattedNumber;
 
  119class ScientificNotation;
 
  121class FractionPrecision;
 
  122class CurrencyPrecision;
 
  123class IncrementPrecision;
 
  143static constexpr int32_t kInternalDefaultThreshold = 3;
 
  149class DecimalQuantity;
 
  151class NumberFormatterImpl;
 
  153class ScientificModifier;
 
  156class ScientificHandler;
 
  159class NumberPropertyMapper;
 
  161class MultiplierFormatHandler;
 
  163class GeneratorHelpers;
 
  165class NumberRangeFormatterImpl;
 
  167struct UFormattedNumberImpl;
 
  168class MutablePatternModifier;
 
  169class ImmutablePatternModifier;
 
  171struct SimpleMicroProps;
 
  350        NTN_SCIENTIFIC, NTN_COMPACT, NTN_SIMPLE, NTN_ERROR
 
  353    union NotationUnion {
 
  376    Notation(
const NotationType &type, 
const NotationUnion &
union_) : fType(type), fUnion(
union_) {}
 
  379        fUnion.errorCode = errorCode;
 
  382    Notation() : fType(NTN_SIMPLE), fUnion() {}
 
  385        if (fType == NTN_ERROR) {
 
  386            status = fUnion.errorCode;
 
  393    friend struct impl::MacroProps;
 
  394    friend class ScientificNotation;
 
  397    friend class impl::NumberFormatterImpl;
 
  398    friend class impl::ScientificModifier;
 
  399    friend class impl::ScientificHandler;
 
  402    friend class impl::GeneratorHelpers;
 
 
  447    using Notation::Notation;
 
  456    friend class impl::NumberPropertyMapper;
 
 
  708        RND_FRACTION_SIGNIFICANT,
 
  725    union PrecisionUnion {
 
  767            : fType(type), fUnion(
union_) {}
 
  770        fUnion.errorCode = errorCode;
 
  773    Precision() : fType(RND_BOGUS) {}
 
  775    bool isBogus()
 const {
 
  776        return fType == RND_BOGUS;
 
  780        if (fType == RND_ERROR) {
 
  781            status = fUnion.errorCode;
 
  788    Precision withCurrency(
const CurrencyUnit ¤cy, 
UErrorCode &status) 
const;
 
  790    static FractionPrecision constructFraction(int32_t minFrac, int32_t maxFrac);
 
  792    static Precision constructSignificant(int32_t minSig, int32_t maxSig);
 
  794    static Precision constructFractionSignificant(
 
  795        const FractionPrecision &base,
 
  801    static IncrementPrecision constructIncrement(uint64_t increment, impl::digits_t magnitude);
 
  806    friend struct impl::MacroProps;
 
  807    friend struct impl::MicroProps;
 
  810    friend class impl::NumberFormatterImpl;
 
  813    friend class impl::NumberPropertyMapper;
 
  816    friend class impl::RoundingImpl;
 
  819    friend class FractionPrecision;
 
  820    friend class CurrencyPrecision;
 
  821    friend class IncrementPrecision;
 
  824    friend class impl::GeneratorHelpers;
 
  827    friend class units::UnitsRouter;
 
 
  900    using Precision::Precision;
 
 
  938    using Precision::Precision;
 
 
  974    using Precision::Precision;
 
 
 1022            bool fFormatFailIfMoreThanMaxDigits;
 
 1026    bool fHasError = 
false;
 
 1031        fUnion.errorCode = errorCode;
 
 1036        fUnion.minMaxInt.fMinInt = -1;
 
 1040    static IntegerWidth standard() {
 
 1041        return IntegerWidth::zeroFillTo(1);
 
 1044    bool isBogus()
 const {
 
 1045        return !fHasError && fUnion.minMaxInt.fMinInt == -1;
 
 1050            status = fUnion.errorCode;
 
 1056    void apply(impl::DecimalQuantity &quantity, 
UErrorCode &status) 
const;
 
 1058    bool operator==(
const IntegerWidth& other) 
const;
 
 1061    friend struct impl::MacroProps;
 
 1062    friend struct impl::MicroProps;
 
 1065    friend class impl::NumberFormatterImpl;
 
 1068    friend class impl::MutablePatternModifier;
 
 1069    friend class impl::ImmutablePatternModifier;
 
 1072    friend class impl::NumberPropertyMapper;
 
 1075    friend class impl::GeneratorHelpers;
 
 
 1158#ifndef U_HIDE_INTERNAL_API 
 1165    impl::DecNum* fArbitrary;
 
 1172    bool isValid()
 const {
 
 1173        return fMagnitude != 0 || fArbitrary != 
nullptr;
 
 1184    void applyTo(impl::DecimalQuantity& quantity) 
const;
 
 1186    void applyReciprocalTo(impl::DecimalQuantity& quantity) 
const;
 
 1189    friend struct impl::MacroProps;
 
 1190    friend struct impl::MicroProps;
 
 1193    friend class impl::NumberFormatterImpl;
 
 1196    friend class impl::MultiplierFormatHandler;
 
 1199    friend class impl::GeneratorHelpers;
 
 1202    friend class ::icu::numparse::impl::NumberParserImpl;
 
 1203    friend class ::icu::numparse::impl::MultiplierParseHandler;
 
 
 1214class U_I18N_API StringProp : 
public UMemory {
 
 1221    StringProp(
const StringProp &other);
 
 1224    StringProp &operator=(
const StringProp &other);
 
 1226#ifndef U_HIDE_INTERNAL_API 
 1229    StringProp(StringProp &&src) 
noexcept;
 
 1232    StringProp &operator=(StringProp &&src) 
noexcept;
 
 1235    int16_t length()
 const {
 
 1242    void set(StringPiece value);
 
 1245    bool isSet()
 const {
 
 1256    StringProp() : fValue(nullptr), fLength(0), fError(
U_ZERO_ERROR) {
 
 1269    friend class impl::NumberFormatterImpl;
 
 1272    friend class impl::GeneratorHelpers;
 
 1276    friend struct impl::MacroProps;
 
 1281class U_I18N_API SymbolsWrapper : 
public UMemory {
 
 1284    SymbolsWrapper() : fType(SYMPTR_NONE), fPtr{nullptr} {}
 
 1287    SymbolsWrapper(
const SymbolsWrapper &other);
 
 1290    SymbolsWrapper &operator=(
const SymbolsWrapper &other);
 
 1293    SymbolsWrapper(SymbolsWrapper&& src) 
noexcept;
 
 1296    SymbolsWrapper &operator=(SymbolsWrapper&& src) 
noexcept;
 
 1301#ifndef U_HIDE_INTERNAL_API 
 1307    void setTo(
const DecimalFormatSymbols &dfs);
 
 1313    void setTo(
const NumberingSystem *ns);
 
 1319    bool isDecimalFormatSymbols() 
const;
 
 1325    bool isNumberingSystem() 
const;
 
 1331    const DecimalFormatSymbols *getDecimalFormatSymbols() 
const;
 
 1337    const NumberingSystem *getNumberingSystem() 
const;
 
 1343        if (fType == SYMPTR_DFS && fPtr.dfs == 
nullptr) {
 
 1346        } 
else if (fType == SYMPTR_NS && fPtr.ns == 
nullptr) {
 
 1354    enum SymbolsPointerType {
 
 1355        SYMPTR_NONE, SYMPTR_DFS, SYMPTR_NS
 
 1359        const DecimalFormatSymbols *dfs;
 
 1360        const NumberingSystem *ns;
 
 1363    void doCopyFrom(
const SymbolsWrapper &other);
 
 1365    void doMoveFrom(SymbolsWrapper&& src);
 
 1374#ifndef U_HIDE_INTERNAL_API 
 1382    static Grouper forProperties(
const DecimalFormatProperties& properties);
 
 1388            : fGrouping1(grouping1),
 
 1389              fGrouping2(grouping2),
 
 1390              fMinGrouping(minGrouping),
 
 1391              fStrategy(strategy) {}
 
 1394    int16_t getPrimary() 
const;
 
 1397    int16_t getSecondary() 
const;
 
 1419    int16_t fMinGrouping;
 
 1427    Grouper() : fGrouping1(-3) {}
 
 1429    bool isBogus()
 const {
 
 1430        return fGrouping1 == -3;
 
 1434    void setLocaleData(
const impl::ParsedPatternInfo &patternInfo, 
const Locale& locale);
 
 1436    bool groupAtPosition(int32_t position, 
const impl::DecimalQuantity &value) 
const;
 
 1439    friend struct MacroProps;
 
 1440    friend struct MicroProps;
 
 1441    friend struct SimpleMicroProps;
 
 1444    friend class NumberFormatterImpl;
 
 1445    friend class ::icu::number::SimpleNumberFormatter;
 
 1448    friend class ::icu::numparse::impl::NumberParserImpl;
 
 1451    friend class impl::GeneratorHelpers;
 
 1458#ifndef U_HIDE_INTERNAL_API 
 1460    static Padder none();
 
 1466    static Padder forProperties(
const DecimalFormatProperties& properties);
 
 1481    Padder(int32_t width);
 
 1484        fUnion.errorCode = errorCode;
 
 1487    Padder() : fWidth(-2) {} 
 
 1489    bool isBogus()
 const {
 
 1490        return fWidth == -2;
 
 1495            status = fUnion.errorCode;
 
 1501    bool isValid()
 const {
 
 1505    int32_t padAndApply(
const impl::Modifier &mod1, 
const impl::Modifier &mod2,
 
 1506                        FormattedStringBuilder &
string, int32_t leftIndex, int32_t rightIndex,
 
 1510    friend struct MacroProps;
 
 1511    friend struct MicroProps;
 
 1514    friend class impl::NumberFormatterImpl;
 
 1517    friend class impl::GeneratorHelpers;
 
 1522struct U_I18N_API MacroProps : 
public UMemory {
 
 1530    MeasureUnit perUnit;  
 
 1533    Precision precision;  
 
 1545    IntegerWidth integerWidth; 
 
 1548    SymbolsWrapper symbols;
 
 1559    bool approximately = 
false;
 
 1571    StringProp unitDisplayCase;  
 
 1574    const AffixPatternProvider* affixProvider = 
nullptr;  
 
 1577    const PluralRules* rules = 
nullptr;  
 
 1580    int32_t threshold = kInternalDefaultThreshold;
 
 1592        return notation.copyErrorTo(status) || precision.copyErrorTo(status) ||
 
 1593               padder.copyErrorTo(status) || integerWidth.copyErrorTo(status) ||
 
 1594               symbols.copyErrorTo(status) || scale.copyErrorTo(status) || usage.copyErrorTo(status) ||
 
 1595               unitDisplayCase.copyErrorTo(status);
 
 1601#if (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN) && defined(_MSC_VER) 
 1607#pragma warning(push) 
 1608#pragma warning(disable: 4661) 
 1616template<
typename Derived>
 
 2280#ifndef U_HIDE_INTERNAL_API 
 2305#ifndef U_HIDE_INTERNAL_API 
 2405    impl::MacroProps fMacros;
 
 2415    friend class impl::NumberRangeFormatterImpl;
 
 
 2565#ifndef U_HIDE_INTERNAL_API 
 2612#ifndef U_HIDE_DRAFT_API 
 2664#ifndef U_HIDE_INTERNAL_API 
 2691    const impl::NumberFormatterImpl* fCompiled {
nullptr};
 
 2692    char fUnsafeCallCount[8] {};  
 
 2696    const impl::DecimalFormatWarehouse* fWarehouse {
nullptr};
 
 2698    explicit LocalizedNumberFormatter(
const NumberFormatterSettings<LocalizedNumberFormatter>& other);
 
 2700    explicit LocalizedNumberFormatter(NumberFormatterSettings<LocalizedNumberFormatter>&& src) 
noexcept;
 
 2702    LocalizedNumberFormatter(
const impl::MacroProps ¯os, 
const Locale &locale);
 
 2704    LocalizedNumberFormatter(impl::MacroProps &¯os, 
const Locale &locale);
 
 2706    void resetCompiled();
 
 2708    void lnfMoveHelper(LocalizedNumberFormatter&& src);
 
 2710    void lnfCopyHelper(
const LocalizedNumberFormatter& src, 
UErrorCode& status);
 
 2715    bool computeCompiled(
UErrorCode& status) 
const;
 
 2718    friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
 
 2719    friend class NumberFormatterSettings<LocalizedNumberFormatter>;
 
 2722    friend class UnlocalizedNumberFormatter;
 
 
 2725#if (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN) && defined(_MSC_VER) 
C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (char16_ts).
 
C++ API: Interface for writing bytes, and implementation classes.
 
A unit of currency, such as USD (U.S.
 
Represents all the display options that are supported by CLDR such as grammatical case,...
 
"Smart pointer" base class; do not use directly: use LocalPointer etc.
 
"Smart pointer" class, deletes objects via the standard C++ delete operator.
 
A Locale object represents a specific geographical, political, or cultural region.
 
A unit such as length, mass, volume, currency, etc.
 
Defines numbering systems.
 
A string-like object that points to a sized piece of memory.
 
UMemory is the common ICU base class.
 
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
 
A class that defines a rounding precision parameterized by a currency to be used when formatting numb...
 
Precision withCurrency(const CurrencyUnit ¤cy) const
Associates a currency with this rounding precision.
 
A class that defines a rounding precision based on a number of fraction places and optionally signifi...
 
Precision withMinDigits(int32_t minSignificantDigits) const
Ensure that no less than this number of significant digits are retained when rounding according to fr...
 
Precision withSignificantDigits(int32_t minSignificantDigits, int32_t maxSignificantDigits, UNumberRoundingPriority priority) const
Override maximum fraction digits with maximum significant digits depending on the magnitude of the nu...
 
Precision withMaxDigits(int32_t maxSignificantDigits) const
Ensure that no more than this number of significant digits are retained when rounding according to fr...
 
A class that defines a rounding precision parameterized by a rounding increment to be used when forma...
 
Precision withMinFraction(int32_t minFrac) const
Specifies the minimum number of fraction digits to render after the decimal separator,...
 
A class that defines the strategy for padding and truncating integers before the decimal separator.
 
static IntegerWidth zeroFillTo(int32_t minInt)
Pad numbers at the beginning with zeros to guarantee a certain number of numerals before the decimal ...
 
IntegerWidth truncateAt(int32_t maxInt)
Truncate numbers exceeding a certain number of numerals before the decimal separator.
 
A class that defines the notation style to be used when formatting numbers in NumberFormatter.
 
static CompactNotation compactShort()
Print the number using short-form compact notation.
 
static ScientificNotation engineering()
Print the number using engineering notation, a variant of scientific notation in which the exponent m...
 
static CompactNotation compactLong()
Print the number using long-form compact notation.
 
static SimpleNotation simple()
Print the number using simple notation without any scaling by powers of ten.
 
static ScientificNotation scientific()
Print the number using scientific notation (also known as scientific form, standard index form,...
 
A class that defines the rounding precision to be used when formatting numbers in NumberFormatter.
 
static SignificantDigitsPrecision maxSignificantDigits(int32_t maxSignificantDigits)
Show numbers rounded if necessary to a certain number of significant digits/figures.
 
static FractionPrecision fixedFraction(int32_t minMaxFractionPlaces)
Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal ...
 
static SignificantDigitsPrecision minSignificantDigits(int32_t minSignificantDigits)
Always show at least a certain number of significant digits/figures, padding with zeros if necessary.
 
static FractionPrecision maxFraction(int32_t maxFractionPlaces)
Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal ...
 
static IncrementPrecision increment(double roundingIncrement)
Show numbers rounded if necessary to the closest multiple of a certain rounding increment.
 
static CurrencyPrecision currency(UCurrencyUsage currencyUsage)
Show numbers rounded and padded according to the rules for the currency unit.
 
static FractionPrecision minFraction(int32_t minFractionPlaces)
Always show at least a certain number of fraction places after the decimal separator,...
 
Precision trailingZeroDisplay(UNumberTrailingZeroDisplay trailingZeroDisplay) const
Configure how trailing zeros are displayed on numbers.
 
static Precision unlimited()
Show all available digits to full precision.
 
static FractionPrecision integer()
Show numbers rounded if necessary to the nearest integer.
 
static SignificantDigitsPrecision fixedSignificantDigits(int32_t minMaxSignificantDigits)
Show numbers rounded if necessary to a certain number of significant digits or significant figures.
 
static IncrementPrecision incrementExact(uint64_t mantissa, int16_t magnitude)
Version of Precision::increment() that takes an integer at a particular power of 10.
 
static FractionPrecision minMaxFraction(int32_t minFractionPlaces, int32_t maxFractionPlaces)
Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal ...
 
static SignificantDigitsPrecision minMaxSignificantDigits(int32_t minSignificantDigits, int32_t maxSignificantDigits)
Show numbers rounded if necessary to a certain number of significant digits/figures; in addition,...
 
A class that defines a quantity by which a number should be multiplied when formatting.
 
static Scale none()
Do not change the value of numbers when formatting or parsing.
 
static Scale powerOfTen(int32_t power)
Multiply numbers by a power of ten before formatting.
 
Scale(const Scale &other)
 
static Scale byDoubleAndPowerOfTen(double multiplicand, int32_t power)
Multiply a number by both a power of ten and by an arbitrary double value.
 
static Scale byDecimal(StringPiece multiplicand)
Multiply numbers by an arbitrary value before formatting.
 
Scale(int32_t magnitude, impl::DecNum *arbitraryToAdopt)
 
Scale & operator=(const Scale &other)
 
Scale(Scale &&src) noexcept
 
Scale & operator=(Scale &&src) noexcept
 
static Scale byDouble(double multiplicand)
Multiply numbers by an arbitrary value before formatting.
 
A class that defines the scientific notation style to be used when formatting numbers in NumberFormat...
 
ScientificNotation withExponentSignDisplay(UNumberSignDisplay exponentSignDisplay) const
Sets whether to show the sign on positive and negative exponents in scientific notation.
 
ScientificNotation withMinExponentDigits(int32_t minExponentDigits) const
Sets the minimum number of digits to show in the exponent of scientific notation, padding with zeros ...
 
C++ API: Currency Unit Information.
 
C++ API: Symbols for formatting numbers.
 
C++ API: Display options class.
 
C++ API: FieldPosition identifies the fields in a formatted output.
 
C++ API: FieldPosition Iterator.
 
C++ API: A unit for measuring a quantity.
 
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
 
C++ API: units for percent and permille.
 
C API: Parse Error Information.
 
C++ API: PluralRules object.
 
A UParseError struct is used to returned detailed information about parsing errors.
 
impl::digits_t fMinExponentDigits
 
UNumberSignDisplay fExponentSignDisplay
 
int8_t fEngineeringInterval
 
bool fRetain
Whether to retain trailing zeros based on the looser strategy.
 
UNumberRoundingPriority fPriority
 
impl::digits_t fIncrementMagnitude
 
C API: Encapsulates information about a currency.
 
UCurrencyUsage
Currency Usage used for Decimal Format.
 
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
 
int8_t UBool
The ICU boolean type, a signed-byte integer.
 
C API: Compatibility APIs for number formatting.
 
UNumberCompactStyle
Constants for specifying short or long format.
 
UNumberFormatPadPosition
The possible number format pad positions.
 
C API: Header-only input options for various number formatting APIs.
 
UNumberFormatRoundingMode
The possible number format rounding modes.
 
@ UNUM_ROUND_HALFEVEN
Half-even rounding.
 
UNumberGroupingStrategy
An enum declaring the strategy for when and how to display grouping separators (i....
 
C++ API: Common ICU base class UObject.
 
Basic definitions for ICU, for both C and C++ APIs.
 
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
 
@ U_MEMORY_ALLOCATION_ERROR
Memory allocation error.
 
@ U_ZERO_ERROR
No error, no warning.
 
#define U_FAILURE(x)
Does the error code indicate a failure?
 
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.