ICU 67.1 67.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"
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/unum.h"
27#include "unicode/uobject.h"
28
84
85U_NAMESPACE_BEGIN
86
87// Forward declarations:
88class IFixedDecimal;
89class FieldPositionIteratorHandler;
90class FormattedStringBuilder;
91
92namespace numparse {
93namespace impl {
94
95// Forward declarations:
96class NumberParserImpl;
97class MultiplierParseHandler;
98
99}
100}
101
102namespace number { // icu::number
103
104// Forward declarations:
105class UnlocalizedNumberFormatter;
106class LocalizedNumberFormatter;
107class FormattedNumber;
108class Notation;
109class ScientificNotation;
110class Precision;
111class FractionPrecision;
112class CurrencyPrecision;
113class IncrementPrecision;
114class IntegerWidth;
115
116namespace impl {
117
118// can't be #ifndef U_HIDE_INTERNAL_API; referenced throughout this file in public classes
124typedef int16_t digits_t;
125
126// can't be #ifndef U_HIDE_INTERNAL_API; needed for struct initialization
133static constexpr int32_t kInternalDefaultThreshold = 3;
134
135// Forward declarations:
136class Padder;
137struct MacroProps;
138struct MicroProps;
139class DecimalQuantity;
140class UFormattedNumberData;
141class NumberFormatterImpl;
142struct ParsedPatternInfo;
143class ScientificModifier;
144class MultiplierProducer;
145class RoundingImpl;
146class ScientificHandler;
147class Modifier;
148class AffixPatternProvider;
149class NumberPropertyMapper;
150struct DecimalFormatProperties;
151class MultiplierFormatHandler;
152class CurrencySymbols;
153class GeneratorHelpers;
154class DecNum;
155class NumberRangeFormatterImpl;
156struct RangeMacroProps;
157struct UFormattedNumberImpl;
158class MutablePatternModifier;
159class ImmutablePatternModifier;
160
168
169} // namespace impl
170
177
184
190class U_I18N_API Notation : public UMemory {
191 public:
216 static ScientificNotation scientific();
217
240 static ScientificNotation engineering();
241
284
308
334
335 private:
336 enum NotationType {
337 NTN_SCIENTIFIC, NTN_COMPACT, NTN_SIMPLE, NTN_ERROR
338 } fType;
339
340 union NotationUnion {
341 // For NTN_SCIENTIFIC
353
354 // For NTN_COMPACT
355 UNumberCompactStyle compactStyle;
356
357 // For NTN_ERROR
358 UErrorCode errorCode;
359 } fUnion;
360
361 typedef NotationUnion::ScientificSettings ScientificSettings;
362
363 Notation(const NotationType &type, const NotationUnion &union_) : fType(type), fUnion(union_) {}
364
365 Notation(UErrorCode errorCode) : fType(NTN_ERROR) {
366 fUnion.errorCode = errorCode;
367 }
368
369 Notation() : fType(NTN_SIMPLE), fUnion() {}
370
371 UBool copyErrorTo(UErrorCode &status) const {
372 if (fType == NTN_ERROR) {
373 status = fUnion.errorCode;
374 return TRUE;
375 }
376 return FALSE;
377 }
378
379 // To allow MacroProps to initialize empty instances:
380 friend struct impl::MacroProps;
381 friend class ScientificNotation;
382
383 // To allow implementation to access internal types:
384 friend class impl::NumberFormatterImpl;
385 friend class impl::ScientificModifier;
386 friend class impl::ScientificHandler;
387
388 // To allow access to the skeleton generation code:
389 friend class impl::GeneratorHelpers;
390};
391
400class U_I18N_API ScientificNotation : public Notation {
401 public:
415 ScientificNotation withMinExponentDigits(int32_t minExponentDigits) const;
416
430 ScientificNotation withExponentSignDisplay(UNumberSignDisplay exponentSignDisplay) const;
431
432 private:
433 // Inherit constructor
434 using Notation::Notation;
435
436 // Raw constructor for NumberPropertyMapper
437 ScientificNotation(int8_t fEngineeringInterval, bool fRequireMinInt, impl::digits_t fMinExponentDigits,
438 UNumberSignDisplay fExponentSignDisplay);
439
440 friend class Notation;
441
442 // So that NumberPropertyMapper can create instances
443 friend class impl::NumberPropertyMapper;
444};
445
452
461class U_I18N_API Precision : public UMemory {
462
463 public:
481 static Precision unlimited();
482
489 static FractionPrecision integer();
490
518 static FractionPrecision fixedFraction(int32_t minMaxFractionPlaces);
519
533 static FractionPrecision minFraction(int32_t minFractionPlaces);
534
545 static FractionPrecision maxFraction(int32_t maxFractionPlaces);
546
560 static FractionPrecision minMaxFraction(int32_t minFractionPlaces, int32_t maxFractionPlaces);
561
576
590
600
613 int32_t maxSignificantDigits);
614
634 static IncrementPrecision increment(double roundingIncrement);
635
653 static CurrencyPrecision currency(UCurrencyUsage currencyUsage);
654
655 private:
656 enum PrecisionType {
657 RND_BOGUS,
658 RND_NONE,
659 RND_FRACTION,
660 RND_SIGNIFICANT,
661 RND_FRACTION_SIGNIFICANT,
662
663 // Used for strange increments like 3.14.
664 RND_INCREMENT,
665
666 // Used for increments with 1 as the only digit. This is different than fraction
667 // rounding because it supports having additional trailing zeros. For example, this
668 // class is used to round with the increment 0.010.
669 RND_INCREMENT_ONE,
670
671 // Used for increments with 5 as the only digit (nickel rounding).
672 RND_INCREMENT_FIVE,
673
674 RND_CURRENCY,
675 RND_ERROR
676 } fType;
677
678 union PrecisionUnion {
681 // For RND_FRACTION, RND_SIGNIFICANT, and RND_FRACTION_SIGNIFICANT
690 } fracSig;
691
693 // For RND_INCREMENT, RND_INCREMENT_ONE, and RND_INCREMENT_FIVE
700 } increment;
701 UCurrencyUsage currencyUsage; // For RND_CURRENCY
702 UErrorCode errorCode; // For RND_ERROR
703 } fUnion;
704
705 typedef PrecisionUnion::FractionSignificantSettings FractionSignificantSettings;
706 typedef PrecisionUnion::IncrementSettings IncrementSettings;
707
709 UNumberFormatRoundingMode fRoundingMode;
710
711 Precision(const PrecisionType& type, const PrecisionUnion& union_,
712 UNumberFormatRoundingMode roundingMode)
713 : fType(type), fUnion(union_), fRoundingMode(roundingMode) {}
714
715 Precision(UErrorCode errorCode) : fType(RND_ERROR) {
716 fUnion.errorCode = errorCode;
717 }
718
719 Precision() : fType(RND_BOGUS) {}
720
721 bool isBogus() const {
722 return fType == RND_BOGUS;
723 }
724
725 UBool copyErrorTo(UErrorCode &status) const {
726 if (fType == RND_ERROR) {
727 status = fUnion.errorCode;
728 return TRUE;
729 }
730 return FALSE;
731 }
732
733 // On the parent type so that this method can be called internally on Precision instances.
734 Precision withCurrency(const CurrencyUnit &currency, UErrorCode &status) const;
735
736 static FractionPrecision constructFraction(int32_t minFrac, int32_t maxFrac);
737
738 static Precision constructSignificant(int32_t minSig, int32_t maxSig);
739
740 static Precision
741 constructFractionSignificant(const FractionPrecision &base, int32_t minSig, int32_t maxSig);
742
743 static IncrementPrecision constructIncrement(double increment, int32_t minFrac);
744
745 static CurrencyPrecision constructCurrency(UCurrencyUsage usage);
746
747 static Precision constructPassThrough();
748
749 // To allow MacroProps/MicroProps to initialize bogus instances:
750 friend struct impl::MacroProps;
751 friend struct impl::MicroProps;
752
753 // To allow NumberFormatterImpl to access isBogus() and other internal methods:
754 friend class impl::NumberFormatterImpl;
755
756 // To allow NumberPropertyMapper to create instances from DecimalFormatProperties:
757 friend class impl::NumberPropertyMapper;
758
759 // To allow access to the main implementation class:
760 friend class impl::RoundingImpl;
761
762 // To allow child classes to call private methods:
763 friend class FractionPrecision;
764 friend class CurrencyPrecision;
765 friend class IncrementPrecision;
766
767 // To allow access to the skeleton generation code:
768 friend class impl::GeneratorHelpers;
769};
770
780class U_I18N_API FractionPrecision : public Precision {
781 public:
798 Precision withMinDigits(int32_t minSignificantDigits) const;
799
817 Precision withMaxDigits(int32_t maxSignificantDigits) const;
818
819 private:
820 // Inherit constructor
821 using Precision::Precision;
822
823 // To allow parent class to call this class's constructor:
824 friend class Precision;
825};
826
836class U_I18N_API CurrencyPrecision : public Precision {
837 public:
855 Precision withCurrency(const CurrencyUnit &currency) const;
856
857 private:
858 // Inherit constructor
859 using Precision::Precision;
860
861 // To allow parent class to call this class's constructor:
862 friend class Precision;
863};
864
874class U_I18N_API IncrementPrecision : public Precision {
875 public:
891 Precision withMinFraction(int32_t minFrac) const;
892
893 private:
894 // Inherit constructor
895 using Precision::Precision;
896
897 // To allow parent class to call this class's constructor:
898 friend class Precision;
899};
900
910class U_I18N_API IntegerWidth : public UMemory {
911 public:
923 static IntegerWidth zeroFillTo(int32_t minInt);
924
936 IntegerWidth truncateAt(int32_t maxInt);
937
938 private:
939 union {
940 struct {
941 impl::digits_t fMinInt;
942 impl::digits_t fMaxInt;
943 bool fFormatFailIfMoreThanMaxDigits;
944 } minMaxInt;
945 UErrorCode errorCode;
946 } fUnion;
947 bool fHasError = false;
948
949 IntegerWidth(impl::digits_t minInt, impl::digits_t maxInt, bool formatFailIfMoreThanMaxDigits);
950
951 IntegerWidth(UErrorCode errorCode) { // NOLINT
952 fUnion.errorCode = errorCode;
953 fHasError = true;
954 }
955
956 IntegerWidth() { // NOLINT
957 fUnion.minMaxInt.fMinInt = -1;
958 }
959
961 static IntegerWidth standard() {
962 return IntegerWidth::zeroFillTo(1);
963 }
964
965 bool isBogus() const {
966 return !fHasError && fUnion.minMaxInt.fMinInt == -1;
967 }
968
969 UBool copyErrorTo(UErrorCode &status) const {
970 if (fHasError) {
971 status = fUnion.errorCode;
972 return TRUE;
973 }
974 return FALSE;
975 }
976
977 void apply(impl::DecimalQuantity &quantity, UErrorCode &status) const;
978
979 bool operator==(const IntegerWidth& other) const;
980
981 // To allow MacroProps/MicroProps to initialize empty instances:
982 friend struct impl::MacroProps;
983 friend struct impl::MicroProps;
984
985 // To allow NumberFormatterImpl to access isBogus():
986 friend class impl::NumberFormatterImpl;
987
988 // To allow the use of this class when formatting:
989 friend class impl::MutablePatternModifier;
990 friend class impl::ImmutablePatternModifier;
991
992 // So that NumberPropertyMapper can create instances
993 friend class impl::NumberPropertyMapper;
994
995 // To allow access to the skeleton generation code:
996 friend class impl::GeneratorHelpers;
997};
998
1007class U_I18N_API Scale : public UMemory {
1008 public:
1015 static Scale none();
1016
1027 static Scale powerOfTen(int32_t power);
1028
1041 static Scale byDecimal(StringPiece multiplicand);
1042
1051 static Scale byDouble(double multiplicand);
1052
1059 static Scale byDoubleAndPowerOfTen(double multiplicand, int32_t power);
1060
1061 // We need a custom destructor for the DecNum, which means we need to declare
1062 // the copy/move constructor/assignment quartet.
1063
1065 Scale(const Scale& other);
1066
1068 Scale& operator=(const Scale& other);
1069
1072
1075
1078
1079#ifndef U_HIDE_INTERNAL_API
1081 Scale(int32_t magnitude, impl::DecNum* arbitraryToAdopt);
1082#endif /* U_HIDE_INTERNAL_API */
1083
1084 private:
1085 int32_t fMagnitude;
1086 impl::DecNum* fArbitrary;
1087 UErrorCode fError;
1088
1089 Scale(UErrorCode error) : fMagnitude(0), fArbitrary(nullptr), fError(error) {}
1090
1091 Scale() : fMagnitude(0), fArbitrary(nullptr), fError(U_ZERO_ERROR) {}
1092
1093 bool isValid() const {
1094 return fMagnitude != 0 || fArbitrary != nullptr;
1095 }
1096
1097 UBool copyErrorTo(UErrorCode &status) const {
1098 if (fError != U_ZERO_ERROR) {
1099 status = fError;
1100 return TRUE;
1101 }
1102 return FALSE;
1103 }
1104
1105 void applyTo(impl::DecimalQuantity& quantity) const;
1106
1107 void applyReciprocalTo(impl::DecimalQuantity& quantity) const;
1108
1109 // To allow MacroProps/MicroProps to initialize empty instances:
1110 friend struct impl::MacroProps;
1111 friend struct impl::MicroProps;
1112
1113 // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1114 friend class impl::NumberFormatterImpl;
1115
1116 // To allow the helper class MultiplierFormatHandler access to private fields:
1117 friend class impl::MultiplierFormatHandler;
1118
1119 // To allow access to the skeleton generation code:
1120 friend class impl::GeneratorHelpers;
1121
1122 // To allow access to parsing code:
1123 friend class ::icu::numparse::impl::NumberParserImpl;
1124 friend class ::icu::numparse::impl::MultiplierParseHandler;
1125};
1126
1127namespace impl {
1128
1129// Do not enclose entire SymbolsWrapper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1132 public:
1134 SymbolsWrapper() : fType(SYMPTR_NONE), fPtr{nullptr} {}
1135
1138
1141
1144
1147
1150
1151#ifndef U_HIDE_INTERNAL_API
1152
1157 void setTo(const DecimalFormatSymbols &dfs);
1158
1163 void setTo(const NumberingSystem *ns);
1164
1170
1175 bool isNumberingSystem() const;
1176
1182
1188
1189#endif // U_HIDE_INTERNAL_API
1190
1193 if (fType == SYMPTR_DFS && fPtr.dfs == nullptr) {
1195 return TRUE;
1196 } else if (fType == SYMPTR_NS && fPtr.ns == nullptr) {
1198 return TRUE;
1199 }
1200 return FALSE;
1201 }
1202
1203 private:
1204 enum SymbolsPointerType {
1205 SYMPTR_NONE, SYMPTR_DFS, SYMPTR_NS
1206 } fType;
1207
1208 union {
1209 const DecimalFormatSymbols *dfs;
1210 const NumberingSystem *ns;
1211 } fPtr;
1212
1213 void doCopyFrom(const SymbolsWrapper &other);
1214
1215 void doMoveFrom(SymbolsWrapper&& src);
1216
1217 void doCleanup();
1218};
1219
1220// Do not enclose entire Grouper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1223 public:
1224#ifndef U_HIDE_INTERNAL_API
1227
1232 static Grouper forProperties(const DecimalFormatProperties& properties);
1233
1234 // Future: static Grouper forProperties(DecimalFormatProperties& properties);
1235
1237 Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping, UNumberGroupingStrategy strategy)
1238 : fGrouping1(grouping1),
1239 fGrouping2(grouping2),
1240 fMinGrouping(minGrouping),
1241 fStrategy(strategy) {}
1242#endif // U_HIDE_INTERNAL_API
1243
1245 int16_t getPrimary() const;
1246
1248 int16_t getSecondary() const;
1249
1250 private:
1259 int16_t fGrouping1;
1260 int16_t fGrouping2;
1261
1269 int16_t fMinGrouping;
1270
1275 UNumberGroupingStrategy fStrategy;
1276
1277 Grouper() : fGrouping1(-3) {}
1278
1279 bool isBogus() const {
1280 return fGrouping1 == -3;
1281 }
1282
1284 void setLocaleData(const impl::ParsedPatternInfo &patternInfo, const Locale& locale);
1285
1286 bool groupAtPosition(int32_t position, const impl::DecimalQuantity &value) const;
1287
1288 // To allow MacroProps/MicroProps to initialize empty instances:
1289 friend struct MacroProps;
1290 friend struct MicroProps;
1291
1292 // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1293 friend class NumberFormatterImpl;
1294
1295 // To allow NumberParserImpl to perform setLocaleData():
1296 friend class ::icu::numparse::impl::NumberParserImpl;
1297
1298 // To allow access to the skeleton generation code:
1299 friend class impl::GeneratorHelpers;
1300};
1301
1302// Do not enclose entire Padder with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1304class U_I18N_API Padder : public UMemory {
1305 public:
1306#ifndef U_HIDE_INTERNAL_API
1308 static Padder none();
1309
1311 static Padder codePoints(UChar32 cp, int32_t targetWidth, UNumberFormatPadPosition position);
1312#endif // U_HIDE_INTERNAL_API
1313
1315 static Padder forProperties(const DecimalFormatProperties& properties);
1316
1317 private:
1318 UChar32 fWidth; // -3 = error; -2 = bogus; -1 = no padding
1319 union {
1320 struct {
1321 int32_t fCp;
1322 UNumberFormatPadPosition fPosition;
1323 } padding;
1324 UErrorCode errorCode;
1325 } fUnion;
1326
1327 Padder(UChar32 cp, int32_t width, UNumberFormatPadPosition position);
1328
1329 Padder(int32_t width);
1330
1331 Padder(UErrorCode errorCode) : fWidth(-3) { // NOLINT
1332 fUnion.errorCode = errorCode;
1333 }
1334
1335 Padder() : fWidth(-2) {} // NOLINT
1336
1337 bool isBogus() const {
1338 return fWidth == -2;
1339 }
1340
1341 UBool copyErrorTo(UErrorCode &status) const {
1342 if (fWidth == -3) {
1343 status = fUnion.errorCode;
1344 return TRUE;
1345 }
1346 return FALSE;
1347 }
1348
1349 bool isValid() const {
1350 return fWidth > 0;
1351 }
1352
1353 int32_t padAndApply(const impl::Modifier &mod1, const impl::Modifier &mod2,
1354 FormattedStringBuilder &string, int32_t leftIndex, int32_t rightIndex,
1355 UErrorCode &status) const;
1356
1357 // To allow MacroProps/MicroProps to initialize empty instances:
1358 friend struct MacroProps;
1359 friend struct MicroProps;
1360
1361 // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1362 friend class impl::NumberFormatterImpl;
1363
1364 // To allow access to the skeleton generation code:
1365 friend class impl::GeneratorHelpers;
1366};
1367
1368// Do not enclose entire MacroProps with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1373
1375 MeasureUnit unit; // = NoUnit::base();
1376
1378 MeasureUnit perUnit; // = NoUnit::base();
1379
1381 Precision precision; // = Precision(); (bogus)
1382
1385
1387 Grouper grouper; // = Grouper(); (bogus)
1388
1390 Padder padder; // = Padder(); (bogus)
1391
1393 IntegerWidth integerWidth; // = IntegerWidth(); (bogus)
1394
1397
1398 // UNUM_XYZ_COUNT denotes null (bogus) values.
1399
1402
1405
1408
1410 Scale scale; // = Scale(); (benign value)
1411
1413 const AffixPatternProvider* affixProvider = nullptr; // no ownership
1414
1416 const PluralRules* rules = nullptr; // no ownership
1417
1419 int32_t threshold = kInternalDefaultThreshold;
1420
1423
1424 // NOTE: Uses default copy and move constructors.
1425
1430 bool copyErrorTo(UErrorCode &status) const {
1431 return notation.copyErrorTo(status) || precision.copyErrorTo(status) ||
1432 padder.copyErrorTo(status) || integerWidth.copyErrorTo(status) ||
1433 symbols.copyErrorTo(status) || scale.copyErrorTo(status);
1434 }
1435};
1436
1437} // namespace impl
1438
1439#if (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN) && defined(_MSC_VER)
1440// Ignore MSVC warning 4661. This is generated for NumberFormatterSettings<>::toSkeleton() as this method
1441// is defined elsewhere (in number_skeletons.cpp). The compiler is warning that the explicit template instantiation
1442// inside this single translation unit (CPP file) is incomplete, and thus it isn't sure if the template class is
1443// fully defined. However, since each translation unit explicitly instantiates all the necessary template classes,
1444// they will all be passed to the linker, and the linker will still find and export all the class members.
1445#pragma warning(push)
1446#pragma warning(disable: 4661)
1447#endif
1448
1454template<typename Derived>
1455class U_I18N_API NumberFormatterSettings {
1456 public:
1485 Derived notation(const Notation &notation) const &;
1486
1496 Derived notation(const Notation &notation) &&;
1497
1541 Derived unit(const icu::MeasureUnit &unit) const &;
1542
1552 Derived unit(const icu::MeasureUnit &unit) &&;
1553
1568
1579
1602 Derived perUnit(const icu::MeasureUnit &perUnit) const &;
1603
1614
1629
1640
1671 Derived precision(const Precision& precision) const &;
1672
1682 Derived precision(const Precision& precision) &&;
1683
1703
1713
1741 Derived grouping(UNumberGroupingStrategy strategy) const &;
1742
1752 Derived grouping(UNumberGroupingStrategy strategy) &&;
1753
1778 Derived integerWidth(const IntegerWidth &style) const &;
1779
1789 Derived integerWidth(const IntegerWidth &style) &&;
1790
1831 Derived symbols(const DecimalFormatSymbols &symbols) const &;
1832
1843
1878
1889
1915 Derived unitWidth(UNumberUnitWidth width) const &;
1916
1926 Derived unitWidth(UNumberUnitWidth width) &&;
1927
1953 Derived sign(UNumberSignDisplay style) const &;
1954
1964 Derived sign(UNumberSignDisplay style) &&;
1965
1992
2003
2028 Derived scale(const Scale &scale) const &;
2029
2039 Derived scale(const Scale &scale) &&;
2040
2041#ifndef U_HIDE_INTERNAL_API
2042
2048 Derived padding(const impl::Padder &padder) const &;
2049
2051 Derived padding(const impl::Padder &padder) &&;
2052
2059 Derived threshold(int32_t threshold) const &;
2060
2062 Derived threshold(int32_t threshold) &&;
2063
2069 Derived macros(const impl::MacroProps& macros) const &;
2070
2072 Derived macros(const impl::MacroProps& macros) &&;
2073
2075 Derived macros(impl::MacroProps&& macros) const &;
2076
2079
2080#endif /* U_HIDE_INTERNAL_API */
2081
2097
2110
2118 LocalPointer<Derived> clone() &&;
2119
2126 UBool copyErrorTo(UErrorCode &outErrorCode) const {
2127 if (U_FAILURE(outErrorCode)) {
2128 // Do not overwrite the older error code
2129 return TRUE;
2130 }
2131 fMacros.copyErrorTo(outErrorCode);
2132 return U_FAILURE(outErrorCode);
2133 }
2134
2135 // NOTE: Uses default copy and move constructors.
2136
2137 private:
2138 impl::MacroProps fMacros;
2139
2140 // Don't construct me directly! Use (Un)LocalizedNumberFormatter.
2141 NumberFormatterSettings() = default;
2142
2143 friend class LocalizedNumberFormatter;
2144 friend class UnlocalizedNumberFormatter;
2145
2146 // Give NumberRangeFormatter access to the MacroProps
2148 friend class impl::NumberRangeFormatterImpl;
2149};
2150
2160 : public NumberFormatterSettings<UnlocalizedNumberFormatter>, public UMemory {
2161
2162 public:
2172 LocalizedNumberFormatter locale(const icu::Locale &locale) const &;
2173
2183 LocalizedNumberFormatter locale(const icu::Locale &locale) &&;
2184
2191
2197
2204
2210
2217
2218 private:
2219 explicit UnlocalizedNumberFormatter(const NumberFormatterSettings<UnlocalizedNumberFormatter>& other);
2220
2222 NumberFormatterSettings<UnlocalizedNumberFormatter>&& src) U_NOEXCEPT;
2223
2224 // To give the fluent setters access to this class's constructor:
2225 friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
2226
2227 // To give NumberFormatter::with() access to this class's constructor:
2228 friend class NumberFormatter;
2229};
2230
2240 : public NumberFormatterSettings<LocalizedNumberFormatter>, public UMemory {
2241 public:
2253 FormattedNumber formatInt(int64_t value, UErrorCode &status) const;
2254
2266 FormattedNumber formatDouble(double value, UErrorCode &status) const;
2267
2283
2284#ifndef U_HIDE_INTERNAL_API
2285
2289 FormattedNumber formatDecimalQuantity(const impl::DecimalQuantity& dq, UErrorCode& status) const;
2290
2294 void getAffixImpl(bool isPrefix, bool isNegative, UnicodeString& result, UErrorCode& status) const;
2295
2300 const impl::NumberFormatterImpl* getCompiled() const;
2301
2306 int32_t getCallCount() const;
2307
2308#endif /* U_HIDE_INTERNAL_API */
2309
2323 Format* toFormat(UErrorCode& status) const;
2324
2331
2337
2344
2350
2357
2358#ifndef U_HIDE_INTERNAL_API
2359
2372 void formatImpl(impl::UFormattedNumberData *results, UErrorCode &status) const;
2373
2374#endif /* U_HIDE_INTERNAL_API */
2375
2381
2382 private:
2383 // Note: fCompiled can't be a LocalPointer because impl::NumberFormatterImpl is defined in an internal
2384 // header, and LocalPointer needs the full class definition in order to delete the instance.
2385 const impl::NumberFormatterImpl* fCompiled {nullptr};
2386 char fUnsafeCallCount[8] {}; // internally cast to u_atomic_int32_t
2387
2388 explicit LocalizedNumberFormatter(const NumberFormatterSettings<LocalizedNumberFormatter>& other);
2389
2390 explicit LocalizedNumberFormatter(NumberFormatterSettings<LocalizedNumberFormatter>&& src) U_NOEXCEPT;
2391
2392 LocalizedNumberFormatter(const impl::MacroProps &macros, const Locale &locale);
2393
2394 LocalizedNumberFormatter(impl::MacroProps &&macros, const Locale &locale);
2395
2396 void clear();
2397
2398 void lnfMoveHelper(LocalizedNumberFormatter&& src);
2399
2403 bool computeCompiled(UErrorCode& status) const;
2404
2405 // To give the fluent setters access to this class's constructor:
2406 friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
2407 friend class NumberFormatterSettings<LocalizedNumberFormatter>;
2408
2409 // To give UnlocalizedNumberFormatter::locale() access to this class's constructor:
2410 friend class UnlocalizedNumberFormatter;
2411};
2412
2413#if (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN) && defined(_MSC_VER)
2414// Warning 4661.
2415#pragma warning(pop)
2416#endif
2417
2427 public:
2428
2434 : fData(nullptr), fErrorCode(U_INVALID_STATE_ERROR) {}
2435
2441
2447
2450
2452 FormattedNumber& operator=(const FormattedNumber&) = delete;
2453
2459
2460 // Copybrief: this method is older than the parent method
2469
2470 // Copydoc: this method is new in ICU 64
2473
2474 // Copybrief: this method is older than the parent method
2482 Appendable &appendTo(Appendable& appendable, UErrorCode& status) const U_OVERRIDE;
2483
2484 // Copydoc: this method is new in ICU 64
2487
2488#ifndef U_HIDE_DRAFT_API
2507 template<typename StringClass>
2508 inline StringClass toDecimalNumber(UErrorCode& status) const;
2509#endif // U_HIDE_DRAFT_API
2510
2511#ifndef U_HIDE_INTERNAL_API
2512
2517 void getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const;
2518
2523 void getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih, UErrorCode& status) const;
2524
2525#endif /* U_HIDE_INTERNAL_API */
2526
2527 private:
2528 // Can't use LocalPointer because UFormattedNumberData is forward-declared
2529 const impl::UFormattedNumberData *fData;
2530
2531 // Error code for the terminal methods
2532 UErrorCode fErrorCode;
2533
2538 explicit FormattedNumber(impl::UFormattedNumberData *results)
2539 : fData(results), fErrorCode(U_ZERO_ERROR) {}
2540
2541 explicit FormattedNumber(UErrorCode errorCode)
2542 : fData(nullptr), fErrorCode(errorCode) {}
2543
2544 // TODO(ICU-20775): Propose this as API.
2545 void toDecimalNumber(ByteSink& sink, UErrorCode& status) const;
2546
2547 // To give LocalizedNumberFormatter format methods access to this class's constructor:
2548 friend class LocalizedNumberFormatter;
2549
2550 // To give C API access to internals
2551 friend struct impl::UFormattedNumberImpl;
2552};
2553
2554#ifndef U_HIDE_DRAFT_API
2555// Note: This is draft ICU 65
2556template<typename StringClass>
2558 StringClass result;
2559 StringByteSink<StringClass> sink(&result);
2560 toDecimalNumber(sink, status);
2561 return result;
2562}
2563#endif // U_HIDE_DRAFT_API
2564
2571 public:
2580
2591
2607
2626 UParseError& perror, UErrorCode& status);
2627
2632};
2633
2634} // namespace number
2635U_NAMESPACE_END
2636
2637#endif /* #if !UCONFIG_NO_FORMATTING */
2638
2639#endif /* U_SHOW_CPLUSPLUS_API */
2640
2641#endif // __NUMBERFORMATTER_H__
2642
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 ByteSink can be filled with bytes.
Definition bytestream.h:53
Represents a span of a string containing a given field.
A unit of currency, such as USD (U.S.
Definition currunit.h:39
This class represents the set of symbols needed by DecimalFormat to format numbers.
Definition dcfmtsym.h:86
Base class for all formats.
Definition format.h:98
An abstract formatted value: a string with associated field attributes.
"Smart pointer" class, deletes objects via the standard C++ delete operator.
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:195
A unit such as length, mass, volume, currency, etc.
Definition measunit.h:237
Defines numbering systems.
Definition numsys.h:60
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition plurrule.h:200
Implementation of ByteSink that writes to a "string".
Definition bytestream.h:269
A string-like object that points to a sized piece of memory.
Definition stringpiece.h:60
UMemory is the common ICU base class.
Definition uobject.h:115
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:295
Precision withCurrency(const CurrencyUnit &currency) const
Associates a currency with this rounding precision.
The result of a number formatting operation.
void getDecimalQuantity(impl::DecimalQuantity &output, UErrorCode &status) const
Gets the raw DecimalQuantity for plural rule selection.
FormattedNumber()
Default constructor; makes an empty FormattedNumber.
UnicodeString toTempString(UErrorCode &status) const U_OVERRIDE
Returns the formatted string as a read-only alias to memory owned by the FormattedValue.
void getAllFieldPositionsImpl(FieldPositionIteratorHandler &fpih, UErrorCode &status) const
Populates the mutable builder type FieldPositionIteratorHandler.
Appendable & appendTo(Appendable &appendable, UErrorCode &status) const U_OVERRIDE
Appends the formatted string to an Appendable.
UnicodeString toString(UErrorCode &status) const U_OVERRIDE
Returns the formatted string as a self-contained UnicodeString.
StringClass toDecimalNumber(UErrorCode &status) const
Export the formatted number as a "numeric string" conforming to the syntax defined in the Decimal Ari...
virtual ~FormattedNumber() U_OVERRIDE
Destruct an instance of FormattedNumber.
FormattedNumber(FormattedNumber &&src) U_NOEXCEPT
Move constructor: Leaves the source FormattedNumber in an undefined state.
UBool nextPosition(ConstrainedFieldPosition &cfpos, UErrorCode &status) const U_OVERRIDE
Iterates over field positions in the FormattedValue.
Precision withMinDigits(int32_t minSignificantDigits) const
Ensure that no less than this number of significant digits are retained when rounding according to fr...
Precision withMaxDigits(int32_t maxSignificantDigits) const
Ensure that no more than this number of significant digits are retained when rounding according to fr...
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 NumberFormatter that has a locale associated with it; this means .format() methods are available.
Format * toFormat(UErrorCode &status) const
Creates a representation of this LocalizedNumberFormat as an icu::Format, enabling the use of this nu...
FormattedNumber formatInt(int64_t value, UErrorCode &status) const
Format the given integer number to a string using the settings specified in the NumberFormatter fluen...
LocalizedNumberFormatter()=default
Default constructor: puts the formatter into a valid but undefined state.
LocalizedNumberFormatter(const LocalizedNumberFormatter &other)
Returns a copy of this LocalizedNumberFormatter.
const impl::NumberFormatterImpl * getCompiled() const
Internal method for testing.
int32_t getCallCount() const
Internal method for testing.
~LocalizedNumberFormatter()
Destruct this LocalizedNumberFormatter, cleaning up any memory it might own.
LocalizedNumberFormatter(LocalizedNumberFormatter &&src) U_NOEXCEPT
Move constructor: The source LocalizedNumberFormatter will be left in a valid but undefined state.
void formatImpl(impl::UFormattedNumberData *results, UErrorCode &status) const
This is the core entrypoint to the number formatting pipeline.
FormattedNumber formatDecimal(StringPiece value, UErrorCode &status) const
Format the given decimal number to a string using the settings specified in the NumberFormatter fluen...
LocalizedNumberFormatter & operator=(LocalizedNumberFormatter &&src) U_NOEXCEPT
Move assignment operator: The source LocalizedNumberFormatter will be left in a valid but undefined s...
void getAffixImpl(bool isPrefix, bool isNegative, UnicodeString &result, UErrorCode &status) const
Internal method for DecimalFormat compatibility.
FormattedNumber formatDecimalQuantity(const impl::DecimalQuantity &dq, UErrorCode &status) const
Internal method.
FormattedNumber formatDouble(double value, UErrorCode &status) const
Format the given float or double to a string using the settings specified in the NumberFormatter flue...
LocalizedNumberFormatter & operator=(const LocalizedNumberFormatter &other)
Copy assignment operator.
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,...
An abstract base class for specifying settings related to number formatting.
LocalPointer< Derived > clone() const &
Returns the current (Un)LocalizedNumberFormatter as a LocalPointer wrapping a heap-allocated copy of ...
Derived adoptSymbols(NumberingSystem *symbols) const &
Specifies that the given numbering system should be used when fetching symbols.
Derived precision(const Precision &precision) const &
Specifies the rounding precision to use when formatting numbers.
Derived decimal(UNumberDecimalSeparatorDisplay style) &&
Overload of decimal() for use on an rvalue reference.
Derived unitWidth(UNumberUnitWidth width) const &
Sets the width of the unit (measure unit or currency).
Derived adoptUnit(icu::MeasureUnit *unit) const &
Like unit(), but takes ownership of a pointer.
Derived perUnit(const icu::MeasureUnit &perUnit) &&
Overload of perUnit() for use on an rvalue reference.
Derived padding(const impl::Padder &padder) &&
Derived adoptSymbols(NumberingSystem *symbols) &&
Overload of adoptSymbols() for use on an rvalue reference.
Derived macros(const impl::MacroProps &macros) &&
Derived roundingMode(UNumberFormatRoundingMode roundingMode) &&
Overload of roundingMode() for use on an rvalue reference.
Derived integerWidth(const IntegerWidth &style) const &
Specifies the minimum and maximum number of digits to render before the decimal mark.
Derived macros(const impl::MacroProps &macros) const &
Internal fluent setter to overwrite the entire macros object.
Derived threshold(int32_t threshold) const &
Internal fluent setter to support a custom regulation threshold.
Derived perUnit(const icu::MeasureUnit &perUnit) const &
Sets a unit to be used in the denominator.
Derived integerWidth(const IntegerWidth &style) &&
Overload of integerWidth() for use on an rvalue reference.
Derived grouping(UNumberGroupingStrategy strategy) const &
Specifies the grouping strategy to use when formatting numbers.
Derived unit(const icu::MeasureUnit &unit) const &
Specifies the unit (unit of measure, currency, or percent) to associate with rendered numbers.
UBool copyErrorTo(UErrorCode &outErrorCode) const
Sets the UErrorCode if an error occurred in the fluent chain.
Derived adoptPerUnit(icu::MeasureUnit *perUnit) const &
Like perUnit(), but takes ownership of a pointer.
Derived adoptUnit(icu::MeasureUnit *unit) &&
Overload of adoptUnit() for use on an rvalue reference.
Derived scale(const Scale &scale) &&
Overload of scale() for use on an rvalue reference.
Derived precision(const Precision &precision) &&
Overload of precision() for use on an rvalue reference.
Derived symbols(const DecimalFormatSymbols &symbols) &&
Overload of symbols() for use on an rvalue reference.
Derived padding(const impl::Padder &padder) const &
Set the padding strategy.
Derived notation(const Notation &notation) const &
Specifies the notation style (simple, scientific, or compact) for rendering numbers.
Derived sign(UNumberSignDisplay style) const &
Sets the plus/minus sign display strategy.
Derived threshold(int32_t threshold) &&
Derived roundingMode(UNumberFormatRoundingMode roundingMode) const &
Specifies how to determine the direction to round a number when it has more digits than fit in the de...
Derived symbols(const DecimalFormatSymbols &symbols) const &
Specifies the symbols (decimal separator, grouping separator, percent sign, numerals,...
Derived macros(impl::MacroProps &&macros) &&
Derived sign(UNumberSignDisplay style) &&
Overload of sign() for use on an rvalue reference.
UnicodeString toSkeleton(UErrorCode &status) const
Creates a skeleton string representation of this number formatter.
Derived grouping(UNumberGroupingStrategy strategy) &&
Overload of grouping() for use on an rvalue reference.
Derived adoptPerUnit(icu::MeasureUnit *perUnit) &&
Overload of adoptPerUnit() for use on an rvalue reference.
Derived unitWidth(UNumberUnitWidth width) &&
Overload of unitWidth() for use on an rvalue reference.
Derived decimal(UNumberDecimalSeparatorDisplay style) const &
Sets the decimal separator display strategy.
Derived unit(const icu::MeasureUnit &unit) &&
Overload of unit() for use on an rvalue reference.
Derived macros(impl::MacroProps &&macros) const &
Derived scale(const Scale &scale) const &
Sets a scale (multiplier) to be used to scale the number by an arbitrary amount before formatting.
Derived notation(const Notation &notation) &&
Overload of notation() for use on an rvalue reference.
static UnlocalizedNumberFormatter forSkeleton(const UnicodeString &skeleton, UParseError &perror, UErrorCode &status)
Call this method at the beginning of a NumberFormatter fluent chain to create an instance based on a ...
static UnlocalizedNumberFormatter forSkeleton(const UnicodeString &skeleton, UErrorCode &status)
Call this method at the beginning of a NumberFormatter fluent chain to create an instance based on a ...
static UnlocalizedNumberFormatter with()
Call this method at the beginning of a NumberFormatter fluent chain in which the locale is not curren...
NumberFormatter()=delete
Use factory methods instead of the constructor to create a NumberFormatter.
static LocalizedNumberFormatter withLocale(const Locale &locale)
Call this method at the beginning of a NumberFormatter fluent chain in which the locale is known at t...
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,...
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 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.
Scale(Scale &&src) U_NOEXCEPT
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 & operator=(Scale &&src) U_NOEXCEPT
static Scale byDouble(double multiplicand)
Multiply numbers by an arbitrary value before formatting.
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 ...
A NumberFormatter that does not yet have a locale.
UnlocalizedNumberFormatter & operator=(UnlocalizedNumberFormatter &&src) U_NOEXCEPT
Move assignment operator: The source UnlocalizedNumberFormatter will be left in a valid but undefined...
UnlocalizedNumberFormatter()=default
Default constructor: puts the formatter into a valid but undefined state.
UnlocalizedNumberFormatter(const UnlocalizedNumberFormatter &other)
Returns a copy of this UnlocalizedNumberFormatter.
LocalizedNumberFormatter locale(const icu::Locale &locale) &&
Overload of locale() for use on an rvalue reference.
UnlocalizedNumberFormatter & operator=(const UnlocalizedNumberFormatter &other)
Copy assignment operator.
LocalizedNumberFormatter locale(const icu::Locale &locale) const &
Associate the given locale with the number formatter.
UnlocalizedNumberFormatter(UnlocalizedNumberFormatter &&src) U_NOEXCEPT
Move constructor: The source UnlocalizedNumberFormatter will be left in a valid but undefined state.
static Grouper forStrategy(UNumberGroupingStrategy grouping)
Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping, UNumberGroupingStrategy strategy)
int16_t getSecondary() const
static Grouper forProperties(const DecimalFormatProperties &properties)
Resolve the values in Properties to a Grouper object.
int16_t getPrimary() const
static Padder forProperties(const DecimalFormatProperties &properties)
static Padder codePoints(UChar32 cp, int32_t targetWidth, UNumberFormatPadPosition position)
SymbolsWrapper & operator=(const SymbolsWrapper &other)
bool isNumberingSystem() const
Whether the object is currently holding a NumberingSystem.
SymbolsWrapper(SymbolsWrapper &&src) U_NOEXCEPT
SymbolsWrapper & operator=(SymbolsWrapper &&src) U_NOEXCEPT
const DecimalFormatSymbols * getDecimalFormatSymbols() const
Get the DecimalFormatSymbols pointer.
SymbolsWrapper(const SymbolsWrapper &other)
void setTo(const DecimalFormatSymbols &dfs)
The provided object is copied, but we do not adopt it.
const NumberingSystem * getNumberingSystem() const
Get the NumberingSystem pointer.
void setTo(const NumberingSystem *ns)
Adopt the provided object.
UBool copyErrorTo(UErrorCode &status) const
bool isDecimalFormatSymbols() const
Whether the object is currently holding a DecimalFormatSymbols.
C++ API: Currency Unit Information.
C++ API: Symbols for formatting numbers.
C++ API: FieldPosition identifies the fields in a formatted output.
C++ API: Abstract operations for localized strings.
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.
int16_t digits_t
Datatype for minimum/maximum fraction digits.
Precision SignificantDigitsPrecision
Extra name reserved in case it is needed in the future.
Notation CompactNotation
Extra name reserved in case it is needed in the future.
void touchRangeLocales(impl::RangeMacroProps &macros)
Used for NumberRangeFormatter and implemented in numrange_fluent.cpp.
Notation SimpleNotation
Extra name reserved in case it is needed in the future.
C API: Parse Error Information.
#define U_NOEXCEPT
"noexcept" if supported, otherwise empty.
Definition platform.h:529
C++ API: PluralRules object.
A UParseError struct is used to returned detailed information about parsing errors.
Definition parseerr.h:58
bool copyErrorTo(UErrorCode &status) const
Check all members for errors.
UNumberDecimalSeparatorDisplay decimal
UNumberFormatRoundingMode roundingMode
const AffixPatternProvider * affixProvider
C API: Encapsulates information about a currency.
UCurrencyUsage
Currency Usage used for Decimal Format.
Definition ucurr.h:41
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition umachine.h:425
int8_t UBool
The ICU boolean type.
Definition umachine.h:261
#define U_OVERRIDE
Defined to the C++11 "override" keyword if available.
Definition umachine.h:129
#define TRUE
The TRUE value of a UBool.
Definition umachine.h:265
#define FALSE
The FALSE value of a UBool.
Definition umachine.h:269
C API: Compatibility APIs for number formatting.
UNumberFormatRoundingMode
The possible number format rounding modes.
Definition unum.h:279
@ UNUM_ROUND_HALFEVEN
Half-even rounding.
Definition unum.h:288
UNumberCompactStyle
Constants for specifying short or long format.
Definition unum.h:319
UNumberFormatPadPosition
The possible number format pad positions.
Definition unum.h:308
C-compatible API for localized number formatting; not recommended for C++.
UNumberSignDisplay
An enum declaring how to denote positive and negative numbers.
@ UNUM_SIGN_COUNT
One more than the highest UNumberSignDisplay value.
UNumberDecimalSeparatorDisplay
An enum declaring how to render the decimal separator.
@ UNUM_DECIMAL_SEPARATOR_COUNT
One more than the highest UNumberDecimalSeparatorDisplay value.
UNumberUnitWidth
An enum declaring how to render units, including currencies.
@ UNUM_UNIT_WIDTH_COUNT
One more than the highest UNumberUnitWidth value.
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.
Definition utypes.h:415
@ U_MEMORY_ALLOCATION_ERROR
Memory allocation error.
Definition utypes.h:457
@ U_INVALID_STATE_ERROR
Requested operation can not be completed with ICU in its current state.
Definition utypes.h:478
@ U_ZERO_ERROR
No error, no warning.
Definition utypes.h:449
#define U_FAILURE(x)
Does the error code indicate a failure?
Definition utypes.h:709
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:301