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"
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 
85 U_NAMESPACE_BEGIN
86 
87 // Forward declarations:
88 class IFixedDecimal;
89 class FieldPositionIteratorHandler;
90 class FormattedStringBuilder;
91 
92 namespace numparse {
93 namespace impl {
94 
95 // Forward declarations:
96 class NumberParserImpl;
97 class MultiplierParseHandler;
98 
99 }
100 }
101 
102 namespace number { // icu::number
103 
104 // Forward declarations:
105 class UnlocalizedNumberFormatter;
106 class LocalizedNumberFormatter;
107 class FormattedNumber;
108 class Notation;
109 class ScientificNotation;
110 class Precision;
111 class FractionPrecision;
112 class CurrencyPrecision;
113 class IncrementPrecision;
114 class IntegerWidth;
115 
116 namespace impl {
117 
118 // can't be #ifndef U_HIDE_INTERNAL_API; referenced throughout this file in public classes
124 typedef int16_t digits_t;
125 
126 // can't be #ifndef U_HIDE_INTERNAL_API; needed for struct initialization
133 static constexpr int32_t kInternalDefaultThreshold = 3;
134 
135 // Forward declarations:
136 class Padder;
137 struct MacroProps;
138 struct MicroProps;
139 class DecimalQuantity;
140 class UFormattedNumberData;
141 class NumberFormatterImpl;
142 struct ParsedPatternInfo;
143 class ScientificModifier;
144 class MultiplierProducer;
145 class RoundingImpl;
146 class ScientificHandler;
147 class Modifier;
148 class AffixPatternProvider;
149 class NumberPropertyMapper;
150 struct DecimalFormatProperties;
151 class MultiplierFormatHandler;
152 class CurrencySymbols;
153 class GeneratorHelpers;
154 class DecNum;
155 class NumberRangeFormatterImpl;
156 struct RangeMacroProps;
157 struct UFormattedNumberImpl;
158 class MutablePatternModifier;
159 class ImmutablePatternModifier;
160 
168 
169 } // namespace impl
170 
177 
184 
190 class U_I18N_API Notation : public UMemory {
191  public:
217 
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
352  } scientific;
353 
354  // For NTN_COMPACT
355  UNumberCompactStyle compactStyle;
356 
357  // For NTN_ERROR
358  UErrorCode errorCode;
359  } fUnion;
360 
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 
401  public:
415  ScientificNotation withMinExponentDigits(int32_t minExponentDigits) const;
416 
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 
461 class U_I18N_API Precision : public UMemory {
462 
463  public:
482 
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 
575  static SignificantDigitsPrecision fixedSignificantDigits(int32_t minMaxSignificantDigits);
576 
589  static SignificantDigitsPrecision minSignificantDigits(int32_t minSignificantDigits);
590 
599  static SignificantDigitsPrecision maxSignificantDigits(int32_t maxSignificantDigits);
600 
612  static SignificantDigitsPrecision minMaxSignificantDigits(int32_t minSignificantDigits,
613  int32_t maxSignificantDigits);
614 
634  static IncrementPrecision increment(double roundingIncrement);
635 
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;
693  // For RND_INCREMENT, RND_INCREMENT_ONE, and RND_INCREMENT_FIVE
695  double fIncrement;
700  } increment;
701  UCurrencyUsage currencyUsage; // For RND_CURRENCY
702  UErrorCode errorCode; // For RND_ERROR
703  } fUnion;
704 
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 
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 
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 
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 
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 
1007 class 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
1080 
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 
1127 namespace 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 
1192  UBool copyErrorTo(UErrorCode &status) const {
1193  if (fType == SYMPTR_DFS && fPtr.dfs == nullptr) {
1194  status = U_MEMORY_ALLOCATION_ERROR;
1195  return TRUE;
1196  } else if (fType == SYMPTR_NS && fPtr.ns == nullptr) {
1197  status = U_MEMORY_ALLOCATION_ERROR;
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
1222 class U_I18N_API Grouper : public UMemory {
1223  public:
1224 #ifndef U_HIDE_INTERNAL_API
1225 
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
1304 class U_I18N_API Padder : public UMemory {
1305  public:
1306 #ifndef U_HIDE_INTERNAL_API
1307 
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
1370 struct U_I18N_API MacroProps : public UMemory {
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 
1454 template<typename Derived>
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 
1567  Derived adoptUnit(icu::MeasureUnit *unit) const &;
1568 
1578  Derived adoptUnit(icu::MeasureUnit *unit) &&;
1579 
1602  Derived perUnit(const icu::MeasureUnit &perUnit) const &;
1603 
1613  Derived perUnit(const icu::MeasureUnit &perUnit) &&;
1614 
1628  Derived adoptPerUnit(icu::MeasureUnit *perUnit) const &;
1629 
1639  Derived adoptPerUnit(icu::MeasureUnit *perUnit) &&;
1640 
1671  Derived precision(const Precision& precision) const &;
1672 
1682  Derived precision(const Precision& precision) &&;
1683 
1702  Derived roundingMode(UNumberFormatRoundingMode roundingMode) const &;
1703 
1712  Derived roundingMode(UNumberFormatRoundingMode roundingMode) &&;
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 
1842  Derived symbols(const DecimalFormatSymbols &symbols) &&;
1843 
1877  Derived adoptSymbols(NumberingSystem *symbols) const &;
1878 
1888  Derived adoptSymbols(NumberingSystem *symbols) &&;
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 
1991  Derived decimal(UNumberDecimalSeparatorDisplay style) const &;
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 
2078  Derived macros(impl::MacroProps&& macros) &&;
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
2147  friend void impl::touchRangeLocales(impl::RangeMacroProps& macros);
2148  friend class impl::NumberRangeFormatterImpl;
2149 };
2150 
2160  : public NumberFormatterSettings<UnlocalizedNumberFormatter>, public UMemory {
2161 
2162  public:
2173 
2184 
2191 
2197 
2204 
2210 
2217 
2218  private:
2220 
2221  explicit UnlocalizedNumberFormatter(
2223 
2224  // To give the fluent setters access to this class's constructor:
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
2468  UnicodeString toString(UErrorCode& status) const U_OVERRIDE;
2469 
2470  // Copydoc: this method is new in ICU 64
2472  UnicodeString toTempString(UErrorCode& status) const U_OVERRIDE;
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
2486  UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE;
2487 
2488 #ifndef U_HIDE_DRAFT_API
2489 
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
2556 template<typename StringClass>
2557 StringClass FormattedNumber::toDecimalNumber(UErrorCode& status) const {
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 
2631  NumberFormatter() = delete;
2632 };
2633 
2634 } // namespace number
2635 U_NAMESPACE_END
2636 
2637 #endif /* #if !UCONFIG_NO_FORMATTING */
2638 
2639 #endif /* U_SHOW_CPLUSPLUS_API */
2640 
2641 #endif // __NUMBERFORMATTER_H__
2642 
icu::number::NumberFormatterSettings::grouping
Derived grouping(UNumberGroupingStrategy strategy) &&
Overload of grouping() for use on an rvalue reference.
icu::number::Scale
A class that defines a quantity by which a number should be multiplied when formatting.
Definition: numberformatter.h:1007
icu::DecimalFormatSymbols
This class represents the set of symbols needed by DecimalFormat to format numbers.
Definition: dcfmtsym.h:86
icu::number::ScientificNotation::withMinExponentDigits
ScientificNotation withMinExponentDigits(int32_t minExponentDigits) const
Sets the minimum number of digits to show in the exponent of scientific notation, padding with zeros ...
UNUM_DECIMAL_SEPARATOR_COUNT
@ UNUM_DECIMAL_SEPARATOR_COUNT
One more than the highest UNumberDecimalSeparatorDisplay value.
Definition: unumberformatter.h:394
icu::number::Notation::NotationUnion::ScientificSettings::fEngineeringInterval
int8_t fEngineeringInterval
Definition: numberformatter.h:345
FALSE
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:269
icu::number::NumberFormatterSettings::scale
Derived scale(const Scale &scale) const &
Sets a scale (multiplier) to be used to scale the number by an arbitrary amount before formatting.
icu::MeasureUnit
A unit such as length, mass, volume, currency, etc.
Definition: measunit.h:237
icu::number::LocalizedNumberFormatter::getCompiled
const impl::NumberFormatterImpl * getCompiled() const
Internal method for testing.
icu::number::Precision::PrecisionUnion::FractionSignificantSettings::fMaxSig
impl::digits_t fMaxSig
Definition: numberformatter.h:689
icu::number::Notation::engineering
static ScientificNotation engineering()
Print the number using engineering notation, a variant of scientific notation in which the exponent m...
fpositer.h
C++ API: FieldPosition Iterator.
icu::number::Scale::byDoubleAndPowerOfTen
static Scale byDoubleAndPowerOfTen(double multiplicand, int32_t power)
Multiply a number by both a power of ten and by an arbitrary double value.
parseerr.h
C API: Parse Error Information.
icu::number::impl::MacroProps::perUnit
MeasureUnit perUnit
Definition: numberformatter.h:1378
icu::number::NumberFormatter::NumberFormatter
NumberFormatter()=delete
Use factory methods instead of the constructor to create a NumberFormatter.
icu::number::FractionPrecision::withMinDigits
Precision withMinDigits(int32_t minSignificantDigits) const
Ensure that no less than this number of significant digits are retained when rounding according to fr...
icu::number::NumberFormatterSettings::clone
LocalPointer< Derived > clone() const &
Returns the current (Un)LocalizedNumberFormatter as a LocalPointer wrapping a heap-allocated copy of ...
icu::number::NumberFormatterSettings::threshold
Derived threshold(int32_t threshold) const &
Internal fluent setter to support a custom regulation threshold.
unumberformatter.h
C-compatible API for localized number formatting; not recommended for C++.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::number::impl::touchRangeLocales
void touchRangeLocales(impl::RangeMacroProps &macros)
Used for NumberRangeFormatter and implemented in numrange_fluent.cpp.
icu::number::NumberFormatterSettings::toSkeleton
UnicodeString toSkeleton(UErrorCode &status) const
Creates a skeleton string representation of this number formatter.
icu::number::NumberFormatterSettings::decimal
Derived decimal(UNumberDecimalSeparatorDisplay style) const &
Sets the decimal separator display strategy.
icu::CurrencyUnit
A unit of currency, such as USD (U.S.
Definition: currunit.h:39
icu::number::IntegerWidth
A class that defines the strategy for padding and truncating integers before the decimal separator.
Definition: numberformatter.h:910
icu::number::impl::MacroProps::scale
Scale scale
Definition: numberformatter.h:1410
U_I18N_API
#define U_I18N_API
Definition: utypes.h:301
icu::number::IntegerWidth::zeroFillTo
static IntegerWidth zeroFillTo(int32_t minInt)
Pad numbers at the beginning with zeros to guarantee a certain number of numerals before the decimal ...
UNUM_UNIT_WIDTH_COUNT
@ UNUM_UNIT_WIDTH_COUNT
One more than the highest UNumberUnitWidth value.
Definition: unumberformatter.h:164
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261
icu::number::LocalizedNumberFormatter::LocalizedNumberFormatter
LocalizedNumberFormatter(const LocalizedNumberFormatter &other)
Returns a copy of this LocalizedNumberFormatter.
UNumberSignDisplay
UNumberSignDisplay
An enum declaring how to denote positive and negative numbers.
Definition: unumberformatter.h:287
U_NOEXCEPT
#define U_NOEXCEPT
Definition: platform.h:529
icu::FormattedValue
An abstract formatted value: a string with associated field attributes.
Definition: formattedvalue.h:241
icu::number::IncrementPrecision
A class that defines a rounding precision parameterized by a rounding increment to be used when forma...
Definition: numberformatter.h:874
icu::number::NumberFormatterSettings::sign
Derived sign(UNumberSignDisplay style) const &
Sets the plus/minus sign display strategy.
icu::number::NumberFormatterSettings::padding
Derived padding(const impl::Padder &padder) &&
icu::number::NumberFormatterSettings::macros
Derived macros(impl::MacroProps &&macros) const &
UNUM_SIGN_COUNT
@ UNUM_SIGN_COUNT
One more than the highest UNumberSignDisplay value.
Definition: unumberformatter.h:359
icu::number::NumberFormatterSettings::adoptPerUnit
Derived adoptPerUnit(icu::MeasureUnit *perUnit) const &
Like perUnit(), but takes ownership of a pointer.
icu::number::NumberFormatter::withLocale
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...
icu::number::impl::SymbolsWrapper::setTo
void setTo(const NumberingSystem *ns)
Adopt the provided object.
icu::number::LocalizedNumberFormatter::formatDecimal
FormattedNumber formatDecimal(StringPiece value, UErrorCode &status) const
Format the given decimal number to a string using the settings specified in the NumberFormatter fluen...
icu::number::NumberFormatterSettings::adoptUnit
Derived adoptUnit(icu::MeasureUnit *unit) const &
Like unit(), but takes ownership of a pointer.
icu::number::LocalizedNumberFormatter::LocalizedNumberFormatter
LocalizedNumberFormatter(LocalizedNumberFormatter &&src) U_NOEXCEPT
Move constructor: The source LocalizedNumberFormatter will be left in a valid but undefined state.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::number::UnlocalizedNumberFormatter::locale
LocalizedNumberFormatter locale(const icu::Locale &locale) &&
Overload of locale() for use on an rvalue reference.
U_OVERRIDE
#define U_OVERRIDE
Definition: umachine.h:129
icu::PluralRules
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:200
icu::number::impl::Grouper::forStrategy
static Grouper forStrategy(UNumberGroupingStrategy grouping)
icu::number::FormattedNumber::~FormattedNumber
virtual ~FormattedNumber() U_OVERRIDE
Destruct an instance of FormattedNumber.
icu::number::Notation::NotationUnion::ScientificSettings
Definition: numberformatter.h:343
icu::number::FormattedNumber::getAllFieldPositionsImpl
void getAllFieldPositionsImpl(FieldPositionIteratorHandler &fpih, UErrorCode &status) const
Populates the mutable builder type FieldPositionIteratorHandler.
icu::number::impl::Grouper::forProperties
static Grouper forProperties(const DecimalFormatProperties &properties)
Resolve the values in Properties to a Grouper object.
UCurrencyUsage
UCurrencyUsage
Currency Usage used for Decimal Format.
Definition: ucurr.h:41
icu::LocalPointer
"Smart pointer" class, deletes objects via the standard C++ delete operator.
Definition: localpointer.h:191
icu::number::NumberFormatterSettings::roundingMode
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...
icu::number::UnlocalizedNumberFormatter::UnlocalizedNumberFormatter
UnlocalizedNumberFormatter(const UnlocalizedNumberFormatter &other)
Returns a copy of this UnlocalizedNumberFormatter.
icu::number::NumberFormatterSettings::symbols
Derived symbols(const DecimalFormatSymbols &symbols) &&
Overload of symbols() for use on an rvalue reference.
icu::number::Scale::byDecimal
static Scale byDecimal(StringPiece multiplicand)
Multiply numbers by an arbitrary value before formatting.
icu::number::Notation::simple
static SimpleNotation simple()
Print the number using simple notation without any scaling by powers of ten.
icu::number::Scale::operator=
Scale & operator=(Scale &&src) U_NOEXCEPT
icu::number::Precision::currency
static CurrencyPrecision currency(UCurrencyUsage currencyUsage)
Show numbers rounded and padded according to the rules for the currency unit.
icu::number::Scale::operator=
Scale & operator=(const Scale &other)
icu::number::NumberFormatterSettings::adoptPerUnit
Derived adoptPerUnit(icu::MeasureUnit *perUnit) &&
Overload of adoptPerUnit() for use on an rvalue reference.
icu::number::LocalizedNumberFormatter::LocalizedNumberFormatter
LocalizedNumberFormatter()=default
Default constructor: puts the formatter into a valid but undefined state.
icu::number::NumberFormatterSettings::symbols
Derived symbols(const DecimalFormatSymbols &symbols) const &
Specifies the symbols (decimal separator, grouping separator, percent sign, numerals,...
icu::number::IncrementPrecision::withMinFraction
Precision withMinFraction(int32_t minFrac) const
Specifies the minimum number of fraction digits to render after the decimal separator,...
icu::number::Precision::maxFraction
static FractionPrecision maxFraction(int32_t maxFractionPlaces)
Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal ...
icu::number::impl::SymbolsWrapper::isNumberingSystem
bool isNumberingSystem() const
Whether the object is currently holding a NumberingSystem.
icu::number::NumberFormatterSettings::unit
Derived unit(const icu::MeasureUnit &unit) &&
Overload of unit() for use on an rvalue reference.
U_MEMORY_ALLOCATION_ERROR
@ U_MEMORY_ALLOCATION_ERROR
Memory allocation error.
Definition: utypes.h:457
icu::number::LocalizedNumberFormatter::formatDecimalQuantity
FormattedNumber formatDecimalQuantity(const impl::DecimalQuantity &dq, UErrorCode &status) const
Internal method.
icu::number::impl::RangeMacroProps
Definition: numberrangeformatter.h:210
UParseError
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
icu::number::NumberFormatterSettings::unit
Derived unit(const icu::MeasureUnit &unit) const &
Specifies the unit (unit of measure, currency, or percent) to associate with rendered numbers.
icu::number::Precision::minSignificantDigits
static SignificantDigitsPrecision minSignificantDigits(int32_t minSignificantDigits)
Always show at least a certain number of significant digits/figures, padding with zeros if necessary.
icu::Format
Base class for all formats.
Definition: format.h:98
icu::number::impl::Padder::none
static Padder none()
icu::number::Notation::compactShort
static CompactNotation compactShort()
Print the number using short-form compact notation.
icu::number::impl::SymbolsWrapper::SymbolsWrapper
SymbolsWrapper(SymbolsWrapper &&src) U_NOEXCEPT
fieldpos.h
C++ API: FieldPosition identifies the fields in a formatted output.
unum.h
C API: Compatibility APIs for number formatting.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
icu::number::Precision::minMaxFraction
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 ...
icu::number::impl::MacroProps::grouper
Grouper grouper
Definition: numberformatter.h:1387
icu::number::impl::SymbolsWrapper::SymbolsWrapper
SymbolsWrapper(const SymbolsWrapper &other)
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:425
icu::number::NumberFormatter::forSkeleton
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 ...
icu::number::Notation::NotationUnion::ScientificSettings::fMinExponentDigits
impl::digits_t fMinExponentDigits
Definition: numberformatter.h:349
U_FAILURE
#define U_FAILURE(x)
Does the error code indicate a failure?
Definition: utypes.h:709
icu::number::NumberFormatterSettings::grouping
Derived grouping(UNumberGroupingStrategy strategy) const &
Specifies the grouping strategy to use when formatting numbers.
icu::number::Precision::fixedSignificantDigits
static SignificantDigitsPrecision fixedSignificantDigits(int32_t minMaxSignificantDigits)
Show numbers rounded if necessary to a certain number of significant digits or significant figures.
icu::number::NumberFormatterSettings::integerWidth
Derived integerWidth(const IntegerWidth &style) &&
Overload of integerWidth() for use on an rvalue reference.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
icu::number::impl::MacroProps::precision
Precision precision
Definition: numberformatter.h:1381
icu::number::NumberFormatterSettings::macros
Derived macros(const impl::MacroProps &macros) const &
Internal fluent setter to overwrite the entire macros object.
icu::number::NumberFormatter::with
static UnlocalizedNumberFormatter with()
Call this method at the beginning of a NumberFormatter fluent chain in which the locale is not curren...
icu::number::Precision::PrecisionUnion::IncrementSettings::fMaxFrac
impl::digits_t fMaxFrac
Definition: numberformatter.h:699
icu::number::LocalizedNumberFormatter::formatImpl
void formatImpl(impl::UFormattedNumberData *results, UErrorCode &status) const
This is the core entrypoint to the number formatting pipeline.
icu::number::LocalizedNumberFormatter::operator=
LocalizedNumberFormatter & operator=(LocalizedNumberFormatter &&src) U_NOEXCEPT
Move assignment operator: The source LocalizedNumberFormatter will be left in a valid but undefined s...
icu::number::impl::SymbolsWrapper::operator=
SymbolsWrapper & operator=(SymbolsWrapper &&src) U_NOEXCEPT
icu::number::Precision::minFraction
static FractionPrecision minFraction(int32_t minFractionPlaces)
Always show at least a certain number of fraction places after the decimal separator,...
TRUE
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:265
icu::number::FormattedNumber
The result of a number formatting operation.
Definition: numberformatter.h:2426
icu::number::Notation::NotationUnion::ScientificSettings::fExponentSignDisplay
UNumberSignDisplay fExponentSignDisplay
Definition: numberformatter.h:351
icu::number::Precision::maxSignificantDigits
static SignificantDigitsPrecision maxSignificantDigits(int32_t maxSignificantDigits)
Show numbers rounded if necessary to a certain number of significant digits/figures.
icu::number::NumberFormatterSettings::decimal
Derived decimal(UNumberDecimalSeparatorDisplay style) &&
Overload of decimal() for use on an rvalue reference.
icu::number::UnlocalizedNumberFormatter
A NumberFormatter that does not yet have a locale.
Definition: numberformatter.h:2160
icu::number::impl::Grouper
Definition: numberformatter.h:1222
icu::ByteSink
A ByteSink can be filled with bytes.
Definition: bytestream.h:53
icu::number::NumberFormatterSettings
An abstract base class for specifying settings related to number formatting.
Definition: numberformatter.h:1455
icu::number::impl::MacroProps::integerWidth
IntegerWidth integerWidth
Definition: numberformatter.h:1393
icu::number::Precision
A class that defines the rounding precision to be used when formatting numbers in NumberFormatter.
Definition: numberformatter.h:461
icu::number::impl::MacroProps::padder
Padder padder
Definition: numberformatter.h:1390
icu::number::FormattedNumber::FormattedNumber
FormattedNumber(FormattedNumber &&src) U_NOEXCEPT
Move constructor: Leaves the source FormattedNumber in an undefined state.
icu::UMemory
UMemory is the common ICU base class.
Definition: uobject.h:115
icu::number::LocalizedNumberFormatter::formatDouble
FormattedNumber formatDouble(double value, UErrorCode &status) const
Format the given float or double to a string using the settings specified in the NumberFormatter flue...
icu::number::LocalizedNumberFormatter::toFormat
Format * toFormat(UErrorCode &status) const
Creates a representation of this LocalizedNumberFormat as an icu::Format, enabling the use of this nu...
icu::number::NumberFormatterSettings::perUnit
Derived perUnit(const icu::MeasureUnit &perUnit) &&
Overload of perUnit() for use on an rvalue reference.
icu::number::LocalizedNumberFormatter::getAffixImpl
void getAffixImpl(bool isPrefix, bool isNegative, UnicodeString &result, UErrorCode &status) const
Internal method for DecimalFormat compatibility.
icu::number::UnlocalizedNumberFormatter::operator=
UnlocalizedNumberFormatter & operator=(const UnlocalizedNumberFormatter &other)
Copy assignment operator.
icu::number::NumberFormatterSettings::scale
Derived scale(const Scale &scale) &&
Overload of scale() for use on an rvalue reference.
icu::number::impl::MacroProps::locale
Locale locale
Definition: numberformatter.h:1422
icu::number::UnlocalizedNumberFormatter::UnlocalizedNumberFormatter
UnlocalizedNumberFormatter()=default
Default constructor: puts the formatter into a valid but undefined state.
icu::number::Scale::powerOfTen
static Scale powerOfTen(int32_t power)
Multiply numbers by a power of ten before formatting.
icu::number::impl::MacroProps::notation
Notation notation
Definition: numberformatter.h:1372
icu::number::NumberFormatterSettings::roundingMode
Derived roundingMode(UNumberFormatRoundingMode roundingMode) &&
Overload of roundingMode() for use on an rvalue reference.
icu::number::impl::SymbolsWrapper::isDecimalFormatSymbols
bool isDecimalFormatSymbols() const
Whether the object is currently holding a DecimalFormatSymbols.
dcfmtsym.h
C++ API: Symbols for formatting numbers.
icu::number::impl::Padder::codePoints
static Padder codePoints(UChar32 cp, int32_t targetWidth, UNumberFormatPadPosition position)
icu::number::ScientificNotation::withExponentSignDisplay
ScientificNotation withExponentSignDisplay(UNumberSignDisplay exponentSignDisplay) const
Sets whether to show the sign on positive and negative exponents in scientific notation.
icu::number::Precision::PrecisionUnion::FractionSignificantSettings::fMaxFrac
impl::digits_t fMaxFrac
Definition: numberformatter.h:685
icu::number::Precision::PrecisionUnion::IncrementSettings::fMinFrac
impl::digits_t fMinFrac
Definition: numberformatter.h:697
icu::number::impl::MacroProps::symbols
SymbolsWrapper symbols
Definition: numberformatter.h:1396
U_ZERO_ERROR
@ U_ZERO_ERROR
No error, no warning.
Definition: utypes.h:449
icu::number::Scale::~Scale
~Scale()
appendable.h
C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (char16_ts).
icu::number::impl::Grouper::getPrimary
int16_t getPrimary() const
UNumberUnitWidth
UNumberUnitWidth
An enum declaring how to render units, including currencies.
Definition: unumberformatter.h:98
UNumberDecimalSeparatorDisplay
UNumberDecimalSeparatorDisplay
An enum declaring how to render the decimal separator.
Definition: unumberformatter.h:373
icu::number::impl::SymbolsWrapper::setTo
void setTo(const DecimalFormatSymbols &dfs)
The provided object is copied, but we do not adopt it.
icu::number::impl::Grouper::getSecondary
int16_t getSecondary() const
icu::number::impl::Padder::forProperties
static Padder forProperties(const DecimalFormatProperties &properties)
formattedvalue.h
C++ API: Abstract operations for localized strings.
icu::number::LocalizedNumberFormatter::getCallCount
int32_t getCallCount() const
Internal method for testing.
icu::number::FractionPrecision
A class that defines a rounding precision based on a number of fraction places and optionally signifi...
Definition: numberformatter.h:780
icu::number::NumberFormatterSettings::adoptSymbols
Derived adoptSymbols(NumberingSystem *symbols) const &
Specifies that the given numbering system should be used when fetching symbols.
icu::number::NumberFormatterSettings::macros
Derived macros(const impl::MacroProps &macros) &&
ucurr.h
C API: Encapsulates information about a currency.
icu::number::CurrencyPrecision
A class that defines a rounding precision parameterized by a currency to be used when formatting numb...
Definition: numberformatter.h:836
UNUM_ROUND_HALFEVEN
@ UNUM_ROUND_HALFEVEN
Half-even rounding.
Definition: unum.h:288
icu::Appendable
Base class for objects to which Unicode characters and strings can be appended.
Definition: appendable.h:54
icu::number::Notation::NotationUnion::ScientificSettings::fRequireMinInt
bool fRequireMinInt
Definition: numberformatter.h:347
icu::number::Precision::PrecisionUnion::FractionSignificantSettings::fMinSig
impl::digits_t fMinSig
Definition: numberformatter.h:687
icu::number::Scale::byDouble
static Scale byDouble(double multiplicand)
Multiply numbers by an arbitrary value before formatting.
icu::number::NumberFormatterSettings::padding
Derived padding(const impl::Padder &padder) const &
Set the padding strategy.
icu::number::impl::SymbolsWrapper::operator=
SymbolsWrapper & operator=(const SymbolsWrapper &other)
icu::number::impl::Grouper::Grouper
Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping, UNumberGroupingStrategy strategy)
Definition: numberformatter.h:1237
icu::NumberingSystem
Defines numbering systems.
Definition: numsys.h:60
icu::number::NumberFormatterSettings::precision
Derived precision(const Precision &precision) &&
Overload of precision() for use on an rvalue reference.
icu::number::impl::SymbolsWrapper::copyErrorTo
UBool copyErrorTo(UErrorCode &status) const
Definition: numberformatter.h:1192
icu::number::NumberFormatterSettings::adoptUnit
Derived adoptUnit(icu::MeasureUnit *unit) &&
Overload of adoptUnit() for use on an rvalue reference.
icu::number::UnlocalizedNumberFormatter::UnlocalizedNumberFormatter
UnlocalizedNumberFormatter(UnlocalizedNumberFormatter &&src) U_NOEXCEPT
Move constructor: The source UnlocalizedNumberFormatter will be left in a valid but undefined state.
icu::number::Notation::scientific
static ScientificNotation scientific()
Print the number using scientific notation (also known as scientific form, standard index form,...
icu::number::Scale::none
static Scale none()
Do not change the value of numbers when formatting or parsing.
icu::number::Notation
A class that defines the notation style to be used when formatting numbers in NumberFormatter.
Definition: numberformatter.h:190
icu::number::impl::digits_t
int16_t digits_t
Datatype for minimum/maximum fraction digits.
Definition: numberformatter.h:124
icu::number::ScientificNotation
A class that defines the scientific notation style to be used when formatting numbers in NumberFormat...
Definition: numberformatter.h:400
UNumberFormatRoundingMode
UNumberFormatRoundingMode
The possible number format rounding modes.
Definition: unum.h:279
icu::number::Notation::compactLong
static CompactNotation compactLong()
Print the number using long-form compact notation.
icu::number::UnlocalizedNumberFormatter::operator=
UnlocalizedNumberFormatter & operator=(UnlocalizedNumberFormatter &&src) U_NOEXCEPT
Move assignment operator: The source UnlocalizedNumberFormatter will be left in a valid but undefined...
icu::number::NumberFormatterSettings::threshold
Derived threshold(int32_t threshold) &&
icu::StringByteSink
Implementation of ByteSink that writes to a "string".
Definition: bytestream.h:269
icu::number::Precision::PrecisionUnion::FractionSignificantSettings
Definition: numberformatter.h:680
icu::number::LocalizedNumberFormatter::formatInt
FormattedNumber formatInt(int64_t value, UErrorCode &status) const
Format the given integer number to a string using the settings specified in the NumberFormatter fluen...
icu::number::impl::Padder
Definition: numberformatter.h:1304
icu::number::impl::SymbolsWrapper::SymbolsWrapper
SymbolsWrapper()
Definition: numberformatter.h:1134
icu::number::Precision::PrecisionUnion::FractionSignificantSettings::fMinFrac
impl::digits_t fMinFrac
Definition: numberformatter.h:683
icu::number::CurrencyPrecision::withCurrency
Precision withCurrency(const CurrencyUnit &currency) const
Associates a currency with this rounding precision.
icu::number::Precision::unlimited
static Precision unlimited()
Show all available digits to full precision.
icu::number::NumberFormatterSettings::integerWidth
Derived integerWidth(const IntegerWidth &style) const &
Specifies the minimum and maximum number of digits to render before the decimal mark.
icu::number::Precision::integer
static FractionPrecision integer()
Show numbers rounded if necessary to the nearest integer.
icu::number::UnlocalizedNumberFormatter::locale
LocalizedNumberFormatter locale(const icu::Locale &locale) const &
Associate the given locale with the number formatter.
icu::number::FractionPrecision::withMaxDigits
Precision withMaxDigits(int32_t maxSignificantDigits) const
Ensure that no more than this number of significant digits are retained when rounding according to fr...
icu::number::Precision::minMaxSignificantDigits
static SignificantDigitsPrecision minMaxSignificantDigits(int32_t minSignificantDigits, int32_t maxSignificantDigits)
Show numbers rounded if necessary to a certain number of significant digits/figures; in addition,...
icu::number::impl::SymbolsWrapper::~SymbolsWrapper
~SymbolsWrapper()
uobject.h
C++ API: Common ICU base class UObject.
icu::number::NumberFormatterSettings::precision
Derived precision(const Precision &precision) const &
Specifies the rounding precision to use when formatting numbers.
icu::number::LocalizedNumberFormatter::~LocalizedNumberFormatter
~LocalizedNumberFormatter()
Destruct this LocalizedNumberFormatter, cleaning up any memory it might own.
nounit.h
C++ API: units for percent and permille.
plurrule.h
C++ API: PluralRules object.
icu::number::NumberFormatter
See the main description in numberformatter.h for documentation and examples.
Definition: numberformatter.h:2570
U_INVALID_STATE_ERROR
@ U_INVALID_STATE_ERROR
Requested operation can not be completed with ICU in its current state.
Definition: utypes.h:478
icu::number::Precision::PrecisionUnion::IncrementSettings
Definition: numberformatter.h:692
icu::number::impl::SymbolsWrapper::getDecimalFormatSymbols
const DecimalFormatSymbols * getDecimalFormatSymbols() const
Get the DecimalFormatSymbols pointer.
icu::number::NumberFormatterSettings::macros
Derived macros(impl::MacroProps &&macros) &&
UNumberGroupingStrategy
UNumberGroupingStrategy
An enum declaring the strategy for when and how to display grouping separators (i....
Definition: unumberformatter.h:193
icu::number::FormattedNumber::FormattedNumber
FormattedNumber()
Default constructor; makes an empty FormattedNumber.
Definition: numberformatter.h:2433
icu::number::NumberFormatterSettings::notation
Derived notation(const Notation &notation) const &
Specifies the notation style (simple, scientific, or compact) for rendering numbers.
icu::number::impl::SymbolsWrapper
Definition: numberformatter.h:1131
measunit.h
C++ API: A unit for measuring a quantity.
UNumberFormatPadPosition
UNumberFormatPadPosition
The possible number format pad positions.
Definition: unum.h:308
icu::number::Precision::PrecisionUnion::IncrementSettings::fIncrement
double fIncrement
Definition: numberformatter.h:695
icu::StringPiece
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:60
icu::number::NumberFormatterSettings::unitWidth
Derived unitWidth(UNumberUnitWidth width) const &
Sets the width of the unit (measure unit or currency).
bytestream.h
C++ API: Interface for writing bytes, and implementation classes.
currunit.h
C++ API: Currency Unit Information.
icu::number::Scale::Scale
Scale(int32_t magnitude, impl::DecNum *arbitraryToAdopt)
icu::number::IntegerWidth::truncateAt
IntegerWidth truncateAt(int32_t maxInt)
Truncate numbers exceeding a certain number of numerals before the decimal separator.
icu::number::NumberFormatter::forSkeleton
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 ...
icu::number::NumberFormatterSettings::adoptSymbols
Derived adoptSymbols(NumberingSystem *symbols) &&
Overload of adoptSymbols() for use on an rvalue reference.
icu::number::Precision::fixedFraction
static FractionPrecision fixedFraction(int32_t minMaxFractionPlaces)
Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal ...
icu::number::LocalizedNumberFormatter::operator=
LocalizedNumberFormatter & operator=(const LocalizedNumberFormatter &other)
Copy assignment operator.
icu::number::Scale::Scale
Scale(const Scale &other)
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
icu::number::NumberFormatterSettings::unitWidth
Derived unitWidth(UNumberUnitWidth width) &&
Overload of unitWidth() for use on an rvalue reference.
icu::number::NumberFormatterSettings::notation
Derived notation(const Notation &notation) &&
Overload of notation() for use on an rvalue reference.
icu::number::impl::SymbolsWrapper::getNumberingSystem
const NumberingSystem * getNumberingSystem() const
Get the NumberingSystem pointer.
icu::number::NumberFormatterSettings::sign
Derived sign(UNumberSignDisplay style) &&
Overload of sign() for use on an rvalue reference.
icu::number::FormattedNumber::getDecimalQuantity
void getDecimalQuantity(impl::DecimalQuantity &output, UErrorCode &status) const
Gets the raw DecimalQuantity for plural rule selection.
icu::number::LocalizedNumberFormatter
A NumberFormatter that has a locale associated with it; this means .format() methods are available.
Definition: numberformatter.h:2240
icu::number::impl::MacroProps
Definition: numberformatter.h:1370
icu::number::Precision::increment
static IncrementPrecision increment(double roundingIncrement)
Show numbers rounded if necessary to the closest multiple of a certain rounding increment.
icu::number::NumberFormatterSettings::perUnit
Derived perUnit(const icu::MeasureUnit &perUnit) const &
Sets a unit to be used in the denominator.
icu::number::Scale::Scale
Scale(Scale &&src) U_NOEXCEPT
icu::number::impl::MacroProps::copyErrorTo
bool copyErrorTo(UErrorCode &status) const
Check all members for errors.
Definition: numberformatter.h:1430
icu::ConstrainedFieldPosition
Represents a span of a string containing a given field.
Definition: formattedvalue.h:41
UNumberCompactStyle
UNumberCompactStyle
Constants for specifying short or long format.
Definition: unum.h:319
icu::number::impl::MacroProps::unit
MeasureUnit unit
Definition: numberformatter.h:1375