6 #if !UCONFIG_NO_FORMATTING 7 #ifndef __NUMBERFORMATTER_H__ 8 #define __NUMBERFORMATTER_H__ 21 #ifndef U_HIDE_DRAFT_API 156 #ifndef U_HIDE_INTERNAL_API 164 #endif // U_HIDE_INTERNAL_API 344 #ifndef U_HIDE_INTERNAL_API 352 #endif // U_HIDE_INTERNAL_API 380 #ifndef U_HIDE_INTERNAL_API 388 #endif // U_HIDE_INTERNAL_API 394 class UnlocalizedNumberFormatter;
395 class LocalizedNumberFormatter;
396 class FormattedNumber;
398 class ScientificNotation;
400 class FractionRounder;
401 class CurrencyRounder;
402 class IncrementRounder;
407 #ifndef U_HIDE_INTERNAL_API 421 static constexpr int32_t DEFAULT_THRESHOLD = 3;
422 #endif // U_HIDE_INTERNAL_API 428 class DecimalQuantity;
429 struct NumberFormatterResults;
430 class NumberFormatterImpl;
431 struct ParsedPatternInfo;
432 class ScientificModifier;
433 class MultiplierProducer;
434 class MutablePatternModifier;
435 class LongNameHandler;
436 class ScientificHandler;
437 class CompactHandler;
439 class NumberStringBuilder;
545 static CompactNotation compactShort();
569 static CompactNotation compactLong();
595 static SimpleNotation simple();
599 NTN_SCIENTIFIC, NTN_COMPACT, NTN_SIMPLE, NTN_ERROR
602 union NotationUnion {
605 int8_t fEngineeringInterval;
620 Notation(
const NotationType &type,
const NotationUnion &union_) : fType(type), fUnion(union_) {}
623 fUnion.errorCode = errorCode;
626 Notation() : fType(NTN_SIMPLE), fUnion() {}
629 if (fType == NTN_ERROR) {
630 status = fUnion.errorCode;
641 friend class impl::NumberFormatterImpl;
642 friend class impl::ScientificModifier;
643 friend class impl::ScientificHandler;
688 using Notation::Notation;
802 static FractionRounder minMaxFraction(int32_t minFractionPlaces, int32_t maxFractionPlaces);
817 static DigitRounder fixedDigits(int32_t minMaxSignificantDigits);
831 static DigitRounder minDigits(int32_t minSignificantDigits);
841 static DigitRounder maxDigits(int32_t maxSignificantDigits);
854 static DigitRounder minMaxDigits(int32_t minSignificantDigits, int32_t maxSignificantDigits);
912 RND_FRACTION_SIGNIFICANT,
941 : fType(type), fUnion(union_), fRoundingMode(roundingMode) {}
944 fUnion.errorCode = errorCode;
947 Rounder() : fType(RND_BOGUS) {}
949 bool isBogus()
const {
950 return fType == RND_BOGUS;
954 if (fType == RND_ERROR) {
955 status = fUnion.errorCode;
967 void apply(impl::DecimalQuantity &value,
UErrorCode &status)
const;
970 void apply(impl::DecimalQuantity &value, int32_t minInt,
UErrorCode status);
987 chooseMultiplierAndApply(impl::DecimalQuantity &input,
const impl::MultiplierProducer &producer,
990 static FractionRounder constructFraction(int32_t minFrac, int32_t maxFrac);
992 static Rounder constructSignificant(int32_t minSig, int32_t maxSig);
995 constructFractionSignificant(
const FractionRounder &base, int32_t minSig, int32_t maxSig);
997 static IncrementRounder constructIncrement(
double increment, int32_t minFrac);
1001 static Rounder constructPassThrough();
1005 friend struct impl::MicroProps;
1008 friend class impl::NumberFormatterImpl;
1011 friend class impl::MutablePatternModifier;
1012 friend class impl::LongNameHandler;
1013 friend class impl::ScientificHandler;
1014 friend class impl::CompactHandler;
1049 Rounder withMinDigits(int32_t minSignificantDigits)
const;
1068 Rounder withMaxDigits(int32_t maxSignificantDigits)
const;
1072 using Rounder::Rounder;
1110 using Rounder::Rounder;
1142 Rounder withMinFraction(int32_t minFrac)
const;
1146 using Rounder::Rounder;
1199 bool fHasError =
false;
1204 fUnion.errorCode = errorCode;
1209 fUnion.minMaxInt.fMinInt = -1;
1212 bool isBogus()
const {
1213 return !fHasError && fUnion.minMaxInt.fMinInt == -1;
1218 status = fUnion.errorCode;
1224 void apply(impl::DecimalQuantity &quantity,
UErrorCode &status)
const;
1228 friend struct impl::MicroProps;
1231 friend class impl::NumberFormatterImpl;
1252 #ifndef U_HIDE_INTERNAL_API 1269 bool isDecimalFormatSymbols()
const;
1275 bool isNumberingSystem()
const;
1291 if (fType == SYMPTR_DFS && fPtr.dfs ==
nullptr) {
1294 }
else if (fType == SYMPTR_NS && fPtr.ns ==
nullptr) {
1300 #endif // U_HIDE_INTERNAL_API 1303 enum SymbolsPointerType {
1304 SYMPTR_NONE, SYMPTR_DFS, SYMPTR_NS
1321 #ifndef U_HIDE_INTERNAL_API 1328 Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping)
1329 : fGrouping1(grouping1), fGrouping2(grouping2), fMinGrouping(minGrouping) {}
1330 #endif // U_HIDE_INTERNAL_API 1351 int16_t fMinGrouping;
1353 Grouper() : fGrouping1(-3) {};
1355 bool isBogus()
const {
1356 return fGrouping1 == -3;
1360 void setLocaleData(
const impl::ParsedPatternInfo &patternInfo,
const Locale& locale);
1362 bool groupAtPosition(int32_t position,
const impl::DecimalQuantity &value)
const;
1366 friend struct MicroProps;
1369 friend class NumberFormatterImpl;
1376 #ifndef U_HIDE_INTERNAL_API 1382 #endif // U_HIDE_INTERNAL_API 1399 fUnion.errorCode = errorCode;
1404 bool isBogus()
const {
1405 return fWidth == -2;
1410 status = fUnion.errorCode;
1416 bool isValid()
const {
1420 int32_t padAndApply(
const impl::Modifier &mod1,
const impl::Modifier &mod2,
1421 impl::NumberStringBuilder &
string, int32_t leftIndex, int32_t rightIndex,
1426 friend struct MicroProps;
1429 friend class impl::NumberFormatterImpl;
1474 int32_t threshold = DEFAULT_THRESHOLD;
1482 return notation.copyErrorTo(status) || rounder.copyErrorTo(status) ||
1483 padder.copyErrorTo(status) || integerWidth.copyErrorTo(status) ||
1494 template<
typename Derived>
1525 Derived notation(
const Notation ¬ation)
const;
1659 Derived rounding(
const Rounder &rounder)
const;
1876 #ifndef U_HIDE_INTERNAL_API 1891 Derived threshold(int32_t threshold)
const;
1906 fMacros.copyErrorTo(outErrorCode);
2036 const impl::NumberFormatterImpl* fCompiled {
nullptr};
2037 char fUnsafeCallCount[8] {};
2063 friend class UnlocalizedNumberFormatter;
2138 const impl::NumberFormatterResults *fResults;
2147 : fResults(
nullptr), fErrorCode(errorCode) {};
2190 #endif // U_HIDE_DRAFT_API 2192 #endif // __NUMBERFORMATTER_H__
UNumberFormatRoundingMode
The possible number format rounding modes.
A class that defines a rounding strategy parameterized by a rounding increment to be used when format...
A unit such as length, mass, volume, currency, etc.
C++ API: Currency Unit Information.
bool copyErrorTo(UErrorCode &status) const
Check all members for errors.
A class that defines a rounding strategy based on a number of fraction places and optionally signific...
#define U_FAILURE(x)
Does the error code indicate a failure?
A class that defines the strategy for padding and truncating integers before the decimal separator...
C++ API: FieldPosition Iterator.
A class that defines the rounding strategy to be used when formatting numbers in NumberFormatter.
Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping)
Defines numbering systems.
C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (char16_ts).
C++ API: units for percent and permille.
C++ API: PluralRules object.
Defines rules for mapping non-negative numeric values onto a small set of keywords.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
C++ API: FieldPosition identifies the fields in a formatted output.
A class that defines the notation style to be used when formatting numbers in NumberFormatter.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
FieldPositionIterator returns the field ids and their start/limit positions generated by a call to Fo...
IntegerWidth integerWidth
C++ API: A unit for measuring a quantity.
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.
#define TRUE
The TRUE value of a UBool.
A unit of currency, such as USD (U.S.
UNumberFormatPadPosition
The possible number format pad positions.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
UNumberCompactStyle
Constants for specifying short or long format.
A class that defines a rounding strategy parameterized by a currency to be used when formatting numbe...
UBool copyErrorTo(UErrorCode &status) const
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
C++ API: Symbols for formatting numbers.
A class that defines the scientific notation style to be used when formatting numbers in NumberFormat...
Basic definitions for ICU, for both C and C++ APIs.
#define FALSE
The FALSE value of a UBool.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
A string-like object that points to a sized piece of memory.
UMemory is the common ICU base class.
int8_t UBool
The ICU boolean type.
Base class for objects to which Unicode characters and strings can be appended.
A Locale object represents a specific geographical, political, or cultural region.