ICU 71.1 71.1

numberformatter.h
Go to the documentation of this file.
1 // © 2017 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3
4 #ifndef __NUMBERFORMATTER_H__
5 #define __NUMBERFORMATTER_H__
6
7 #include "unicode/utypes.h"
8
9 #if U_SHOW_CPLUSPLUS_API
10
11 #if !UCONFIG_NO_FORMATTING
12
13 #include "unicode/appendable.h"
14 #include "unicode/bytestream.h"
15 #include "unicode/currunit.h"
16 #include "unicode/dcfmtsym.h"
17 #include "unicode/fieldpos.h"
18 #include "unicode/formattedvalue.h"
19 #include "unicode/fpositer.h"
20 #include "unicode/measunit.h"
21 #include "unicode/nounit.h"
22 #include "unicode/parseerr.h"
23 #include "unicode/plurrule.h"
24 #include "unicode/ucurr.h"
25 #include "unicode/unounclass.h"
26 #include "unicode/unum.h"
27 #include "unicode/unumberformatter.h"
28 #include "unicode/uobject.h"
29
85 U_NAMESPACE_BEGIN
86
87 // Forward declarations:
88 class IFixedDecimal;
89 class FieldPositionIteratorHandler;
90 class FormattedStringBuilder;
91
92 namespace numparse {
93 namespace impl {
94
95 // Forward declarations:
96 class NumberParserImpl;
97 class MultiplierParseHandler;
98
99 }
100 }
101
102 namespace units {
103
104 // Forward declarations:
105 class UnitsRouter;
106
107 } // namespace units
108
109 namespace number { // icu::number
110
111 // Forward declarations:
112 class UnlocalizedNumberFormatter;
113 class LocalizedNumberFormatter;
114 class FormattedNumber;
115 class Notation;
116 class ScientificNotation;
117 class Precision;
118 class FractionPrecision;
119 class CurrencyPrecision;
120 class IncrementPrecision;
121 class IntegerWidth;
122
123 namespace impl {
124
125 // can't be #ifndef U_HIDE_INTERNAL_API; referenced throughout this file in public classes
131 typedef int16_t digits_t;
132
133 // can't be #ifndef U_HIDE_INTERNAL_API; needed for struct initialization
140 static constexpr int32_t kInternalDefaultThreshold = 3;
141
142 // Forward declarations:
143 class Padder;
144 struct MacroProps;
145 struct MicroProps;
146 class DecimalQuantity;
147 class UFormattedNumberData;
148 class NumberFormatterImpl;
149 struct ParsedPatternInfo;
150 class ScientificModifier;
151 class MultiplierProducer;
152 class RoundingImpl;
153 class ScientificHandler;
154 class Modifier;
155 class AffixPatternProvider;
156 class NumberPropertyMapper;
157 struct DecimalFormatProperties;
158 class MultiplierFormatHandler;
159 class CurrencySymbols;
160 class GeneratorHelpers;
161 class DecNum;
162 class NumberRangeFormatterImpl;
163 struct RangeMacroProps;
164 struct UFormattedNumberImpl;
165 class MutablePatternModifier;
166 class ImmutablePatternModifier;
167 struct DecimalFormatWarehouse;
168
175 void touchRangeLocales(impl::RangeMacroProps& macros);
176
177 } // namespace impl
178
184 typedef Notation CompactNotation;
185
191 typedef Notation SimpleNotation;
192
198 class U_I18N_API Notation : public UMemory {
199 public:
224 static ScientificNotation scientific();
225
248 static ScientificNotation engineering();
249
291 static CompactNotation compactShort();
292
315 static CompactNotation compactLong();
316
341 static SimpleNotation simple();
342
343 private:
344 enum NotationType {
345 NTN_SCIENTIFIC, NTN_COMPACT, NTN_SIMPLE, NTN_ERROR
346 } fType;
347
348 union NotationUnion {
349 // For NTN_SCIENTIFIC
351 struct ScientificSettings {
353 int8_t fEngineeringInterval;
355 bool fRequireMinInt;
357 impl::digits_t fMinExponentDigits;
359 UNumberSignDisplay fExponentSignDisplay;
360 } scientific;
361
362 // For NTN_COMPACT
363 UNumberCompactStyle compactStyle;
364
365 // For NTN_ERROR
366 UErrorCode errorCode;
367 } fUnion;
368
369 typedef NotationUnion::ScientificSettings ScientificSettings;
370
371 Notation(const NotationType &type, const NotationUnion &union_) : fType(type), fUnion(union_) {}
372
373 Notation(UErrorCode errorCode) : fType(NTN_ERROR) {
374 fUnion.errorCode = errorCode;
375 }
376
377 Notation() : fType(NTN_SIMPLE), fUnion() {}
378
379 UBool copyErrorTo(UErrorCode &status) const {
380 if (fType == NTN_ERROR) {
381 status = fUnion.errorCode;
382 return true;
383 }
384 return false;
385 }
386
387 // To allow MacroProps to initialize empty instances:
388 friend struct impl::MacroProps;
389 friend class ScientificNotation;
390
391 // To allow implementation to access internal types:
392 friend class impl::NumberFormatterImpl;
393 friend class impl::ScientificModifier;
394 friend class impl::ScientificHandler;
395
396 // To allow access to the skeleton generation code:
397 friend class impl::GeneratorHelpers;
398 };
399
408 class U_I18N_API ScientificNotation : public Notation {
409 public:
423 ScientificNotation withMinExponentDigits(int32_t minExponentDigits) const;
424
438 ScientificNotation withExponentSignDisplay(UNumberSignDisplay exponentSignDisplay) const;
439
440 private:
441 // Inherit constructor
442 using Notation::Notation;
443
444 // Raw constructor for NumberPropertyMapper
445 ScientificNotation(int8_t fEngineeringInterval, bool fRequireMinInt, impl::digits_t fMinExponentDigits,
446 UNumberSignDisplay fExponentSignDisplay);
447
448 friend class Notation;
449
450 // So that NumberPropertyMapper can create instances
451 friend class impl::NumberPropertyMapper;
452 };
453
459 typedef Precision SignificantDigitsPrecision;
460
469 class U_I18N_API Precision : public UMemory {
470
471 public:
489 static Precision unlimited();
490
497 static FractionPrecision integer();
498
526 static FractionPrecision fixedFraction(int32_t minMaxFractionPlaces);
527
541 static FractionPrecision minFraction(int32_t minFractionPlaces);
542
553 static FractionPrecision maxFraction(int32_t maxFractionPlaces);
554
568 static FractionPrecision minMaxFraction(int32_t minFractionPlaces, int32_t maxFractionPlaces);
569
583 static SignificantDigitsPrecision fixedSignificantDigits(int32_t minMaxSignificantDigits);
584
597 static SignificantDigitsPrecision minSignificantDigits(int32_t minSignificantDigits);
598
607 static SignificantDigitsPrecision maxSignificantDigits(int32_t maxSignificantDigits);
608
620 static SignificantDigitsPrecision minMaxSignificantDigits(int32_t minSignificantDigits,
621 int32_t maxSignificantDigits);
622
642 static IncrementPrecision increment(double roundingIncrement);
643
644 #ifndef U_HIDE_DRAFT_API
645
668 static IncrementPrecision incrementExact(uint64_t mantissa, int16_t magnitude);
669 #endif // U_HIDE_DRAFT_API
670
688 static CurrencyPrecision currency(UCurrencyUsage currencyUsage);
689
697 Precision trailingZeroDisplay(UNumberTrailingZeroDisplay trailingZeroDisplay) const;
698
699 private:
700 enum PrecisionType {
701 RND_BOGUS,
702 RND_NONE,
703 RND_FRACTION,
704 RND_SIGNIFICANT,
705 RND_FRACTION_SIGNIFICANT,
706
707 // Used for strange increments like 3.14.
708 RND_INCREMENT,
709
710 // Used for increments with 1 as the only digit. This is different than fraction
711 // rounding because it supports having additional trailing zeros. For example, this
712 // class is used to round with the increment 0.010.
713 RND_INCREMENT_ONE,
714
715 // Used for increments with 5 as the only digit (nickel rounding).
716 RND_INCREMENT_FIVE,
717
718 RND_CURRENCY,
719 RND_ERROR
720 } fType;
721
722 union PrecisionUnion {
724 struct FractionSignificantSettings {
725 // For RND_FRACTION, RND_SIGNIFICANT, and RND_FRACTION_SIGNIFICANT
727 impl::digits_t fMinFrac;
729 impl::digits_t fMaxFrac;
731 impl::digits_t fMinSig;
733 impl::digits_t fMaxSig;
735 UNumberRoundingPriority fPriority;
740 bool fRetain;
741 } fracSig;
743 struct IncrementSettings {
744 // For RND_INCREMENT, RND_INCREMENT_ONE, and RND_INCREMENT_FIVE
745 // Note: This is a union, so we shouldn't own memory, since
746 // the default destructor would leak it.
748 uint64_t fIncrement;
750 impl::digits_t fIncrementMagnitude;
752 impl::digits_t fMinFrac;
753 } increment;
754 UCurrencyUsage currencyUsage; // For RND_CURRENCY
755 UErrorCode errorCode; // For RND_ERROR
756 } fUnion;
757
758 UNumberTrailingZeroDisplay fTrailingZeroDisplay = UNUM_TRAILING_ZERO_AUTO;
759
760 typedef PrecisionUnion::FractionSignificantSettings FractionSignificantSettings;
761 typedef PrecisionUnion::IncrementSettings IncrementSettings;
762
763 Precision(const PrecisionType& type, const PrecisionUnion& union_)
764 : fType(type), fUnion(union_) {}
765
766 Precision(UErrorCode errorCode) : fType(RND_ERROR) {
767 fUnion.errorCode = errorCode;
768 }
769
770 Precision() : fType(RND_BOGUS) {}
771
772 bool isBogus() const {
773 return fType == RND_BOGUS;
774 }
775
776 UBool copyErrorTo(UErrorCode &status) const {
777 if (fType == RND_ERROR) {
778 status = fUnion.errorCode;
779 return true;
780 }
781 return false;
782 }
783
784 // On the parent type so that this method can be called internally on Precision instances.
785 Precision withCurrency(const CurrencyUnit &currency, UErrorCode &status) const;
786
787 static FractionPrecision constructFraction(int32_t minFrac, int32_t maxFrac);
788
789 static Precision constructSignificant(int32_t minSig, int32_t maxSig);
790
791 static Precision constructFractionSignificant(
792 const FractionPrecision &base,
793 int32_t minSig,
794 int32_t maxSig,
795 UNumberRoundingPriority priority,
796 bool retain);
797
798 static IncrementPrecision constructIncrement(uint64_t increment, impl::digits_t magnitude);
799
800 static CurrencyPrecision constructCurrency(UCurrencyUsage usage);
801
802 // To allow MacroProps/MicroProps to initialize bogus instances:
803 friend struct impl::MacroProps;
804 friend struct impl::MicroProps;
805
806 // To allow NumberFormatterImpl to access isBogus() and other internal methods:
807 friend class impl::NumberFormatterImpl;
808
809 // To allow NumberPropertyMapper to create instances from DecimalFormatProperties:
810 friend class impl::NumberPropertyMapper;
811
812 // To allow access to the main implementation class:
813 friend class impl::RoundingImpl;
814
815 // To allow child classes to call private methods:
816 friend class FractionPrecision;
817 friend class CurrencyPrecision;
818 friend class IncrementPrecision;
819
820 // To allow access to the skeleton generation code:
821 friend class impl::GeneratorHelpers;
822
823 // To allow access to isBogus and the default (bogus) constructor:
824 friend class units::UnitsRouter;
825 };
826
836 class U_I18N_API FractionPrecision : public Precision {
837 public:
852 Precision withSignificantDigits(
853 int32_t minSignificantDigits,
854 int32_t maxSignificantDigits,
855 UNumberRoundingPriority priority) const;
856
874 Precision withMinDigits(int32_t minSignificantDigits) const;
875
893 Precision withMaxDigits(int32_t maxSignificantDigits) const;
894
895 private:
896 // Inherit constructor
897 using Precision::Precision;
898
899 // To allow parent class to call this class's constructor:
900 friend class Precision;
901 };
902
912 class U_I18N_API CurrencyPrecision : public Precision {
913 public:
931 Precision withCurrency(const CurrencyUnit &currency) const;
932
933 private:
934 // Inherit constructor
935 using Precision::Precision;
936
937 // To allow parent class to call this class's constructor:
938 friend class Precision;
939 };
940
950 class U_I18N_API IncrementPrecision : public Precision {
951 public:
967 Precision withMinFraction(int32_t minFrac) const;
968
969 private:
970 // Inherit constructor
971 using Precision::Precision;
972
973 // To allow parent class to call this class's constructor:
974 friend class Precision;
975 };
976
986 class U_I18N_API IntegerWidth : public UMemory {
987 public:
999 static IntegerWidth zeroFillTo(int32_t minInt);
1000
1012 IntegerWidth truncateAt(int32_t maxInt);
1013
1014 private:
1015 union {
1016 struct {
1017 impl::digits_t fMinInt;
1018 impl::digits_t fMaxInt;
1019 bool fFormatFailIfMoreThanMaxDigits;
1020 } minMaxInt;
1021 UErrorCode errorCode;
1022 } fUnion;
1023 bool fHasError = false;
1024
1025 IntegerWidth(impl::digits_t minInt, impl::digits_t maxInt, bool formatFailIfMoreThanMaxDigits);
1026
1027 IntegerWidth(UErrorCode errorCode) { // NOLINT
1028 fUnion.errorCode = errorCode;
1029 fHasError = true;
1030 }
1031
1032 IntegerWidth() { // NOLINT
1033 fUnion.minMaxInt.fMinInt = -1;
1034 }
1035
1037 static IntegerWidth standard() {
1038 return IntegerWidth::zeroFillTo(1);
1039 }
1040
1041 bool isBogus() const {
1042 return !fHasError && fUnion.minMaxInt.fMinInt == -1;
1043 }
1044
1045 UBool copyErrorTo(UErrorCode &status) const {
1046 if (fHasError) {
1047 status = fUnion.errorCode;
1048 return true;
1049 }
1050 return false;
1051 }
1052
1053 void apply(impl::DecimalQuantity &quantity, UErrorCode &status) const;
1054
1055 bool operator==(const IntegerWidth& other) const;
1056
1057 // To allow MacroProps/MicroProps to initialize empty instances:
1058 friend struct impl::MacroProps;
1059 friend struct impl::MicroProps;
1060
1061 // To allow NumberFormatterImpl to access isBogus():
1062 friend class impl::NumberFormatterImpl;
1063
1064 // To allow the use of this class when formatting:
1065 friend class impl::MutablePatternModifier;
1066 friend class impl::ImmutablePatternModifier;
1067
1068 // So that NumberPropertyMapper can create instances
1069 friend class impl::NumberPropertyMapper;
1070
1071 // To allow access to the skeleton generation code:
1072 friend class impl::GeneratorHelpers;
1073 };
1074
1083 class U_I18N_API Scale : public UMemory {
1084 public:
1091 static Scale none();
1092
1103 static Scale powerOfTen(int32_t power);
1104
1117 static Scale byDecimal(StringPiece multiplicand);
1118
1127 static Scale byDouble(double multiplicand);
1128
1135 static Scale byDoubleAndPowerOfTen(double multiplicand, int32_t power);
1136
1137 // We need a custom destructor for the DecNum, which means we need to declare
1138 // the copy/move constructor/assignment quartet.
1139
1141 Scale(const Scale& other);
1142
1144 Scale& operator=(const Scale& other);
1145
1147 Scale(Scale&& src) U_NOEXCEPT;
1148
1150 Scale& operator=(Scale&& src) U_NOEXCEPT;
1151
1153 ~Scale();
1154
1155 #ifndef U_HIDE_INTERNAL_API
1156
1157 Scale(int32_t magnitude, impl::DecNum* arbitraryToAdopt);
1158 #endif /* U_HIDE_INTERNAL_API */
1159
1160 private:
1161 int32_t fMagnitude;
1162 impl::DecNum* fArbitrary;
1163 UErrorCode fError;
1164
1165 Scale(UErrorCode error) : fMagnitude(0), fArbitrary(nullptr), fError(error) {}
1166
1167 Scale() : fMagnitude(0), fArbitrary(nullptr), fError(U_ZERO_ERROR) {}
1168
1169 bool isValid() const {
1170 return fMagnitude != 0 || fArbitrary != nullptr;
1171 }
1172
1173 UBool copyErrorTo(UErrorCode &status) const {
1174 if (U_FAILURE(fError)) {
1175 status = fError;
1176 return true;
1177 }
1178 return false;
1179 }
1180
1181 void applyTo(impl::DecimalQuantity& quantity) const;
1182
1183 void applyReciprocalTo(impl::DecimalQuantity& quantity) const;
1184
1185 // To allow MacroProps/MicroProps to initialize empty instances:
1186 friend struct impl::MacroProps;
1187 friend struct impl::MicroProps;
1188
1189 // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1190 friend class impl::NumberFormatterImpl;
1191
1192 // To allow the helper class MultiplierFormatHandler access to private fields:
1193 friend class impl::MultiplierFormatHandler;
1194
1195 // To allow access to the skeleton generation code:
1196 friend class impl::GeneratorHelpers;
1197
1198 // To allow access to parsing code:
1199 friend class ::icu::numparse::impl::NumberParserImpl;
1200 friend class ::icu::numparse::impl::MultiplierParseHandler;
1201 };
1202
1203 namespace impl {
1204
1205 // Do not enclose entire StringProp with #ifndef U_HIDE_INTERNAL_API, needed for a protected field.
1206 // And do not enclose its class boilerplate within #ifndef U_HIDE_INTERNAL_API.
1211 class U_I18N_API StringProp : public UMemory {
1212
1213 public:
1215 ~StringProp();
1216
1218 StringProp(const StringProp &other);
1219
1221 StringProp &operator=(const StringProp &other);
1222
1223 #ifndef U_HIDE_INTERNAL_API
1224
1226 StringProp(StringProp &&src) U_NOEXCEPT;
1227
1229 StringProp &operator=(StringProp &&src) U_NOEXCEPT;
1230
1232 int16_t length() const {
1233 return fLength;
1234 }
1235
1239 void set(StringPiece value);
1240
1242 bool isSet() const {
1243 return fLength > 0;
1244 }
1245
1246 #endif // U_HIDE_INTERNAL_API
1247
1248 private:
1249 char *fValue;
1250 int16_t fLength;
1251 UErrorCode fError;
1252
1253 StringProp() : fValue(nullptr), fLength(0), fError(U_ZERO_ERROR) {
1254 }
1255
1257 UBool copyErrorTo(UErrorCode &status) const {
1258 if (U_FAILURE(fError)) {
1259 status = fError;
1260 return true;
1261 }
1262 return false;
1263 }
1264
1265 // Allow NumberFormatterImpl to access fValue.
1266 friend class impl::NumberFormatterImpl;
1267
1268 // Allow skeleton generation code to access private members.
1269 friend class impl::GeneratorHelpers;
1270
1271 // Allow MacroProps/MicroProps to initialize empty instances and to call
1272 // copyErrorTo().
1273 friend struct impl::MacroProps;
1274 };
1275
1276 // Do not enclose entire SymbolsWrapper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1278 class U_I18N_API SymbolsWrapper : public UMemory {
1279 public:
1281 SymbolsWrapper() : fType(SYMPTR_NONE), fPtr{nullptr} {}
1282
1284 SymbolsWrapper(const SymbolsWrapper &other);
1285
1287 SymbolsWrapper &operator=(const SymbolsWrapper &other);
1288
1290 SymbolsWrapper(SymbolsWrapper&& src) U_NOEXCEPT;
1291
1293 SymbolsWrapper &operator=(SymbolsWrapper&& src) U_NOEXCEPT;
1294
1296 ~SymbolsWrapper();
1297
1298 #ifndef U_HIDE_INTERNAL_API
1299
1304 void setTo(const DecimalFormatSymbols &dfs);
1305
1310 void setTo(const NumberingSystem *ns);
1311
1316 bool isDecimalFormatSymbols() const;
1317
1322 bool isNumberingSystem() const;
1323
1328 const DecimalFormatSymbols *getDecimalFormatSymbols() const;
1329
1334 const NumberingSystem *getNumberingSystem() const;
1335
1336 #endif // U_HIDE_INTERNAL_API
1337
1339 UBool copyErrorTo(UErrorCode &status) const {
1340 if (fType == SYMPTR_DFS && fPtr.dfs == nullptr) {
1341 status = U_MEMORY_ALLOCATION_ERROR;
1342 return true;
1343 } else if (fType == SYMPTR_NS && fPtr.ns == nullptr) {
1344 status = U_MEMORY_ALLOCATION_ERROR;
1345 return true;
1346 }
1347 return false;
1348 }
1349
1350 private:
1351 enum SymbolsPointerType {
1352 SYMPTR_NONE, SYMPTR_DFS, SYMPTR_NS
1353 } fType;
1354
1355 union {
1356 const DecimalFormatSymbols *dfs;
1357 const NumberingSystem *ns;
1358 } fPtr;
1359
1360 void doCopyFrom(const SymbolsWrapper &other);
1361
1362 void doMoveFrom(SymbolsWrapper&& src);
1363
1364 void doCleanup();
1365 };
1366
1367 // Do not enclose entire Grouper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1369 class U_I18N_API Grouper : public UMemory {
1370 public:
1371 #ifndef U_HIDE_INTERNAL_API
1372
1373 static Grouper forStrategy(UNumberGroupingStrategy grouping);
1374
1379 static Grouper forProperties(const DecimalFormatProperties& properties);
1380
1381 // Future: static Grouper forProperties(DecimalFormatProperties& properties);
1382
1384 Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping, UNumberGroupingStrategy strategy)
1385 : fGrouping1(grouping1),
1386 fGrouping2(grouping2),
1387 fMinGrouping(minGrouping),
1388 fStrategy(strategy) {}
1389
1391 int16_t getPrimary() const;
1392
1394 int16_t getSecondary() const;
1395 #endif // U_HIDE_INTERNAL_API
1396
1397 private:
1406 int16_t fGrouping1;
1407 int16_t fGrouping2;
1408
1416 int16_t fMinGrouping;
1417
1422 UNumberGroupingStrategy fStrategy;
1423
1424 Grouper() : fGrouping1(-3) {}
1425
1426 bool isBogus() const {
1427 return fGrouping1 == -3;
1428 }
1429
1431 void setLocaleData(const impl::ParsedPatternInfo &patternInfo, const Locale& locale);
1432
1433 bool groupAtPosition(int32_t position, const impl::DecimalQuantity &value) const;
1434
1435 // To allow MacroProps/MicroProps to initialize empty instances:
1436 friend struct MacroProps;
1437 friend struct MicroProps;
1438
1439 // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1440 friend class NumberFormatterImpl;
1441
1442 // To allow NumberParserImpl to perform setLocaleData():
1443 friend class ::icu::numparse::impl::NumberParserImpl;
1444
1445 // To allow access to the skeleton generation code:
1446 friend class impl::GeneratorHelpers;
1447 };
1448
1449 // Do not enclose entire Padder with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1451 class U_I18N_API Padder : public UMemory {
1452 public:
1453 #ifndef U_HIDE_INTERNAL_API
1454
1455 static Padder none();
1456
1458 static Padder codePoints(UChar32 cp, int32_t targetWidth, UNumberFormatPadPosition position);
1459
1461 static Padder forProperties(const DecimalFormatProperties& properties);
1462 #endif // U_HIDE_INTERNAL_API
1463
1464 private:
1465 UChar32 fWidth; // -3 = error; -2 = bogus; -1 = no padding
1466 union {
1467 struct {
1468 int32_t fCp;
1469 UNumberFormatPadPosition fPosition;
1470 } padding;
1471 UErrorCode errorCode;
1472 } fUnion;
1473
1474 Padder(UChar32 cp, int32_t width, UNumberFormatPadPosition position);
1475
1476 Padder(int32_t width);
1477
1478 Padder(UErrorCode errorCode) : fWidth(-3) { // NOLINT
1479 fUnion.errorCode = errorCode;
1480 }
1481
1482 Padder() : fWidth(-2) {} // NOLINT
1483
1484 bool isBogus() const {
1485 return fWidth == -2;
1486 }
1487
1488 UBool copyErrorTo(UErrorCode &status) const {
1489 if (fWidth == -3) {
1490 status = fUnion.errorCode;
1491 return true;
1492 }
1493 return false;
1494 }
1495
1496 bool isValid() const {
1497 return fWidth > 0;
1498 }
1499
1500 int32_t padAndApply(const impl::Modifier &mod1, const impl::Modifier &mod2,
1501 FormattedStringBuilder &string, int32_t leftIndex, int32_t rightIndex,
1502 UErrorCode &status) const;
1503
1504 // To allow MacroProps/MicroProps to initialize empty instances:
1505 friend struct MacroProps;
1506 friend struct MicroProps;
1507
1508 // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1509 friend class impl::NumberFormatterImpl;
1510
1511 // To allow access to the skeleton generation code:
1512 friend class impl::GeneratorHelpers;
1513 };
1514
1515 // Do not enclose entire MacroProps with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1517 struct U_I18N_API MacroProps : public UMemory {
1519 Notation notation;
1520
1522 MeasureUnit unit; // = MeasureUnit(); (the base dimensionless unit)
1523
1525 MeasureUnit perUnit; // = MeasureUnit(); (the base dimensionless unit)
1526
1528 Precision precision; // = Precision(); (bogus)
1529
1531 UNumberFormatRoundingMode roundingMode = UNUM_ROUND_HALFEVEN;
1532
1534 Grouper grouper; // = Grouper(); (bogus)
1535
1537 Padder padder; // = Padder(); (bogus)
1538
1540 IntegerWidth integerWidth; // = IntegerWidth(); (bogus)
1541
1543 SymbolsWrapper symbols;
1544
1545 // UNUM_XYZ_COUNT denotes null (bogus) values.
1546
1548 UNumberUnitWidth unitWidth = UNUM_UNIT_WIDTH_COUNT;
1549
1551 UNumberSignDisplay sign = UNUM_SIGN_COUNT;
1552
1554 bool approximately = false;
1555
1557 UNumberDecimalSeparatorDisplay decimal = UNUM_DECIMAL_SEPARATOR_COUNT;
1558
1560 Scale scale; // = Scale(); (benign value)
1561
1563 StringProp usage; // = StringProp(); (no usage)
1564
1566 StringProp unitDisplayCase; // = StringProp(); (nominative)
1567
1569 const AffixPatternProvider* affixProvider = nullptr; // no ownership
1570
1572 const PluralRules* rules = nullptr; // no ownership
1573
1575 int32_t threshold = kInternalDefaultThreshold;
1576
1578 Locale locale;
1579
1580 // NOTE: Uses default copy and move constructors.
1581
1586 bool copyErrorTo(UErrorCode &status) const {
1587 return notation.copyErrorTo(status) || precision.copyErrorTo(status) ||
1588 padder.copyErrorTo(status) || integerWidth.copyErrorTo(status) ||
1589 symbols.copyErrorTo(status) || scale.copyErrorTo(status) || usage.copyErrorTo(status) ||
1590 unitDisplayCase.copyErrorTo(status);
1591 }
1592 };
1593
1594 } // namespace impl
1595
1596 #if (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN) && defined(_MSC_VER)
1597 // Ignore MSVC warning 4661. This is generated for NumberFormatterSettings<>::toSkeleton() as this method
1598 // is defined elsewhere (in number_skeletons.cpp). The compiler is warning that the explicit template instantiation
1599 // inside this single translation unit (CPP file) is incomplete, and thus it isn't sure if the template class is
1600 // fully defined. However, since each translation unit explicitly instantiates all the necessary template classes,
1601 // they will all be passed to the linker, and the linker will still find and export all the class members.
1602 #pragma warning(push)
1603 #pragma warning(disable: 4661)
1604 #endif
1605
1611 template<typename Derived>
1612 class U_I18N_API NumberFormatterSettings {
1613 public:
1642 Derived notation(const Notation &notation) const &;
1643
1653 Derived notation(const Notation &notation) &&;
1654
1703 Derived unit(const icu::MeasureUnit &unit) const &;
1704
1714 Derived unit(const icu::MeasureUnit &unit) &&;
1715
1729 Derived adoptUnit(icu::MeasureUnit *unit) const &;
1730
1740 Derived adoptUnit(icu::MeasureUnit *unit) &&;
1741
1764 Derived perUnit(const icu::MeasureUnit &perUnit) const &;
1765
1775 Derived perUnit(const icu::MeasureUnit &perUnit) &&;
1776
1790 Derived adoptPerUnit(icu::MeasureUnit *perUnit) const &;
1791
1801 Derived adoptPerUnit(icu::MeasureUnit *perUnit) &&;
1802
1833 Derived precision(const Precision& precision) const &;
1834
1844 Derived precision(const Precision& precision) &&;
1845
1864 Derived roundingMode(UNumberFormatRoundingMode roundingMode) const &;
1865
1874 Derived roundingMode(UNumberFormatRoundingMode roundingMode) &&;
1875
1903 Derived grouping(UNumberGroupingStrategy strategy) const &;
1904
1914 Derived grouping(UNumberGroupingStrategy strategy) &&;
1915
1940 Derived integerWidth(const IntegerWidth &style) const &;
1941
1951 Derived integerWidth(const IntegerWidth &style) &&;
1952
1993 Derived symbols(const DecimalFormatSymbols &symbols) const &;
1994
2004 Derived symbols(const DecimalFormatSymbols &symbols) &&;
2005
2039 Derived adoptSymbols(NumberingSystem *symbols) const &;
2040
2050 Derived adoptSymbols(NumberingSystem *symbols) &&;
2051
2077 Derived unitWidth(UNumberUnitWidth width) const &;
2078
2088 Derived unitWidth(UNumberUnitWidth width) &&;
2089
2115 Derived sign(UNumberSignDisplay style) const &;
2116
2126 Derived sign(UNumberSignDisplay style) &&;
2127
2153 Derived decimal(UNumberDecimalSeparatorDisplay style) const &;
2154
2164 Derived decimal(UNumberDecimalSeparatorDisplay style) &&;
2165
2190 Derived scale(const Scale &scale) const &;
2191
2201 Derived scale(const Scale &scale) &&;
2202
2245 Derived usage(StringPiece usage) const &;
2246
2254 Derived usage(StringPiece usage) &&;
2255
2256 #ifndef U_HIDE_DRAFT_API
2257 #ifndef U_HIDE_INTERNAL_API
2258
2264 Derived unitDisplayCase(StringPiece unitDisplayCase) const &;
2265
2271 Derived unitDisplayCase(StringPiece unitDisplayCase) &&;
2272 #endif // U_HIDE_INTERNAL_API
2273 #endif // U_HIDE_DRAFT_API
2274
2275 #ifndef U_HIDE_INTERNAL_API
2276
2282 Derived padding(const impl::Padder &padder) const &;
2283
2285 Derived padding(const impl::Padder &padder) &&;
2286
2293 Derived threshold(int32_t threshold) const &;
2294
2296 Derived threshold(int32_t threshold) &&;
2297
2303 Derived macros(const impl::MacroProps& macros) const &;
2304
2306 Derived macros(const impl::MacroProps& macros) &&;
2307
2309 Derived macros(impl::MacroProps&& macros) const &;
2310
2312 Derived macros(impl::MacroProps&& macros) &&;
2313
2314 #endif /* U_HIDE_INTERNAL_API */
2315
2333 UnicodeString toSkeleton(UErrorCode& status) const;
2334
2346 LocalPointer<Derived> clone() const &;
2347
2355 LocalPointer<Derived> clone() &&;
2356
2363 UBool copyErrorTo(UErrorCode &outErrorCode) const {
2364 if (U_FAILURE(outErrorCode)) {
2365 // Do not overwrite the older error code
2366 return true;
2367 }
2368 fMacros.copyErrorTo(outErrorCode);
2369 return U_FAILURE(outErrorCode);
2370 }
2371
2372 // NOTE: Uses default copy and move constructors.
2373
2374 private:
2375 impl::MacroProps fMacros;
2376
2377 // Don't construct me directly! Use (Un)LocalizedNumberFormatter.
2378 NumberFormatterSettings() = default;
2379
2380 friend class LocalizedNumberFormatter;
2381 friend class UnlocalizedNumberFormatter;
2382
2383 // Give NumberRangeFormatter access to the MacroProps
2384 friend void impl::touchRangeLocales(impl::RangeMacroProps& macros);
2385 friend class impl::NumberRangeFormatterImpl;
2386 };
2387
2396 class U_I18N_API UnlocalizedNumberFormatter
2397 : public NumberFormatterSettings<UnlocalizedNumberFormatter>, public UMemory {
2398
2399 public:
2409 LocalizedNumberFormatter locale(const icu::Locale &locale) const &;
2410
2420 LocalizedNumberFormatter locale(const icu::Locale &locale) &&;
2421
2427 UnlocalizedNumberFormatter() = default;
2428
2433 UnlocalizedNumberFormatter(const UnlocalizedNumberFormatter &other);
2434
2440 UnlocalizedNumberFormatter(UnlocalizedNumberFormatter&& src) U_NOEXCEPT;
2441
2446 UnlocalizedNumberFormatter& operator=(const UnlocalizedNumberFormatter& other);
2447
2453 UnlocalizedNumberFormatter& operator=(UnlocalizedNumberFormatter&& src) U_NOEXCEPT;
2454
2455 private:
2456 explicit UnlocalizedNumberFormatter(const NumberFormatterSettings<UnlocalizedNumberFormatter>& other);
2457
2458 explicit UnlocalizedNumberFormatter(
2459 NumberFormatterSettings<UnlocalizedNumberFormatter>&& src) U_NOEXCEPT;
2460
2461 // To give the fluent setters access to this class's constructor:
2462 friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
2463
2464 // To give NumberFormatter::with() access to this class's constructor:
2465 friend class NumberFormatter;
2466 };
2467
2476 class U_I18N_API LocalizedNumberFormatter
2477 : public NumberFormatterSettings<LocalizedNumberFormatter>, public UMemory {
2478 public:
2490 FormattedNumber formatInt(int64_t value, UErrorCode &status) const;
2491
2503 FormattedNumber formatDouble(double value, UErrorCode &status) const;
2504
2519 FormattedNumber formatDecimal(StringPiece value, UErrorCode& status) const;
2520
2521 #ifndef U_HIDE_INTERNAL_API
2522
2523
2527 const DecimalFormatSymbols* getDecimalFormatSymbols() const;
2528
2532 FormattedNumber formatDecimalQuantity(const impl::DecimalQuantity& dq, UErrorCode& status) const;
2533
2537 void getAffixImpl(bool isPrefix, bool isNegative, UnicodeString& result, UErrorCode& status) const;
2538
2543 const impl::NumberFormatterImpl* getCompiled() const;
2544
2549 int32_t getCallCount() const;
2550
2551 #endif /* U_HIDE_INTERNAL_API */
2552
2566 Format* toFormat(UErrorCode& status) const;
2567
2573 LocalizedNumberFormatter() = default;
2574
2579 LocalizedNumberFormatter(const LocalizedNumberFormatter &other);
2580
2586 LocalizedNumberFormatter(LocalizedNumberFormatter&& src) U_NOEXCEPT;
2587
2592 LocalizedNumberFormatter& operator=(const LocalizedNumberFormatter& other);
2593
2599 LocalizedNumberFormatter& operator=(LocalizedNumberFormatter&& src) U_NOEXCEPT;
2600
2601 #ifndef U_HIDE_INTERNAL_API
2602
2615 void formatImpl(impl::UFormattedNumberData *results, UErrorCode &status) const;
2616
2617 #endif /* U_HIDE_INTERNAL_API */
2618
2623 ~LocalizedNumberFormatter();
2624
2625 private:
2626 // Note: fCompiled can't be a LocalPointer because impl::NumberFormatterImpl is defined in an internal
2627 // header, and LocalPointer needs the full class definition in order to delete the instance.
2628 const impl::NumberFormatterImpl* fCompiled {nullptr};
2629 char fUnsafeCallCount[8] {}; // internally cast to u_atomic_int32_t
2630
2631 // Owned pointer to a DecimalFormatWarehouse, used when copying a LocalizedNumberFormatter
2632 // from a DecimalFormat.
2633 const impl::DecimalFormatWarehouse* fWarehouse {nullptr};
2634
2635 explicit LocalizedNumberFormatter(const NumberFormatterSettings<LocalizedNumberFormatter>& other);
2636
2637 explicit LocalizedNumberFormatter(NumberFormatterSettings<LocalizedNumberFormatter>&& src) U_NOEXCEPT;
2638
2639 LocalizedNumberFormatter(const impl::MacroProps &macros, const Locale &locale);
2640
2641 LocalizedNumberFormatter(impl::MacroProps &&macros, const Locale &locale);
2642
2643 void resetCompiled();
2644
2645 void lnfMoveHelper(LocalizedNumberFormatter&& src);
2646
2647 void lnfCopyHelper(const LocalizedNumberFormatter& src, UErrorCode& status);
2648
2652 bool computeCompiled(UErrorCode& status) const;
2653
2654 // To give the fluent setters access to this class's constructor:
2655 friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
2656 friend class NumberFormatterSettings<LocalizedNumberFormatter>;
2657
2658 // To give UnlocalizedNumberFormatter::locale() access to this class's constructor:
2659 friend class UnlocalizedNumberFormatter;
2660 };
2661
2662 #if (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN) && defined(_MSC_VER)
2663 // Warning 4661.
2664 #pragma warning(pop)
2665 #endif
2666
2675 class U_I18N_API FormattedNumber : public UMemory, public FormattedValue {
2676 public:
2677
2682 FormattedNumber()
2683 : fData(nullptr), fErrorCode(U_INVALID_STATE_ERROR) {}
2684
2689 FormattedNumber(FormattedNumber&& src) U_NOEXCEPT;
2690
2695 virtual ~FormattedNumber() U_OVERRIDE;
2696
2698 FormattedNumber(const FormattedNumber&) = delete;
2699
2701 FormattedNumber& operator=(const FormattedNumber&) = delete;
2702
2707 FormattedNumber& operator=(FormattedNumber&& src) U_NOEXCEPT;
2708
2709 // Copybrief: this method is older than the parent method
2717 UnicodeString toString(UErrorCode& status) const U_OVERRIDE;
2718
2719 // Copydoc: this method is new in ICU 64
2721 UnicodeString toTempString(UErrorCode& status) const U_OVERRIDE;
2722
2723 // Copybrief: this method is older than the parent method
2731 Appendable &appendTo(Appendable& appendable, UErrorCode& status) const U_OVERRIDE;
2732
2733 // Copydoc: this method is new in ICU 64
2735 UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE;
2736
2755 template<typename StringClass>
2756 inline StringClass toDecimalNumber(UErrorCode& status) const;
2757
2769 MeasureUnit getOutputUnit(UErrorCode& status) const;
2770
2771 #ifndef U_HIDE_DRAFT_API
2772
2780 NounClass getNounClass(UErrorCode &status) const;
2781
2782 #endif // U_HIDE_DRAFT_API
2783
2784 #ifndef U_HIDE_INTERNAL_API
2785
2790 void getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const;
2791
2796 void getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih, UErrorCode& status) const;
2797
2798 #endif /* U_HIDE_INTERNAL_API */
2799
2800 #ifndef U_HIDE_DEPRECATED_API
2801
2808 const char *getGender(UErrorCode &status) const;
2809
2810 #endif /* U_HIDE_DEPRECATED_API */
2811
2812 private:
2813 // Can't use LocalPointer because UFormattedNumberData is forward-declared
2814 const impl::UFormattedNumberData *fData;
2815
2816 // Error code for the terminal methods
2817 UErrorCode fErrorCode;
2818
2823 explicit FormattedNumber(impl::UFormattedNumberData *results)
2824 : fData(results), fErrorCode(U_ZERO_ERROR) {}
2825
2826 explicit FormattedNumber(UErrorCode errorCode)
2827 : fData(nullptr), fErrorCode(errorCode) {}
2828
2829 void toDecimalNumber(ByteSink& sink, UErrorCode& status) const;
2830
2831 // To give LocalizedNumberFormatter format methods access to this class's constructor:
2832 friend class LocalizedNumberFormatter;
2833
2834 // To give C API access to internals
2835 friend struct impl::UFormattedNumberImpl;
2836 };
2837
2838 template<typename StringClass>
2839 StringClass FormattedNumber::toDecimalNumber(UErrorCode& status) const {
2840 StringClass result;
2841 StringByteSink<StringClass> sink(&result);
2842 toDecimalNumber(sink, status);
2843 return result;
2844 }
2845
2851 class U_I18N_API NumberFormatter final {
2852 public:
2860 static UnlocalizedNumberFormatter with();
2861
2871 static LocalizedNumberFormatter withLocale(const Locale &locale);
2872
2890 static UnlocalizedNumberFormatter forSkeleton(const UnicodeString& skeleton, UErrorCode& status);
2891
2912 static UnlocalizedNumberFormatter forSkeleton(const UnicodeString& skeleton,
2913 UParseError& perror, UErrorCode& status);
2914
2918 NumberFormatter() = delete;
2919 };
2920
2921 } // namespace number
2922 U_NAMESPACE_END
2923
2924 #endif /* #if !UCONFIG_NO_FORMATTING */
2925
2926 #endif /* U_SHOW_CPLUSPLUS_API */
2927
2928 #endif // __NUMBERFORMATTER_H__
icu::number::Scale
A class that defines a quantity by which a number should be multiplied when formatting.
Definition: numberformatter.h:1083
icu::DecimalFormatSymbols
This class represents the set of symbols needed by DecimalFormat to format numbers.
Definition: dcfmtsym.h:86
UNUM_DECIMAL_SEPARATOR_COUNT
@ UNUM_DECIMAL_SEPARATOR_COUNT
One more than the highest UNumberDecimalSeparatorDisplay value.
Definition: unumberformatter.h:494
icu::number::Notation::NotationUnion::ScientificSettings::fEngineeringInterval
int8_t fEngineeringInterval
Definition: numberformatter.h:353
icu::MeasureUnit
A unit such as length, mass, volume, currency, etc.
Definition: measunit.h:368
icu::number::Precision::PrecisionUnion::FractionSignificantSettings::fMaxSig
impl::digits_t fMaxSig
Definition: numberformatter.h:733
fpositer.h
C++ API: FieldPosition Iterator.
parseerr.h
C API: Parse Error Information.
icu::number::impl::MacroProps::perUnit
MeasureUnit perUnit
Definition: numberformatter.h:1525
icu::number::Precision::PrecisionUnion::FractionSignificantSettings::fPriority
UNumberRoundingPriority fPriority
Definition: numberformatter.h:735
unumberformatter.h
C-compatible API for localized number formatting; not recommended for C++.
icu::number::Precision::PrecisionUnion::IncrementSettings::fIncrement
uint64_t fIncrement
Definition: numberformatter.h:748
icu::number::impl::StringProp::length
int16_t length() const
Definition: numberformatter.h:1232
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::number::impl::touchRangeLocales
void touchRangeLocales(impl::RangeMacroProps &macros)
Used for NumberRangeFormatter and implemented in numrange_fluent.cpp.
icu::CurrencyUnit
A unit of currency, such as USD (U.S.
Definition: currunit.h:39
icu::number::IntegerWidth
A class that defines the strategy for padding and truncating integers before the decimal separator.
Definition: numberformatter.h:986
icu::number::impl::MacroProps::scale
Scale scale
Definition: numberformatter.h:1560
U_I18N_API
#define U_I18N_API
Definition: utypes.h:301
UNUM_UNIT_WIDTH_COUNT
@ UNUM_UNIT_WIDTH_COUNT
One more than the highest UNumberUnitWidth value.
Definition: unumberformatter.h:243
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
UNumberSignDisplay
UNumberSignDisplay
An enum declaring how to denote positive and negative numbers.
Definition: unumberformatter.h:366
U_NOEXCEPT
#define U_NOEXCEPT
Definition: platform.h:529
icu::number::impl::MacroProps::usage
StringProp usage
Definition: numberformatter.h:1563
icu::FormattedValue
An abstract formatted value: a string with associated field attributes.
Definition: formattedvalue.h:241
icu::number::IncrementPrecision
A class that defines a rounding precision parameterized by a rounding increment to be used when forma...
Definition: numberformatter.h:950
UNUM_SIGN_COUNT
@ UNUM_SIGN_COUNT
One more than the highest UNumberSignDisplay value.
Definition: unumberformatter.h:457
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
U_OVERRIDE
#define U_OVERRIDE
Definition: umachine.h:130
icu::PluralRules
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:206
icu::number::Notation::NotationUnion::ScientificSettings
Definition: numberformatter.h:351
UCurrencyUsage
UCurrencyUsage
Currency Usage used for Decimal Format.
Definition: ucurr.h:41
icu::LocalPointer
"Smart pointer" class, deletes objects via the standard C++ delete operator.
Definition: localpointer.h:191
icu::number::NumberFormatterSettings::copyErrorTo
UBool copyErrorTo(UErrorCode &outErrorCode) const
Sets the UErrorCode if an error occurred in the fluent chain.
Definition: numberformatter.h:2363
U_MEMORY_ALLOCATION_ERROR
@ U_MEMORY_ALLOCATION_ERROR
Memory allocation error.
Definition: utypes.h:457
icu::number::impl::RangeMacroProps
Definition: numberrangeformatter.h:93
UParseError
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
icu::Format
Base class for all formats.
Definition: format.h:98
fieldpos.h
C++ API: FieldPosition identifies the fields in a formatted output.
unum.h
C API: Compatibility APIs for number formatting.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
icu::number::impl::MacroProps::grouper
Grouper grouper
Definition: numberformatter.h:1534
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:467
icu::number::Notation::NotationUnion::ScientificSettings::fMinExponentDigits
impl::digits_t fMinExponentDigits
Definition: numberformatter.h:357
icu::number::impl::MacroProps::unitDisplayCase
StringProp unitDisplayCase
Definition: numberformatter.h:1566
U_FAILURE
#define U_FAILURE(x)
Does the error code indicate a failure?
Definition: utypes.h:717
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
icu::number::impl::MacroProps::precision
Precision precision
Definition: numberformatter.h:1528
UNumberRoundingPriority
UNumberRoundingPriority
An enum declaring how to resolve conflicts between maximum fraction digits and maximum significant di...
Definition: unumberformatter.h:119
icu::number::FormattedNumber
The result of a number formatting operation.
Definition: numberformatter.h:2675
icu::number::Notation::NotationUnion::ScientificSettings::fExponentSignDisplay
UNumberSignDisplay fExponentSignDisplay
Definition: numberformatter.h:359
icu::number::UnlocalizedNumberFormatter
A NumberFormatter that does not yet have a locale.
Definition: numberformatter.h:2396
icu::number::impl::Grouper
Definition: numberformatter.h:1369
icu::number::NumberFormatterSettings
An abstract base class for specifying settings related to number formatting.
Definition: numberformatter.h:1612
icu::number::impl::MacroProps::integerWidth
IntegerWidth integerWidth
Definition: numberformatter.h:1540
icu::number::Precision
A class that defines the rounding precision to be used when formatting numbers in NumberFormatter.
Definition: numberformatter.h:469
icu::number::impl::MacroProps::padder
Padder padder
Definition: numberformatter.h:1537
icu::UMemory
UMemory is the common ICU base class.
Definition: uobject.h:115
icu::number::impl::MacroProps::locale
Locale locale
Definition: numberformatter.h:1578
icu::number::impl::MacroProps::notation
Notation notation
Definition: numberformatter.h:1519
dcfmtsym.h
C++ API: Symbols for formatting numbers.
icu::number::Precision::PrecisionUnion::FractionSignificantSettings::fMaxFrac
impl::digits_t fMaxFrac
Definition: numberformatter.h:729
icu::number::Precision::PrecisionUnion::IncrementSettings::fMinFrac
impl::digits_t fMinFrac
Definition: numberformatter.h:752
icu::number::impl::MacroProps::symbols
SymbolsWrapper symbols
Definition: numberformatter.h:1543
U_ZERO_ERROR
@ U_ZERO_ERROR
No error, no warning.
Definition: utypes.h:449
appendable.h
C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (char16_ts).
UNumberUnitWidth
UNumberUnitWidth
An enum declaring how to render units, including currencies.
Definition: unumberformatter.h:153
UNumberDecimalSeparatorDisplay
UNumberDecimalSeparatorDisplay
An enum declaring how to render the decimal separator.
Definition: unumberformatter.h:471
icu::number::impl::StringProp
Manages NumberFormatterSettings::usage()'s char* instance on the heap.
Definition: numberformatter.h:1211
UNumberTrailingZeroDisplay
UNumberTrailingZeroDisplay
An enum declaring how to render trailing zeros.
Definition: unumberformatter.h:505
formattedvalue.h
C++ API: Abstract operations for localized strings.
icu::number::FractionPrecision
A class that defines a rounding precision based on a number of fraction places and optionally signifi...
Definition: numberformatter.h:836
ucurr.h
C API: Encapsulates information about a currency.
icu::number::CurrencyPrecision
A class that defines a rounding precision parameterized by a currency to be used when formatting numb...
Definition: numberformatter.h:912
UNUM_ROUND_HALFEVEN
@ UNUM_ROUND_HALFEVEN
Half-even rounding.
Definition: unum.h:291
icu::Appendable
Base class for objects to which Unicode characters and strings can be appended.
Definition: appendable.h:54
icu::number::Notation::NotationUnion::ScientificSettings::fRequireMinInt
bool fRequireMinInt
Definition: numberformatter.h:355
icu::number::Precision::PrecisionUnion::FractionSignificantSettings::fMinSig
impl::digits_t fMinSig
Definition: numberformatter.h:731
icu::number::impl::Grouper::Grouper
Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping, UNumberGroupingStrategy strategy)
Definition: numberformatter.h:1384
icu::NumberingSystem
Defines numbering systems.
Definition: numsys.h:60
icu::number::impl::SymbolsWrapper::copyErrorTo
UBool copyErrorTo(UErrorCode &status) const
Definition: numberformatter.h:1339
icu::number::Notation
A class that defines the notation style to be used when formatting numbers in NumberFormatter.
Definition: numberformatter.h:198
icu::number::impl::digits_t
int16_t digits_t
Datatype for minimum/maximum fraction digits.
Definition: numberformatter.h:131
icu::number::ScientificNotation
A class that defines the scientific notation style to be used when formatting numbers in NumberFormat...
Definition: numberformatter.h:408
UNumberFormatRoundingMode
UNumberFormatRoundingMode
The possible number format rounding modes.
Definition: unum.h:282
icu::NounClass
NounClass
Represents all the grammatical noun classes that are supported by CLDR.
Definition: unounclass.h:24
icu::StringByteSink
Implementation of ByteSink that writes to a "string".
Definition: bytestream.h:267
icu::number::Precision::PrecisionUnion::FractionSignificantSettings
Definition: numberformatter.h:724
UNUM_TRAILING_ZERO_AUTO
@ UNUM_TRAILING_ZERO_AUTO
Display trailing zeros according to the settings for minimum fraction and significant digits.
Definition: unumberformatter.h:511
icu::number::impl::StringProp::isSet
bool isSet() const
Definition: numberformatter.h:1242
icu::number::impl::Padder
Definition: numberformatter.h:1451
icu::number::impl::SymbolsWrapper::SymbolsWrapper
SymbolsWrapper()
Definition: numberformatter.h:1281
icu::number::Precision::PrecisionUnion::FractionSignificantSettings::fMinFrac
impl::digits_t fMinFrac
Definition: numberformatter.h:727
uobject.h
C++ API: Common ICU base class UObject.
nounit.h
C++ API: units for percent and permille.
plurrule.h
C++ API: PluralRules object.
icu::number::NumberFormatter
See the main description in numberformatter.h for documentation and examples.
Definition: numberformatter.h:2851
U_INVALID_STATE_ERROR
@ U_INVALID_STATE_ERROR
Requested operation can not be completed with ICU in its current state.
Definition: utypes.h:478
icu::number::Precision::PrecisionUnion::IncrementSettings::fIncrementMagnitude
impl::digits_t fIncrementMagnitude
Definition: numberformatter.h:750
icu::number::Precision::PrecisionUnion::IncrementSettings
Definition: numberformatter.h:743
UNumberGroupingStrategy
UNumberGroupingStrategy
An enum declaring the strategy for when and how to display grouping separators (i....
Definition: unumberformatter.h:272
icu::number::FormattedNumber::FormattedNumber
FormattedNumber()
Default constructor; makes an empty FormattedNumber.
Definition: numberformatter.h:2682
icu::number::impl::SymbolsWrapper
Definition: numberformatter.h:1278
measunit.h
C++ API: A unit for measuring a quantity.
UNumberFormatPadPosition
UNumberFormatPadPosition
The possible number format pad positions.
Definition: unum.h:326
icu::StringPiece
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:60
bytestream.h
C++ API: Interface for writing bytes, and implementation classes.
currunit.h
C++ API: Currency Unit Information.
icu::number::Precision::PrecisionUnion::FractionSignificantSettings::fRetain
bool fRetain
Whether to retain trailing zeros based on the looser strategy.
Definition: numberformatter.h:740
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
icu::number::LocalizedNumberFormatter
A NumberFormatter that has a locale associated with it; this means .format() methods are available.
Definition: numberformatter.h:2476
icu::number::impl::MacroProps
Definition: numberformatter.h:1517
icu::number::impl::MacroProps::copyErrorTo
bool copyErrorTo(UErrorCode &status) const
Check all members for errors.
Definition: numberformatter.h:1586
icu::ConstrainedFieldPosition
Represents a span of a string containing a given field.
Definition: formattedvalue.h:41
UNumberCompactStyle
UNumberCompactStyle
Constants for specifying short or long format.
Definition: unum.h:337
icu::number::impl::MacroProps::unit
MeasureUnit unit
Definition: numberformatter.h:1522