ICU 70.1  70.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/unum.h"
27 #include "unicode/uobject.h"
28 
84 U_NAMESPACE_BEGIN
85 
86 // Forward declarations:
87 class IFixedDecimal;
88 class FieldPositionIteratorHandler;
89 class FormattedStringBuilder;
90 
91 namespace numparse {
92 namespace impl {
93 
94 // Forward declarations:
95 class NumberParserImpl;
96 class MultiplierParseHandler;
97 
98 }
99 }
100 
101 namespace units {
102 
103 // Forward declarations:
104 class UnitsRouter;
105 
106 } // namespace units
107 
108 namespace number { // icu::number
109 
110 // Forward declarations:
111 class UnlocalizedNumberFormatter;
112 class LocalizedNumberFormatter;
113 class FormattedNumber;
114 class Notation;
115 class ScientificNotation;
116 class Precision;
117 class FractionPrecision;
118 class CurrencyPrecision;
119 class IncrementPrecision;
120 class IntegerWidth;
121 
122 namespace impl {
123 
124 // can't be #ifndef U_HIDE_INTERNAL_API; referenced throughout this file in public classes
130 typedef int16_t digits_t;
131 
132 // can't be #ifndef U_HIDE_INTERNAL_API; needed for struct initialization
139 static constexpr int32_t kInternalDefaultThreshold = 3;
140 
141 // Forward declarations:
142 class Padder;
143 struct MacroProps;
144 struct MicroProps;
145 class DecimalQuantity;
146 class UFormattedNumberData;
147 class NumberFormatterImpl;
148 struct ParsedPatternInfo;
149 class ScientificModifier;
150 class MultiplierProducer;
151 class RoundingImpl;
152 class ScientificHandler;
153 class Modifier;
154 class AffixPatternProvider;
155 class NumberPropertyMapper;
156 struct DecimalFormatProperties;
157 class MultiplierFormatHandler;
158 class CurrencySymbols;
159 class GeneratorHelpers;
160 class DecNum;
161 class NumberRangeFormatterImpl;
162 struct RangeMacroProps;
163 struct UFormattedNumberImpl;
164 class MutablePatternModifier;
165 class ImmutablePatternModifier;
166 struct DecimalFormatWarehouse;
167 
175 
176 } // namespace impl
177 
184 
191 
197 class U_I18N_API Notation : public UMemory {
198  public:
224 
248 
291 
315 
341 
342  private:
343  enum NotationType {
344  NTN_SCIENTIFIC, NTN_COMPACT, NTN_SIMPLE, NTN_ERROR
345  } fType;
346 
347  union NotationUnion {
348  // For NTN_SCIENTIFIC
359  } scientific;
360 
361  // For NTN_COMPACT
362  UNumberCompactStyle compactStyle;
363 
364  // For NTN_ERROR
365  UErrorCode errorCode;
366  } fUnion;
367 
369 
370  Notation(const NotationType &type, const NotationUnion &union_) : fType(type), fUnion(union_) {}
371 
372  Notation(UErrorCode errorCode) : fType(NTN_ERROR) {
373  fUnion.errorCode = errorCode;
374  }
375 
376  Notation() : fType(NTN_SIMPLE), fUnion() {}
377 
378  UBool copyErrorTo(UErrorCode &status) const {
379  if (fType == NTN_ERROR) {
380  status = fUnion.errorCode;
381  return true;
382  }
383  return false;
384  }
385 
386  // To allow MacroProps to initialize empty instances:
387  friend struct impl::MacroProps;
388  friend class ScientificNotation;
389 
390  // To allow implementation to access internal types:
391  friend class impl::NumberFormatterImpl;
392  friend class impl::ScientificModifier;
393  friend class impl::ScientificHandler;
394 
395  // To allow access to the skeleton generation code:
396  friend class impl::GeneratorHelpers;
397 };
398 
408  public:
422  ScientificNotation withMinExponentDigits(int32_t minExponentDigits) const;
423 
438 
439  private:
440  // Inherit constructor
441  using Notation::Notation;
442 
443  // Raw constructor for NumberPropertyMapper
444  ScientificNotation(int8_t fEngineeringInterval, bool fRequireMinInt, impl::digits_t fMinExponentDigits,
445  UNumberSignDisplay fExponentSignDisplay);
446 
447  friend class Notation;
448 
449  // So that NumberPropertyMapper can create instances
450  friend class impl::NumberPropertyMapper;
451 };
452 
459 
468 class U_I18N_API Precision : public UMemory {
469 
470  public:
489 
497 
525  static FractionPrecision fixedFraction(int32_t minMaxFractionPlaces);
526 
540  static FractionPrecision minFraction(int32_t minFractionPlaces);
541 
552  static FractionPrecision maxFraction(int32_t maxFractionPlaces);
553 
567  static FractionPrecision minMaxFraction(int32_t minFractionPlaces, int32_t maxFractionPlaces);
568 
582  static SignificantDigitsPrecision fixedSignificantDigits(int32_t minMaxSignificantDigits);
583 
596  static SignificantDigitsPrecision minSignificantDigits(int32_t minSignificantDigits);
597 
606  static SignificantDigitsPrecision maxSignificantDigits(int32_t maxSignificantDigits);
607 
619  static SignificantDigitsPrecision minMaxSignificantDigits(int32_t minSignificantDigits,
620  int32_t maxSignificantDigits);
621 
641  static IncrementPrecision increment(double roundingIncrement);
642 
661 
662 #ifndef U_HIDE_DRAFT_API
671 #endif // U_HIDE_DRAFT_API
672 
673  private:
674  enum PrecisionType {
675  RND_BOGUS,
676  RND_NONE,
677  RND_FRACTION,
678  RND_SIGNIFICANT,
679  RND_FRACTION_SIGNIFICANT,
680 
681  // Used for strange increments like 3.14.
682  RND_INCREMENT,
683 
684  // Used for increments with 1 as the only digit. This is different than fraction
685  // rounding because it supports having additional trailing zeros. For example, this
686  // class is used to round with the increment 0.010.
687  RND_INCREMENT_ONE,
688 
689  // Used for increments with 5 as the only digit (nickel rounding).
690  RND_INCREMENT_FIVE,
691 
692  RND_CURRENCY,
693  RND_ERROR
694  } fType;
695 
696  union PrecisionUnion {
699  // For RND_FRACTION, RND_SIGNIFICANT, and RND_FRACTION_SIGNIFICANT
710  } fracSig;
713  // For RND_INCREMENT, RND_INCREMENT_ONE, and RND_INCREMENT_FIVE
715  double fIncrement;
720  } increment;
721  UCurrencyUsage currencyUsage; // For RND_CURRENCY
722  UErrorCode errorCode; // For RND_ERROR
723  } fUnion;
724 
726 
729 
730  Precision(const PrecisionType& type, const PrecisionUnion& union_)
731  : fType(type), fUnion(union_) {}
732 
733  Precision(UErrorCode errorCode) : fType(RND_ERROR) {
734  fUnion.errorCode = errorCode;
735  }
736 
737  Precision() : fType(RND_BOGUS) {}
738 
739  bool isBogus() const {
740  return fType == RND_BOGUS;
741  }
742 
743  UBool copyErrorTo(UErrorCode &status) const {
744  if (fType == RND_ERROR) {
745  status = fUnion.errorCode;
746  return true;
747  }
748  return false;
749  }
750 
751  // On the parent type so that this method can be called internally on Precision instances.
752  Precision withCurrency(const CurrencyUnit &currency, UErrorCode &status) const;
753 
754  static FractionPrecision constructFraction(int32_t minFrac, int32_t maxFrac);
755 
756  static Precision constructSignificant(int32_t minSig, int32_t maxSig);
757 
758  static Precision constructFractionSignificant(
759  const FractionPrecision &base,
760  int32_t minSig,
761  int32_t maxSig,
762  UNumberRoundingPriority priority);
763 
764  static IncrementPrecision constructIncrement(double increment, int32_t minFrac);
765 
766  static CurrencyPrecision constructCurrency(UCurrencyUsage usage);
767 
768  // To allow MacroProps/MicroProps to initialize bogus instances:
769  friend struct impl::MacroProps;
770  friend struct impl::MicroProps;
771 
772  // To allow NumberFormatterImpl to access isBogus() and other internal methods:
773  friend class impl::NumberFormatterImpl;
774 
775  // To allow NumberPropertyMapper to create instances from DecimalFormatProperties:
776  friend class impl::NumberPropertyMapper;
777 
778  // To allow access to the main implementation class:
779  friend class impl::RoundingImpl;
780 
781  // To allow child classes to call private methods:
782  friend class FractionPrecision;
783  friend class CurrencyPrecision;
784  friend class IncrementPrecision;
785 
786  // To allow access to the skeleton generation code:
787  friend class impl::GeneratorHelpers;
788 
789  // To allow access to isBogus and the default (bogus) constructor:
790  friend class units::UnitsRouter;
791 };
792 
803  public:
804 #ifndef U_HIDE_DRAFT_API
820  int32_t minSignificantDigits,
821  int32_t maxSignificantDigits,
822  UNumberRoundingPriority priority) const;
823 #endif // U_HIDE_DRAFT_API
824 
842  Precision withMinDigits(int32_t minSignificantDigits) const;
843 
861  Precision withMaxDigits(int32_t maxSignificantDigits) const;
862 
863  private:
864  // Inherit constructor
865  using Precision::Precision;
866 
867  // To allow parent class to call this class's constructor:
868  friend class Precision;
869 };
870 
881  public:
899  Precision withCurrency(const CurrencyUnit &currency) const;
900 
901  private:
902  // Inherit constructor
903  using Precision::Precision;
904 
905  // To allow parent class to call this class's constructor:
906  friend class Precision;
907 };
908 
919  public:
935  Precision withMinFraction(int32_t minFrac) const;
936 
937  private:
938  // Inherit constructor
939  using Precision::Precision;
940 
941  // To allow parent class to call this class's constructor:
942  friend class Precision;
943 };
944 
955  public:
967  static IntegerWidth zeroFillTo(int32_t minInt);
968 
980  IntegerWidth truncateAt(int32_t maxInt);
981 
982  private:
983  union {
984  struct {
985  impl::digits_t fMinInt;
986  impl::digits_t fMaxInt;
987  bool fFormatFailIfMoreThanMaxDigits;
988  } minMaxInt;
989  UErrorCode errorCode;
990  } fUnion;
991  bool fHasError = false;
992 
993  IntegerWidth(impl::digits_t minInt, impl::digits_t maxInt, bool formatFailIfMoreThanMaxDigits);
994 
995  IntegerWidth(UErrorCode errorCode) { // NOLINT
996  fUnion.errorCode = errorCode;
997  fHasError = true;
998  }
999 
1000  IntegerWidth() { // NOLINT
1001  fUnion.minMaxInt.fMinInt = -1;
1002  }
1003 
1005  static IntegerWidth standard() {
1006  return IntegerWidth::zeroFillTo(1);
1007  }
1008 
1009  bool isBogus() const {
1010  return !fHasError && fUnion.minMaxInt.fMinInt == -1;
1011  }
1012 
1013  UBool copyErrorTo(UErrorCode &status) const {
1014  if (fHasError) {
1015  status = fUnion.errorCode;
1016  return true;
1017  }
1018  return false;
1019  }
1020 
1021  void apply(impl::DecimalQuantity &quantity, UErrorCode &status) const;
1022 
1023  bool operator==(const IntegerWidth& other) const;
1024 
1025  // To allow MacroProps/MicroProps to initialize empty instances:
1026  friend struct impl::MacroProps;
1027  friend struct impl::MicroProps;
1028 
1029  // To allow NumberFormatterImpl to access isBogus():
1030  friend class impl::NumberFormatterImpl;
1031 
1032  // To allow the use of this class when formatting:
1033  friend class impl::MutablePatternModifier;
1034  friend class impl::ImmutablePatternModifier;
1035 
1036  // So that NumberPropertyMapper can create instances
1037  friend class impl::NumberPropertyMapper;
1038 
1039  // To allow access to the skeleton generation code:
1040  friend class impl::GeneratorHelpers;
1041 };
1042 
1051 class U_I18N_API Scale : public UMemory {
1052  public:
1059  static Scale none();
1060 
1071  static Scale powerOfTen(int32_t power);
1072 
1085  static Scale byDecimal(StringPiece multiplicand);
1086 
1095  static Scale byDouble(double multiplicand);
1096 
1103  static Scale byDoubleAndPowerOfTen(double multiplicand, int32_t power);
1104 
1105  // We need a custom destructor for the DecNum, which means we need to declare
1106  // the copy/move constructor/assignment quartet.
1107 
1109  Scale(const Scale& other);
1110 
1112  Scale& operator=(const Scale& other);
1113 
1116 
1119 
1122 
1123 #ifndef U_HIDE_INTERNAL_API
1125  Scale(int32_t magnitude, impl::DecNum* arbitraryToAdopt);
1126 #endif /* U_HIDE_INTERNAL_API */
1127 
1128  private:
1129  int32_t fMagnitude;
1130  impl::DecNum* fArbitrary;
1131  UErrorCode fError;
1132 
1133  Scale(UErrorCode error) : fMagnitude(0), fArbitrary(nullptr), fError(error) {}
1134 
1135  Scale() : fMagnitude(0), fArbitrary(nullptr), fError(U_ZERO_ERROR) {}
1136 
1137  bool isValid() const {
1138  return fMagnitude != 0 || fArbitrary != nullptr;
1139  }
1140 
1141  UBool copyErrorTo(UErrorCode &status) const {
1142  if (U_FAILURE(fError)) {
1143  status = fError;
1144  return true;
1145  }
1146  return false;
1147  }
1148 
1149  void applyTo(impl::DecimalQuantity& quantity) const;
1150 
1151  void applyReciprocalTo(impl::DecimalQuantity& quantity) const;
1152 
1153  // To allow MacroProps/MicroProps to initialize empty instances:
1154  friend struct impl::MacroProps;
1155  friend struct impl::MicroProps;
1156 
1157  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1158  friend class impl::NumberFormatterImpl;
1159 
1160  // To allow the helper class MultiplierFormatHandler access to private fields:
1161  friend class impl::MultiplierFormatHandler;
1162 
1163  // To allow access to the skeleton generation code:
1164  friend class impl::GeneratorHelpers;
1165 
1166  // To allow access to parsing code:
1167  friend class ::icu::numparse::impl::NumberParserImpl;
1168  friend class ::icu::numparse::impl::MultiplierParseHandler;
1169 };
1170 
1171 namespace impl {
1172 
1173 // Do not enclose entire StringProp with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1179 
1180 #ifndef U_HIDE_INTERNAL_API
1181 
1182  public:
1184  StringProp(const StringProp &other);
1185 
1188 
1191 
1194 
1197 
1199  int16_t length() const {
1200  return fLength;
1201  }
1202 
1206  void set(StringPiece value);
1207 
1209  bool isSet() const {
1210  return fLength > 0;
1211  }
1212 
1213 #endif // U_HIDE_INTERNAL_API
1214 
1215  private:
1216  char *fValue;
1217  int16_t fLength;
1218  UErrorCode fError;
1219 
1220  StringProp() : fValue(nullptr), fLength(0), fError(U_ZERO_ERROR) {
1221  }
1222 
1224  UBool copyErrorTo(UErrorCode &status) const {
1225  if (U_FAILURE(fError)) {
1226  status = fError;
1227  return true;
1228  }
1229  return false;
1230  }
1231 
1232  // Allow NumberFormatterImpl to access fValue.
1233  friend class impl::NumberFormatterImpl;
1234 
1235  // Allow skeleton generation code to access private members.
1236  friend class impl::GeneratorHelpers;
1237 
1238  // Allow MacroProps/MicroProps to initialize empty instances and to call
1239  // copyErrorTo().
1240  friend struct impl::MacroProps;
1241 };
1242 
1243 // Do not enclose entire SymbolsWrapper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1246  public:
1248  SymbolsWrapper() : fType(SYMPTR_NONE), fPtr{nullptr} {}
1249 
1252 
1255 
1258 
1261 
1264 
1265 #ifndef U_HIDE_INTERNAL_API
1266 
1271  void setTo(const DecimalFormatSymbols &dfs);
1272 
1277  void setTo(const NumberingSystem *ns);
1278 
1284 
1289  bool isNumberingSystem() const;
1290 
1296 
1302 
1303 #endif // U_HIDE_INTERNAL_API
1304 
1306  UBool copyErrorTo(UErrorCode &status) const {
1307  if (fType == SYMPTR_DFS && fPtr.dfs == nullptr) {
1308  status = U_MEMORY_ALLOCATION_ERROR;
1309  return true;
1310  } else if (fType == SYMPTR_NS && fPtr.ns == nullptr) {
1311  status = U_MEMORY_ALLOCATION_ERROR;
1312  return true;
1313  }
1314  return false;
1315  }
1316 
1317  private:
1318  enum SymbolsPointerType {
1319  SYMPTR_NONE, SYMPTR_DFS, SYMPTR_NS
1320  } fType;
1321 
1322  union {
1323  const DecimalFormatSymbols *dfs;
1324  const NumberingSystem *ns;
1325  } fPtr;
1326 
1327  void doCopyFrom(const SymbolsWrapper &other);
1328 
1329  void doMoveFrom(SymbolsWrapper&& src);
1330 
1331  void doCleanup();
1332 };
1333 
1334 // Do not enclose entire Grouper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1336 class U_I18N_API Grouper : public UMemory {
1337  public:
1338 #ifndef U_HIDE_INTERNAL_API
1341 
1346  static Grouper forProperties(const DecimalFormatProperties& properties);
1347 
1348  // Future: static Grouper forProperties(DecimalFormatProperties& properties);
1349 
1351  Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping, UNumberGroupingStrategy strategy)
1352  : fGrouping1(grouping1),
1353  fGrouping2(grouping2),
1354  fMinGrouping(minGrouping),
1355  fStrategy(strategy) {}
1356 
1358  int16_t getPrimary() const;
1359 
1361  int16_t getSecondary() const;
1362 #endif // U_HIDE_INTERNAL_API
1363 
1364  private:
1373  int16_t fGrouping1;
1374  int16_t fGrouping2;
1375 
1383  int16_t fMinGrouping;
1384 
1389  UNumberGroupingStrategy fStrategy;
1390 
1391  Grouper() : fGrouping1(-3) {}
1392 
1393  bool isBogus() const {
1394  return fGrouping1 == -3;
1395  }
1396 
1398  void setLocaleData(const impl::ParsedPatternInfo &patternInfo, const Locale& locale);
1399 
1400  bool groupAtPosition(int32_t position, const impl::DecimalQuantity &value) const;
1401 
1402  // To allow MacroProps/MicroProps to initialize empty instances:
1403  friend struct MacroProps;
1404  friend struct MicroProps;
1405 
1406  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1407  friend class NumberFormatterImpl;
1408 
1409  // To allow NumberParserImpl to perform setLocaleData():
1410  friend class ::icu::numparse::impl::NumberParserImpl;
1411 
1412  // To allow access to the skeleton generation code:
1413  friend class impl::GeneratorHelpers;
1414 };
1415 
1416 // Do not enclose entire Padder with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1418 class U_I18N_API Padder : public UMemory {
1419  public:
1420 #ifndef U_HIDE_INTERNAL_API
1422  static Padder none();
1423 
1425  static Padder codePoints(UChar32 cp, int32_t targetWidth, UNumberFormatPadPosition position);
1426 
1428  static Padder forProperties(const DecimalFormatProperties& properties);
1429 #endif // U_HIDE_INTERNAL_API
1430 
1431  private:
1432  UChar32 fWidth; // -3 = error; -2 = bogus; -1 = no padding
1433  union {
1434  struct {
1435  int32_t fCp;
1436  UNumberFormatPadPosition fPosition;
1437  } padding;
1438  UErrorCode errorCode;
1439  } fUnion;
1440 
1441  Padder(UChar32 cp, int32_t width, UNumberFormatPadPosition position);
1442 
1443  Padder(int32_t width);
1444 
1445  Padder(UErrorCode errorCode) : fWidth(-3) { // NOLINT
1446  fUnion.errorCode = errorCode;
1447  }
1448 
1449  Padder() : fWidth(-2) {} // NOLINT
1450 
1451  bool isBogus() const {
1452  return fWidth == -2;
1453  }
1454 
1455  UBool copyErrorTo(UErrorCode &status) const {
1456  if (fWidth == -3) {
1457  status = fUnion.errorCode;
1458  return true;
1459  }
1460  return false;
1461  }
1462 
1463  bool isValid() const {
1464  return fWidth > 0;
1465  }
1466 
1467  int32_t padAndApply(const impl::Modifier &mod1, const impl::Modifier &mod2,
1468  FormattedStringBuilder &string, int32_t leftIndex, int32_t rightIndex,
1469  UErrorCode &status) const;
1470 
1471  // To allow MacroProps/MicroProps to initialize empty instances:
1472  friend struct MacroProps;
1473  friend struct MicroProps;
1474 
1475  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1476  friend class impl::NumberFormatterImpl;
1477 
1478  // To allow access to the skeleton generation code:
1479  friend class impl::GeneratorHelpers;
1480 };
1481 
1482 // Do not enclose entire MacroProps with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1484 struct U_I18N_API MacroProps : public UMemory {
1487 
1489  MeasureUnit unit; // = MeasureUnit(); (the base dimensionless unit)
1490 
1492  MeasureUnit perUnit; // = MeasureUnit(); (the base dimensionless unit)
1493 
1495  Precision precision; // = Precision(); (bogus)
1496 
1499 
1501  Grouper grouper; // = Grouper(); (bogus)
1502 
1504  Padder padder; // = Padder(); (bogus)
1505 
1507  IntegerWidth integerWidth; // = IntegerWidth(); (bogus)
1508 
1511 
1512  // UNUM_XYZ_COUNT denotes null (bogus) values.
1513 
1516 
1519 
1521  bool approximately = false;
1522 
1525 
1527  Scale scale; // = Scale(); (benign value)
1528 
1530  StringProp usage; // = StringProp(); (no usage)
1531 
1533  StringProp unitDisplayCase; // = StringProp(); (nominative)
1534 
1536  const AffixPatternProvider* affixProvider = nullptr; // no ownership
1537 
1539  const PluralRules* rules = nullptr; // no ownership
1540 
1542  int32_t threshold = kInternalDefaultThreshold;
1543 
1546 
1547  // NOTE: Uses default copy and move constructors.
1548 
1553  bool copyErrorTo(UErrorCode &status) const {
1554  return notation.copyErrorTo(status) || precision.copyErrorTo(status) ||
1555  padder.copyErrorTo(status) || integerWidth.copyErrorTo(status) ||
1556  symbols.copyErrorTo(status) || scale.copyErrorTo(status) || usage.copyErrorTo(status) ||
1557  unitDisplayCase.copyErrorTo(status);
1558  }
1559 };
1560 
1561 } // namespace impl
1562 
1563 #if (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN) && defined(_MSC_VER)
1564 // Ignore MSVC warning 4661. This is generated for NumberFormatterSettings<>::toSkeleton() as this method
1565 // is defined elsewhere (in number_skeletons.cpp). The compiler is warning that the explicit template instantiation
1566 // inside this single translation unit (CPP file) is incomplete, and thus it isn't sure if the template class is
1567 // fully defined. However, since each translation unit explicitly instantiates all the necessary template classes,
1568 // they will all be passed to the linker, and the linker will still find and export all the class members.
1569 #pragma warning(push)
1570 #pragma warning(disable: 4661)
1571 #endif
1572 
1578 template<typename Derived>
1580  public:
1609  Derived notation(const Notation &notation) const &;
1610 
1620  Derived notation(const Notation &notation) &&;
1621 
1670  Derived unit(const icu::MeasureUnit &unit) const &;
1671 
1681  Derived unit(const icu::MeasureUnit &unit) &&;
1682 
1696  Derived adoptUnit(icu::MeasureUnit *unit) const &;
1697 
1707  Derived adoptUnit(icu::MeasureUnit *unit) &&;
1708 
1731  Derived perUnit(const icu::MeasureUnit &perUnit) const &;
1732 
1742  Derived perUnit(const icu::MeasureUnit &perUnit) &&;
1743 
1757  Derived adoptPerUnit(icu::MeasureUnit *perUnit) const &;
1758 
1768  Derived adoptPerUnit(icu::MeasureUnit *perUnit) &&;
1769 
1800  Derived precision(const Precision& precision) const &;
1801 
1811  Derived precision(const Precision& precision) &&;
1812 
1831  Derived roundingMode(UNumberFormatRoundingMode roundingMode) const &;
1832 
1841  Derived roundingMode(UNumberFormatRoundingMode roundingMode) &&;
1842 
1870  Derived grouping(UNumberGroupingStrategy strategy) const &;
1871 
1881  Derived grouping(UNumberGroupingStrategy strategy) &&;
1882 
1907  Derived integerWidth(const IntegerWidth &style) const &;
1908 
1918  Derived integerWidth(const IntegerWidth &style) &&;
1919 
1960  Derived symbols(const DecimalFormatSymbols &symbols) const &;
1961 
1971  Derived symbols(const DecimalFormatSymbols &symbols) &&;
1972 
2006  Derived adoptSymbols(NumberingSystem *symbols) const &;
2007 
2017  Derived adoptSymbols(NumberingSystem *symbols) &&;
2018 
2044  Derived unitWidth(UNumberUnitWidth width) const &;
2045 
2055  Derived unitWidth(UNumberUnitWidth width) &&;
2056 
2082  Derived sign(UNumberSignDisplay style) const &;
2083 
2093  Derived sign(UNumberSignDisplay style) &&;
2094 
2120  Derived decimal(UNumberDecimalSeparatorDisplay style) const &;
2121 
2132 
2157  Derived scale(const Scale &scale) const &;
2158 
2168  Derived scale(const Scale &scale) &&;
2169 
2212  Derived usage(StringPiece usage) const &;
2213 
2221  Derived usage(StringPiece usage) &&;
2222 
2223 #ifndef U_HIDE_DRAFT_API
2224 #ifndef U_HIDE_INTERNAL_API
2231  Derived unitDisplayCase(StringPiece unitDisplayCase) const &;
2232 
2238  Derived unitDisplayCase(StringPiece unitDisplayCase) &&;
2239 #endif // U_HIDE_INTERNAL_API
2240 #endif // U_HIDE_DRAFT_API
2241 
2242 #ifndef U_HIDE_INTERNAL_API
2243 
2249  Derived padding(const impl::Padder &padder) const &;
2250 
2252  Derived padding(const impl::Padder &padder) &&;
2253 
2260  Derived threshold(int32_t threshold) const &;
2261 
2263  Derived threshold(int32_t threshold) &&;
2264 
2270  Derived macros(const impl::MacroProps& macros) const &;
2271 
2273  Derived macros(const impl::MacroProps& macros) &&;
2274 
2276  Derived macros(impl::MacroProps&& macros) const &;
2277 
2279  Derived macros(impl::MacroProps&& macros) &&;
2280 
2281 #endif /* U_HIDE_INTERNAL_API */
2282 
2301 
2314 
2322  LocalPointer<Derived> clone() &&;
2323 
2330  UBool copyErrorTo(UErrorCode &outErrorCode) const {
2331  if (U_FAILURE(outErrorCode)) {
2332  // Do not overwrite the older error code
2333  return true;
2334  }
2335  fMacros.copyErrorTo(outErrorCode);
2336  return U_FAILURE(outErrorCode);
2337  }
2338 
2339  // NOTE: Uses default copy and move constructors.
2340 
2341  private:
2342  impl::MacroProps fMacros;
2343 
2344  // Don't construct me directly! Use (Un)LocalizedNumberFormatter.
2345  NumberFormatterSettings() = default;
2346 
2347  friend class LocalizedNumberFormatter;
2348  friend class UnlocalizedNumberFormatter;
2349 
2350  // Give NumberRangeFormatter access to the MacroProps
2351  friend void impl::touchRangeLocales(impl::RangeMacroProps& macros);
2352  friend class impl::NumberRangeFormatterImpl;
2353 };
2354 
2364  : public NumberFormatterSettings<UnlocalizedNumberFormatter>, public UMemory {
2365 
2366  public:
2377 
2388 
2395 
2401 
2408 
2414 
2421 
2422  private:
2424 
2425  explicit UnlocalizedNumberFormatter(
2427 
2428  // To give the fluent setters access to this class's constructor:
2430 
2431  // To give NumberFormatter::with() access to this class's constructor:
2432  friend class NumberFormatter;
2433 };
2434 
2444  : public NumberFormatterSettings<LocalizedNumberFormatter>, public UMemory {
2445  public:
2457  FormattedNumber formatInt(int64_t value, UErrorCode &status) const;
2458 
2470  FormattedNumber formatDouble(double value, UErrorCode &status) const;
2471 
2487 
2488 #ifndef U_HIDE_INTERNAL_API
2489 
2490 
2495 
2499  FormattedNumber formatDecimalQuantity(const impl::DecimalQuantity& dq, UErrorCode& status) const;
2500 
2504  void getAffixImpl(bool isPrefix, bool isNegative, UnicodeString& result, UErrorCode& status) const;
2505 
2510  const impl::NumberFormatterImpl* getCompiled() const;
2511 
2516  int32_t getCallCount() const;
2517 
2518 #endif /* U_HIDE_INTERNAL_API */
2519 
2533  Format* toFormat(UErrorCode& status) const;
2534 
2541 
2547 
2554 
2560 
2567 
2568 #ifndef U_HIDE_INTERNAL_API
2569 
2582  void formatImpl(impl::UFormattedNumberData *results, UErrorCode &status) const;
2583 
2584 #endif /* U_HIDE_INTERNAL_API */
2585 
2591 
2592  private:
2593  // Note: fCompiled can't be a LocalPointer because impl::NumberFormatterImpl is defined in an internal
2594  // header, and LocalPointer needs the full class definition in order to delete the instance.
2595  const impl::NumberFormatterImpl* fCompiled {nullptr};
2596  char fUnsafeCallCount[8] {}; // internally cast to u_atomic_int32_t
2597 
2598  // Owned pointer to a DecimalFormatWarehouse, used when copying a LocalizedNumberFormatter
2599  // from a DecimalFormat.
2600  const impl::DecimalFormatWarehouse* fWarehouse {nullptr};
2601 
2602  explicit LocalizedNumberFormatter(const NumberFormatterSettings<LocalizedNumberFormatter>& other);
2603 
2604  explicit LocalizedNumberFormatter(NumberFormatterSettings<LocalizedNumberFormatter>&& src) U_NOEXCEPT;
2605 
2606  LocalizedNumberFormatter(const impl::MacroProps &macros, const Locale &locale);
2607 
2608  LocalizedNumberFormatter(impl::MacroProps &&macros, const Locale &locale);
2609 
2610  void resetCompiled();
2611 
2612  void lnfMoveHelper(LocalizedNumberFormatter&& src);
2613 
2614  void lnfCopyHelper(const LocalizedNumberFormatter& src, UErrorCode& status);
2615 
2619  bool computeCompiled(UErrorCode& status) const;
2620 
2621  // To give the fluent setters access to this class's constructor:
2622  friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
2623  friend class NumberFormatterSettings<LocalizedNumberFormatter>;
2624 
2625  // To give UnlocalizedNumberFormatter::locale() access to this class's constructor:
2626  friend class UnlocalizedNumberFormatter;
2627 };
2628 
2629 #if (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN) && defined(_MSC_VER)
2630 // Warning 4661.
2631 #pragma warning(pop)
2632 #endif
2633 
2643  public:
2644 
2650  : fData(nullptr), fErrorCode(U_INVALID_STATE_ERROR) {}
2651 
2657 
2663 
2666 
2668  FormattedNumber& operator=(const FormattedNumber&) = delete;
2669 
2675 
2676  // Copybrief: this method is older than the parent method
2684  UnicodeString toString(UErrorCode& status) const U_OVERRIDE;
2685 
2686  // Copydoc: this method is new in ICU 64
2688  UnicodeString toTempString(UErrorCode& status) const U_OVERRIDE;
2689 
2690  // Copybrief: this method is older than the parent method
2698  Appendable &appendTo(Appendable& appendable, UErrorCode& status) const U_OVERRIDE;
2699 
2700  // Copydoc: this method is new in ICU 64
2702  UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE;
2703 
2722  template<typename StringClass>
2723  inline StringClass toDecimalNumber(UErrorCode& status) const;
2724 
2736  MeasureUnit getOutputUnit(UErrorCode& status) const;
2737 
2738 #ifndef U_HIDE_INTERNAL_API
2745  const char *getGender(UErrorCode& status) const;
2746 
2751  void getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const;
2752 
2757  void getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih, UErrorCode& status) const;
2758 
2759 #endif /* U_HIDE_INTERNAL_API */
2760 
2761  private:
2762  // Can't use LocalPointer because UFormattedNumberData is forward-declared
2763  const impl::UFormattedNumberData *fData;
2764 
2765  // Error code for the terminal methods
2766  UErrorCode fErrorCode;
2767 
2772  explicit FormattedNumber(impl::UFormattedNumberData *results)
2773  : fData(results), fErrorCode(U_ZERO_ERROR) {}
2774 
2775  explicit FormattedNumber(UErrorCode errorCode)
2776  : fData(nullptr), fErrorCode(errorCode) {}
2777 
2778  void toDecimalNumber(ByteSink& sink, UErrorCode& status) const;
2779 
2780  // To give LocalizedNumberFormatter format methods access to this class's constructor:
2781  friend class LocalizedNumberFormatter;
2782 
2783  // To give C API access to internals
2784  friend struct impl::UFormattedNumberImpl;
2785 };
2786 
2787 template<typename StringClass>
2788 StringClass FormattedNumber::toDecimalNumber(UErrorCode& status) const {
2789  StringClass result;
2790  StringByteSink<StringClass> sink(&result);
2791  toDecimalNumber(sink, status);
2792  return result;
2793 }
2794 
2801  public:
2810 
2821 
2840 
2862  UParseError& perror, UErrorCode& status);
2863 
2867  NumberFormatter() = delete;
2868 };
2869 
2870 } // namespace number
2871 U_NAMESPACE_END
2872 
2873 #endif /* #if !UCONFIG_NO_FORMATTING */
2874 
2875 #endif /* U_SHOW_CPLUSPLUS_API */
2876 
2877 #endif // __NUMBERFORMATTER_H__
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.
Base class for objects to which Unicode characters and strings can be appended.
Definition: appendable.h:54
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.
Definition: localpointer.h:191
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:371
Defines numbering systems.
Definition: numsys.h:60
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:206
Implementation of ByteSink that writes to a "string".
Definition: bytestream.h:267
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:296
A class that defines a rounding precision parameterized by a currency to be used when formatting numb...
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.
void getAllFieldPositionsImpl(FieldPositionIteratorHandler &fpih, UErrorCode &status) const
Populates the mutable builder type FieldPositionIteratorHandler.
const char * getGender(UErrorCode &status) const
Gets the gender of the formatted output.
virtual ~FormattedNumber() U_OVERRIDE
Destruct an instance of FormattedNumber.
FormattedNumber(FormattedNumber &&src) U_NOEXCEPT
Move constructor: Leaves the source FormattedNumber in an undefined state.
A class that defines a rounding precision based on a number of fraction places and optionally signifi...
Precision withMinDigits(int32_t minSignificantDigits) const
Ensure that no less than this number of significant digits are retained when rounding according to fr...
Precision withSignificantDigits(int32_t minSignificantDigits, int32_t maxSignificantDigits, UNumberRoundingPriority priority) const
Override maximum fraction digits with maximum significant digits depending on the magnitude of the nu...
Precision withMaxDigits(int32_t maxSignificantDigits) const
Ensure that no more than this number of significant digits are retained when rounding according to fr...
A class that defines a rounding precision parameterized by a rounding increment to be used when forma...
Precision withMinFraction(int32_t minFrac) const
Specifies the minimum number of fraction digits to render after the decimal separator,...
A class that defines the strategy for padding and truncating integers before the decimal separator.
static IntegerWidth zeroFillTo(int32_t minInt)
Pad numbers at the beginning with zeros to guarantee a certain number of numerals before the decimal ...
IntegerWidth truncateAt(int32_t maxInt)
Truncate numbers exceeding a certain number of numerals before the decimal separator.
A NumberFormatter that has a locale associated with it; this means .format() methods are available.
const DecimalFormatSymbols * getDecimalFormatSymbols() const
const impl::NumberFormatterImpl * getCompiled() const
Internal method for testing.
LocalizedNumberFormatter & operator=(const LocalizedNumberFormatter &other)
Copy assignment operator.
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.
int32_t getCallCount() const
Internal method for testing.
~LocalizedNumberFormatter()
Destruct this LocalizedNumberFormatter, cleaning up any memory it might own.
Format * toFormat(UErrorCode &status) const
Creates a representation of this LocalizedNumberFormat as an icu::Format, enabling the use of this nu...
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.
LocalizedNumberFormatter & operator=(LocalizedNumberFormatter &&src) U_NOEXCEPT
Move assignment operator: The source LocalizedNumberFormatter will be left in a valid but undefined s...
FormattedNumber formatDecimal(StringPiece value, UErrorCode &status) const
Format the given decimal number to a string using the settings specified in the NumberFormatter fluen...
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...
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.
Derived unitDisplayCase(StringPiece unitDisplayCase) &&
Overload of unitDisplayCase() for use on an rvalue reference.
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 unitDisplayCase(StringPiece unitDisplayCase) const &
Specifies the desired case for a unit formatter's output (e.g.
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.
Derived usage(StringPiece usage) &&
Overload of usage() for use on an rvalue reference.
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) &&
LocalPointer< Derived > clone() const &
Returns the current (Un)LocalizedNumberFormatter as a LocalPointer wrapping a heap-allocated copy of ...
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 usage(StringPiece usage) const &
Specifies the usage for which numbers will be formatted ("person-height", "road", "rainfall",...
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.
See the main description in numberformatter.h for documentation and examples.
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,...
Precision trailingZeroDisplay(UNumberTrailingZeroDisplay trailingZeroDisplay) const
Configure how trailing zeros are displayed on numbers.
static Precision unlimited()
Show all available digits to full precision.
static FractionPrecision integer()
Show numbers rounded if necessary to the nearest integer.
static SignificantDigitsPrecision fixedSignificantDigits(int32_t minMaxSignificantDigits)
Show numbers rounded if necessary to a certain number of significant digits or significant figures.
static 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
Scale & operator=(const Scale &other)
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=(Scale &&src) U_NOEXCEPT
static Scale byDouble(double multiplicand)
Multiply numbers by an arbitrary value before formatting.
A class that defines the scientific notation style to be used when formatting numbers in NumberFormat...
ScientificNotation withExponentSignDisplay(UNumberSignDisplay exponentSignDisplay) const
Sets whether to show the sign on positive and negative exponents in scientific notation.
ScientificNotation withMinExponentDigits(int32_t minExponentDigits) const
Sets the minimum number of digits to show in the exponent of scientific notation, padding with zeros ...
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 & operator=(const UnlocalizedNumberFormatter &other)
Copy assignment operator.
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.
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)
Manages NumberFormatterSettings::usage()'s char* instance on the heap.
StringProp & operator=(StringProp &&src) U_NOEXCEPT
StringProp(const StringProp &other)
StringProp & operator=(const StringProp &other)
void set(StringPiece value)
StringProp(StringProp &&src) U_NOEXCEPT
SymbolsWrapper & operator=(SymbolsWrapper &&src) U_NOEXCEPT
SymbolsWrapper & operator=(const SymbolsWrapper &other)
const NumberingSystem * getNumberingSystem() const
Get the NumberingSystem pointer.
bool isNumberingSystem() const
Whether the object is currently holding a NumberingSystem.
const DecimalFormatSymbols * getDecimalFormatSymbols() const
Get the DecimalFormatSymbols pointer.
SymbolsWrapper(SymbolsWrapper &&src) U_NOEXCEPT
SymbolsWrapper(const SymbolsWrapper &other)
void setTo(const DecimalFormatSymbols &dfs)
The provided object is copied, but we do not adopt it.
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.
void touchRangeLocales(impl::RangeMacroProps &macros)
Used for NumberRangeFormatter and implemented in numrange_fluent.cpp.
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.
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:467
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
#define U_OVERRIDE
Defined to the C++11 "override" keyword if available.
Definition: umachine.h:130
C API: Compatibility APIs for number formatting.
UNumberFormatRoundingMode
The possible number format rounding modes.
Definition: unum.h:282
@ UNUM_ROUND_HALFEVEN
Half-even rounding.
Definition: unum.h:291
UNumberCompactStyle
Constants for specifying short or long format.
Definition: unum.h:339
UNumberFormatPadPosition
The possible number format pad positions.
Definition: unum.h:328
C-compatible API for localized number formatting; not recommended for C++.
UNumberRoundingPriority
An enum declaring how to resolve conflicts between maximum fraction digits and maximum significant di...
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.
UNumberTrailingZeroDisplay
An enum declaring how to render trailing zeros.
@ UNUM_TRAILING_ZERO_AUTO
Display trailing zeros according to the settings for minimum fraction and significant digits.
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:717
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:301