ICU 65.1  65.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 
166 
167 } // namespace impl
168 
175 
182 
188 class U_I18N_API Notation : public UMemory {
189  public:
215 
239 
282 
306 
332 
333  private:
334  enum NotationType {
335  NTN_SCIENTIFIC, NTN_COMPACT, NTN_SIMPLE, NTN_ERROR
336  } fType;
337 
338  union NotationUnion {
339  // For NTN_SCIENTIFIC
350  } scientific;
351 
352  // For NTN_COMPACT
353  UNumberCompactStyle compactStyle;
354 
355  // For NTN_ERROR
356  UErrorCode errorCode;
357  } fUnion;
358 
360 
361  Notation(const NotationType &type, const NotationUnion &union_) : fType(type), fUnion(union_) {}
362 
363  Notation(UErrorCode errorCode) : fType(NTN_ERROR) {
364  fUnion.errorCode = errorCode;
365  }
366 
367  Notation() : fType(NTN_SIMPLE), fUnion() {}
368 
369  UBool copyErrorTo(UErrorCode &status) const {
370  if (fType == NTN_ERROR) {
371  status = fUnion.errorCode;
372  return TRUE;
373  }
374  return FALSE;
375  }
376 
377  // To allow MacroProps to initialize empty instances:
378  friend struct impl::MacroProps;
379  friend class ScientificNotation;
380 
381  // To allow implementation to access internal types:
382  friend class impl::NumberFormatterImpl;
383  friend class impl::ScientificModifier;
384  friend class impl::ScientificHandler;
385 
386  // To allow access to the skeleton generation code:
387  friend class impl::GeneratorHelpers;
388 };
389 
399  public:
413  ScientificNotation withMinExponentDigits(int32_t minExponentDigits) const;
414 
429 
430  private:
431  // Inherit constructor
432  using Notation::Notation;
433 
434  // Raw constructor for NumberPropertyMapper
435  ScientificNotation(int8_t fEngineeringInterval, bool fRequireMinInt, impl::digits_t fMinExponentDigits,
436  UNumberSignDisplay fExponentSignDisplay);
437 
438  friend class Notation;
439 
440  // So that NumberPropertyMapper can create instances
441  friend class impl::NumberPropertyMapper;
442 };
443 
450 
459 class U_I18N_API Precision : public UMemory {
460 
461  public:
480 
488 
516  static FractionPrecision fixedFraction(int32_t minMaxFractionPlaces);
517 
531  static FractionPrecision minFraction(int32_t minFractionPlaces);
532 
543  static FractionPrecision maxFraction(int32_t maxFractionPlaces);
544 
558  static FractionPrecision minMaxFraction(int32_t minFractionPlaces, int32_t maxFractionPlaces);
559 
573  static SignificantDigitsPrecision fixedSignificantDigits(int32_t minMaxSignificantDigits);
574 
587  static SignificantDigitsPrecision minSignificantDigits(int32_t minSignificantDigits);
588 
597  static SignificantDigitsPrecision maxSignificantDigits(int32_t maxSignificantDigits);
598 
610  static SignificantDigitsPrecision minMaxSignificantDigits(int32_t minSignificantDigits,
611  int32_t maxSignificantDigits);
612 
632  static IncrementPrecision increment(double roundingIncrement);
633 
652 
653  private:
654  enum PrecisionType {
655  RND_BOGUS,
656  RND_NONE,
657  RND_FRACTION,
658  RND_SIGNIFICANT,
659  RND_FRACTION_SIGNIFICANT,
660 
661  // Used for strange increments like 3.14.
662  RND_INCREMENT,
663 
664  // Used for increments with 1 as the only digit. This is different than fraction
665  // rounding because it supports having additional trailing zeros. For example, this
666  // class is used to round with the increment 0.010.
667  RND_INCREMENT_ONE,
668 
669  // Used for increments with 5 as the only digit (nickel rounding).
670  RND_INCREMENT_FIVE,
671 
672  RND_CURRENCY,
673  RND_ERROR
674  } fType;
675 
676  union PrecisionUnion {
679  // For RND_FRACTION, RND_SIGNIFICANT, and RND_FRACTION_SIGNIFICANT
688  } fracSig;
691  // For RND_INCREMENT, RND_INCREMENT_ONE, and RND_INCREMENT_FIVE
693  double fIncrement;
698  } increment;
699  UCurrencyUsage currencyUsage; // For RND_CURRENCY
700  UErrorCode errorCode; // For RND_ERROR
701  } fUnion;
702 
705 
707  UNumberFormatRoundingMode fRoundingMode;
708 
709  Precision(const PrecisionType& type, const PrecisionUnion& union_,
710  UNumberFormatRoundingMode roundingMode)
711  : fType(type), fUnion(union_), fRoundingMode(roundingMode) {}
712 
713  Precision(UErrorCode errorCode) : fType(RND_ERROR) {
714  fUnion.errorCode = errorCode;
715  }
716 
717  Precision() : fType(RND_BOGUS) {}
718 
719  bool isBogus() const {
720  return fType == RND_BOGUS;
721  }
722 
723  UBool copyErrorTo(UErrorCode &status) const {
724  if (fType == RND_ERROR) {
725  status = fUnion.errorCode;
726  return TRUE;
727  }
728  return FALSE;
729  }
730 
731  // On the parent type so that this method can be called internally on Precision instances.
732  Precision withCurrency(const CurrencyUnit &currency, UErrorCode &status) const;
733 
734  static FractionPrecision constructFraction(int32_t minFrac, int32_t maxFrac);
735 
736  static Precision constructSignificant(int32_t minSig, int32_t maxSig);
737 
738  static Precision
739  constructFractionSignificant(const FractionPrecision &base, int32_t minSig, int32_t maxSig);
740 
741  static IncrementPrecision constructIncrement(double increment, int32_t minFrac);
742 
743  static CurrencyPrecision constructCurrency(UCurrencyUsage usage);
744 
745  static Precision constructPassThrough();
746 
747  // To allow MacroProps/MicroProps to initialize bogus instances:
748  friend struct impl::MacroProps;
749  friend struct impl::MicroProps;
750 
751  // To allow NumberFormatterImpl to access isBogus() and other internal methods:
752  friend class impl::NumberFormatterImpl;
753 
754  // To allow NumberPropertyMapper to create instances from DecimalFormatProperties:
755  friend class impl::NumberPropertyMapper;
756 
757  // To allow access to the main implementation class:
758  friend class impl::RoundingImpl;
759 
760  // To allow child classes to call private methods:
761  friend class FractionPrecision;
762  friend class CurrencyPrecision;
763  friend class IncrementPrecision;
764 
765  // To allow access to the skeleton generation code:
766  friend class impl::GeneratorHelpers;
767 };
768 
779  public:
796  Precision withMinDigits(int32_t minSignificantDigits) const;
797 
815  Precision withMaxDigits(int32_t maxSignificantDigits) const;
816 
817  private:
818  // Inherit constructor
819  using Precision::Precision;
820 
821  // To allow parent class to call this class's constructor:
822  friend class Precision;
823 };
824 
835  public:
853  Precision withCurrency(const CurrencyUnit &currency) const;
854 
855  private:
856  // Inherit constructor
857  using Precision::Precision;
858 
859  // To allow parent class to call this class's constructor:
860  friend class Precision;
861 };
862 
873  public:
889  Precision withMinFraction(int32_t minFrac) const;
890 
891  private:
892  // Inherit constructor
893  using Precision::Precision;
894 
895  // To allow parent class to call this class's constructor:
896  friend class Precision;
897 };
898 
909  public:
921  static IntegerWidth zeroFillTo(int32_t minInt);
922 
934  IntegerWidth truncateAt(int32_t maxInt);
935 
936  private:
937  union {
938  struct {
939  impl::digits_t fMinInt;
940  impl::digits_t fMaxInt;
941  bool fFormatFailIfMoreThanMaxDigits;
942  } minMaxInt;
943  UErrorCode errorCode;
944  } fUnion;
945  bool fHasError = false;
946 
947  IntegerWidth(impl::digits_t minInt, impl::digits_t maxInt, bool formatFailIfMoreThanMaxDigits);
948 
949  IntegerWidth(UErrorCode errorCode) { // NOLINT
950  fUnion.errorCode = errorCode;
951  fHasError = true;
952  }
953 
954  IntegerWidth() { // NOLINT
955  fUnion.minMaxInt.fMinInt = -1;
956  }
957 
959  static IntegerWidth standard() {
960  return IntegerWidth::zeroFillTo(1);
961  }
962 
963  bool isBogus() const {
964  return !fHasError && fUnion.minMaxInt.fMinInt == -1;
965  }
966 
967  UBool copyErrorTo(UErrorCode &status) const {
968  if (fHasError) {
969  status = fUnion.errorCode;
970  return TRUE;
971  }
972  return FALSE;
973  }
974 
975  void apply(impl::DecimalQuantity &quantity, UErrorCode &status) const;
976 
977  bool operator==(const IntegerWidth& other) const;
978 
979  // To allow MacroProps/MicroProps to initialize empty instances:
980  friend struct impl::MacroProps;
981  friend struct impl::MicroProps;
982 
983  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
984  friend class impl::NumberFormatterImpl;
985 
986  // So that NumberPropertyMapper can create instances
987  friend class impl::NumberPropertyMapper;
988 
989  // To allow access to the skeleton generation code:
990  friend class impl::GeneratorHelpers;
991 };
992 
1001 class U_I18N_API Scale : public UMemory {
1002  public:
1009  static Scale none();
1010 
1021  static Scale powerOfTen(int32_t power);
1022 
1035  static Scale byDecimal(StringPiece multiplicand);
1036 
1045  static Scale byDouble(double multiplicand);
1046 
1053  static Scale byDoubleAndPowerOfTen(double multiplicand, int32_t power);
1054 
1055  // We need a custom destructor for the DecNum, which means we need to declare
1056  // the copy/move constructor/assignment quartet.
1057 
1059  Scale(const Scale& other);
1060 
1062  Scale& operator=(const Scale& other);
1063 
1066 
1069 
1072 
1073 #ifndef U_HIDE_INTERNAL_API
1075  Scale(int32_t magnitude, impl::DecNum* arbitraryToAdopt);
1076 #endif /* U_HIDE_INTERNAL_API */
1077 
1078  private:
1079  int32_t fMagnitude;
1080  impl::DecNum* fArbitrary;
1081  UErrorCode fError;
1082 
1083  Scale(UErrorCode error) : fMagnitude(0), fArbitrary(nullptr), fError(error) {}
1084 
1085  Scale() : fMagnitude(0), fArbitrary(nullptr), fError(U_ZERO_ERROR) {}
1086 
1087  bool isValid() const {
1088  return fMagnitude != 0 || fArbitrary != nullptr;
1089  }
1090 
1091  UBool copyErrorTo(UErrorCode &status) const {
1092  if (fError != U_ZERO_ERROR) {
1093  status = fError;
1094  return TRUE;
1095  }
1096  return FALSE;
1097  }
1098 
1099  void applyTo(impl::DecimalQuantity& quantity) const;
1100 
1101  void applyReciprocalTo(impl::DecimalQuantity& quantity) const;
1102 
1103  // To allow MacroProps/MicroProps to initialize empty instances:
1104  friend struct impl::MacroProps;
1105  friend struct impl::MicroProps;
1106 
1107  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1108  friend class impl::NumberFormatterImpl;
1109 
1110  // To allow the helper class MultiplierFormatHandler access to private fields:
1111  friend class impl::MultiplierFormatHandler;
1112 
1113  // To allow access to the skeleton generation code:
1114  friend class impl::GeneratorHelpers;
1115 
1116  // To allow access to parsing code:
1117  friend class ::icu::numparse::impl::NumberParserImpl;
1118  friend class ::icu::numparse::impl::MultiplierParseHandler;
1119 };
1120 
1121 namespace impl {
1122 
1123 // Do not enclose entire SymbolsWrapper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1126  public:
1128  SymbolsWrapper() : fType(SYMPTR_NONE), fPtr{nullptr} {}
1129 
1132 
1135 
1138 
1141 
1144 
1145 #ifndef U_HIDE_INTERNAL_API
1146 
1151  void setTo(const DecimalFormatSymbols &dfs);
1152 
1157  void setTo(const NumberingSystem *ns);
1158 
1164 
1169  bool isNumberingSystem() const;
1170 
1176 
1182 
1183 #endif // U_HIDE_INTERNAL_API
1184 
1186  UBool copyErrorTo(UErrorCode &status) const {
1187  if (fType == SYMPTR_DFS && fPtr.dfs == nullptr) {
1188  status = U_MEMORY_ALLOCATION_ERROR;
1189  return TRUE;
1190  } else if (fType == SYMPTR_NS && fPtr.ns == nullptr) {
1191  status = U_MEMORY_ALLOCATION_ERROR;
1192  return TRUE;
1193  }
1194  return FALSE;
1195  }
1196 
1197  private:
1198  enum SymbolsPointerType {
1199  SYMPTR_NONE, SYMPTR_DFS, SYMPTR_NS
1200  } fType;
1201 
1202  union {
1203  const DecimalFormatSymbols *dfs;
1204  const NumberingSystem *ns;
1205  } fPtr;
1206 
1207  void doCopyFrom(const SymbolsWrapper &other);
1208 
1209  void doMoveFrom(SymbolsWrapper&& src);
1210 
1211  void doCleanup();
1212 };
1213 
1214 // Do not enclose entire Grouper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1216 class U_I18N_API Grouper : public UMemory {
1217  public:
1218 #ifndef U_HIDE_INTERNAL_API
1221 
1226  static Grouper forProperties(const DecimalFormatProperties& properties);
1227 
1228  // Future: static Grouper forProperties(DecimalFormatProperties& properties);
1229 
1231  Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping, UNumberGroupingStrategy strategy)
1232  : fGrouping1(grouping1),
1233  fGrouping2(grouping2),
1234  fMinGrouping(minGrouping),
1235  fStrategy(strategy) {}
1236 #endif // U_HIDE_INTERNAL_API
1237 
1239  int16_t getPrimary() const;
1240 
1242  int16_t getSecondary() const;
1243 
1244  private:
1253  int16_t fGrouping1;
1254  int16_t fGrouping2;
1255 
1263  int16_t fMinGrouping;
1264 
1269  UNumberGroupingStrategy fStrategy;
1270 
1271  Grouper() : fGrouping1(-3) {}
1272 
1273  bool isBogus() const {
1274  return fGrouping1 == -3;
1275  }
1276 
1278  void setLocaleData(const impl::ParsedPatternInfo &patternInfo, const Locale& locale);
1279 
1280  bool groupAtPosition(int32_t position, const impl::DecimalQuantity &value) const;
1281 
1282  // To allow MacroProps/MicroProps to initialize empty instances:
1283  friend struct MacroProps;
1284  friend struct MicroProps;
1285 
1286  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1287  friend class NumberFormatterImpl;
1288 
1289  // To allow NumberParserImpl to perform setLocaleData():
1290  friend class ::icu::numparse::impl::NumberParserImpl;
1291 
1292  // To allow access to the skeleton generation code:
1293  friend class impl::GeneratorHelpers;
1294 };
1295 
1296 // Do not enclose entire Padder with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1298 class U_I18N_API Padder : public UMemory {
1299  public:
1300 #ifndef U_HIDE_INTERNAL_API
1302  static Padder none();
1303 
1305  static Padder codePoints(UChar32 cp, int32_t targetWidth, UNumberFormatPadPosition position);
1306 #endif // U_HIDE_INTERNAL_API
1307 
1309  static Padder forProperties(const DecimalFormatProperties& properties);
1310 
1311  private:
1312  UChar32 fWidth; // -3 = error; -2 = bogus; -1 = no padding
1313  union {
1314  struct {
1315  int32_t fCp;
1316  UNumberFormatPadPosition fPosition;
1317  } padding;
1318  UErrorCode errorCode;
1319  } fUnion;
1320 
1321  Padder(UChar32 cp, int32_t width, UNumberFormatPadPosition position);
1322 
1323  Padder(int32_t width);
1324 
1325  Padder(UErrorCode errorCode) : fWidth(-3) { // NOLINT
1326  fUnion.errorCode = errorCode;
1327  }
1328 
1329  Padder() : fWidth(-2) {} // NOLINT
1330 
1331  bool isBogus() const {
1332  return fWidth == -2;
1333  }
1334 
1335  UBool copyErrorTo(UErrorCode &status) const {
1336  if (fWidth == -3) {
1337  status = fUnion.errorCode;
1338  return TRUE;
1339  }
1340  return FALSE;
1341  }
1342 
1343  bool isValid() const {
1344  return fWidth > 0;
1345  }
1346 
1347  int32_t padAndApply(const impl::Modifier &mod1, const impl::Modifier &mod2,
1348  FormattedStringBuilder &string, int32_t leftIndex, int32_t rightIndex,
1349  UErrorCode &status) const;
1350 
1351  // To allow MacroProps/MicroProps to initialize empty instances:
1352  friend struct MacroProps;
1353  friend struct MicroProps;
1354 
1355  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1356  friend class impl::NumberFormatterImpl;
1357 
1358  // To allow access to the skeleton generation code:
1359  friend class impl::GeneratorHelpers;
1360 };
1361 
1362 // Do not enclose entire MacroProps with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1364 struct U_I18N_API MacroProps : public UMemory {
1367 
1369  MeasureUnit unit; // = NoUnit::base();
1370 
1372  MeasureUnit perUnit; // = NoUnit::base();
1373 
1375  Precision precision; // = Precision(); (bogus)
1376 
1379 
1381  Grouper grouper; // = Grouper(); (bogus)
1382 
1384  Padder padder; // = Padder(); (bogus)
1385 
1387  IntegerWidth integerWidth; // = IntegerWidth(); (bogus)
1388 
1391 
1392  // UNUM_XYZ_COUNT denotes null (bogus) values.
1393 
1396 
1399 
1402 
1404  Scale scale; // = Scale(); (benign value)
1405 
1407  const AffixPatternProvider* affixProvider = nullptr; // no ownership
1408 
1410  const PluralRules* rules = nullptr; // no ownership
1411 
1413  const CurrencySymbols* currencySymbols = nullptr; // no ownership
1414 
1416  int32_t threshold = kInternalDefaultThreshold;
1417 
1420 
1421  // NOTE: Uses default copy and move constructors.
1422 
1427  bool copyErrorTo(UErrorCode &status) const {
1428  return notation.copyErrorTo(status) || precision.copyErrorTo(status) ||
1429  padder.copyErrorTo(status) || integerWidth.copyErrorTo(status) ||
1430  symbols.copyErrorTo(status) || scale.copyErrorTo(status);
1431  }
1432 };
1433 
1434 } // namespace impl
1435 
1441 template<typename Derived>
1443  public:
1472  Derived notation(const Notation &notation) const &;
1473 
1483  Derived notation(const Notation &notation) &&;
1484 
1528  Derived unit(const icu::MeasureUnit &unit) const &;
1529 
1539  Derived unit(const icu::MeasureUnit &unit) &&;
1540 
1554  Derived adoptUnit(icu::MeasureUnit *unit) const &;
1555 
1565  Derived adoptUnit(icu::MeasureUnit *unit) &&;
1566 
1589  Derived perUnit(const icu::MeasureUnit &perUnit) const &;
1590 
1600  Derived perUnit(const icu::MeasureUnit &perUnit) &&;
1601 
1615  Derived adoptPerUnit(icu::MeasureUnit *perUnit) const &;
1616 
1626  Derived adoptPerUnit(icu::MeasureUnit *perUnit) &&;
1627 
1658  Derived precision(const Precision& precision) const &;
1659 
1669  Derived precision(const Precision& precision) &&;
1670 
1689  Derived roundingMode(UNumberFormatRoundingMode roundingMode) const &;
1690 
1699  Derived roundingMode(UNumberFormatRoundingMode roundingMode) &&;
1700 
1728  Derived grouping(UNumberGroupingStrategy strategy) const &;
1729 
1739  Derived grouping(UNumberGroupingStrategy strategy) &&;
1740 
1765  Derived integerWidth(const IntegerWidth &style) const &;
1766 
1776  Derived integerWidth(const IntegerWidth &style) &&;
1777 
1818  Derived symbols(const DecimalFormatSymbols &symbols) const &;
1819 
1829  Derived symbols(const DecimalFormatSymbols &symbols) &&;
1830 
1864  Derived adoptSymbols(NumberingSystem *symbols) const &;
1865 
1875  Derived adoptSymbols(NumberingSystem *symbols) &&;
1876 
1902  Derived unitWidth(UNumberUnitWidth width) const &;
1903 
1913  Derived unitWidth(UNumberUnitWidth width) &&;
1914 
1940  Derived sign(UNumberSignDisplay style) const &;
1941 
1951  Derived sign(UNumberSignDisplay style) &&;
1952 
1978  Derived decimal(UNumberDecimalSeparatorDisplay style) const &;
1979 
1990 
2015  Derived scale(const Scale &scale) const &;
2016 
2026  Derived scale(const Scale &scale) &&;
2027 
2028 #ifndef U_HIDE_INTERNAL_API
2029 
2035  Derived padding(const impl::Padder &padder) const &;
2036 
2038  Derived padding(const impl::Padder &padder) &&;
2039 
2046  Derived threshold(int32_t threshold) const &;
2047 
2049  Derived threshold(int32_t threshold) &&;
2050 
2056  Derived macros(const impl::MacroProps& macros) const &;
2057 
2059  Derived macros(const impl::MacroProps& macros) &&;
2060 
2062  Derived macros(impl::MacroProps&& macros) const &;
2063 
2065  Derived macros(impl::MacroProps&& macros) &&;
2066 
2067 #endif /* U_HIDE_INTERNAL_API */
2068 
2084 
2085 #ifndef U_HIDE_DRAFT_API
2098 
2106  LocalPointer<Derived> clone() &&;
2107 #endif /* U_HIDE_DRAFT_API */
2108 
2115  UBool copyErrorTo(UErrorCode &outErrorCode) const {
2116  if (U_FAILURE(outErrorCode)) {
2117  // Do not overwrite the older error code
2118  return TRUE;
2119  }
2120  fMacros.copyErrorTo(outErrorCode);
2121  return U_FAILURE(outErrorCode);
2122  }
2123 
2124  // NOTE: Uses default copy and move constructors.
2125 
2126  private:
2127  impl::MacroProps fMacros;
2128 
2129  // Don't construct me directly! Use (Un)LocalizedNumberFormatter.
2130  NumberFormatterSettings() = default;
2131 
2132  friend class LocalizedNumberFormatter;
2133  friend class UnlocalizedNumberFormatter;
2134 
2135  // Give NumberRangeFormatter access to the MacroProps
2136  friend void impl::touchRangeLocales(impl::RangeMacroProps& macros);
2137  friend class impl::NumberRangeFormatterImpl;
2138 };
2139 
2149  : public NumberFormatterSettings<UnlocalizedNumberFormatter>, public UMemory {
2150 
2151  public:
2162 
2173 
2180 
2186 
2193 
2199 
2206 
2207  private:
2209 
2210  explicit UnlocalizedNumberFormatter(
2212 
2213  // To give the fluent setters access to this class's constructor:
2215 
2216  // To give NumberFormatter::with() access to this class's constructor:
2217  friend class NumberFormatter;
2218 };
2219 
2229  : public NumberFormatterSettings<LocalizedNumberFormatter>, public UMemory {
2230  public:
2242  FormattedNumber formatInt(int64_t value, UErrorCode &status) const;
2243 
2255  FormattedNumber formatDouble(double value, UErrorCode &status) const;
2256 
2272 
2273 #ifndef U_HIDE_INTERNAL_API
2274 
2278  FormattedNumber formatDecimalQuantity(const impl::DecimalQuantity& dq, UErrorCode& status) const;
2279 
2283  void getAffixImpl(bool isPrefix, bool isNegative, UnicodeString& result, UErrorCode& status) const;
2284 
2289  const impl::NumberFormatterImpl* getCompiled() const;
2290 
2295  int32_t getCallCount() const;
2296 
2297 #endif /* U_HIDE_INTERNAL_API */
2298 
2312  Format* toFormat(UErrorCode& status) const;
2313 
2320 
2326 
2333 
2339 
2346 
2347 #ifndef U_HIDE_INTERNAL_API
2348 
2361  void formatImpl(impl::UFormattedNumberData *results, UErrorCode &status) const;
2362 
2363 #endif /* U_HIDE_INTERNAL_API */
2364 
2370 
2371  private:
2372  // Note: fCompiled can't be a LocalPointer because impl::NumberFormatterImpl is defined in an internal
2373  // header, and LocalPointer needs the full class definition in order to delete the instance.
2374  const impl::NumberFormatterImpl* fCompiled {nullptr};
2375  char fUnsafeCallCount[8] {}; // internally cast to u_atomic_int32_t
2376 
2377  explicit LocalizedNumberFormatter(const NumberFormatterSettings<LocalizedNumberFormatter>& other);
2378 
2379  explicit LocalizedNumberFormatter(NumberFormatterSettings<LocalizedNumberFormatter>&& src) U_NOEXCEPT;
2380 
2381  LocalizedNumberFormatter(const impl::MacroProps &macros, const Locale &locale);
2382 
2383  LocalizedNumberFormatter(impl::MacroProps &&macros, const Locale &locale);
2384 
2385  void clear();
2386 
2387  void lnfMoveHelper(LocalizedNumberFormatter&& src);
2388 
2392  bool computeCompiled(UErrorCode& status) const;
2393 
2394  // To give the fluent setters access to this class's constructor:
2395  friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
2396  friend class NumberFormatterSettings<LocalizedNumberFormatter>;
2397 
2398  // To give UnlocalizedNumberFormatter::locale() access to this class's constructor:
2399  friend class UnlocalizedNumberFormatter;
2400 };
2401 
2411  public:
2412 
2413  // Default constructor cannot have #ifndef U_HIDE_DRAFT_API
2414 #ifndef U_FORCE_HIDE_DRAFT_API
2420  : fData(nullptr), fErrorCode(U_INVALID_STATE_ERROR) {}
2421 #endif // U_FORCE_HIDE_DRAFT_API
2422 
2428 
2434 
2437 
2439  FormattedNumber& operator=(const FormattedNumber&) = delete;
2440 
2446 
2447  // Copybrief: this method is older than the parent method
2455  UnicodeString toString(UErrorCode& status) const U_OVERRIDE;
2456 
2457  // Copydoc: this method is new in ICU 64
2459  UnicodeString toTempString(UErrorCode& status) const U_OVERRIDE;
2460 
2461  // Copybrief: this method is older than the parent method
2469  Appendable &appendTo(Appendable& appendable, UErrorCode& status) const U_OVERRIDE;
2470 
2471  // Copydoc: this method is new in ICU 64
2473  UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE;
2474 
2475 #ifndef U_HIDE_DRAFT_API
2509  UBool nextFieldPosition(FieldPosition& fieldPosition, UErrorCode& status) const;
2510 
2527 #endif /* U_HIDE_DRAFT_API */
2528 
2529 #ifndef U_HIDE_DRAFT_API
2548  template<typename StringClass>
2549  inline StringClass toDecimalNumber(UErrorCode& status) const;
2550 #endif // U_HIDE_DRAFT_API
2551 
2552 #ifndef U_HIDE_INTERNAL_API
2553 
2558  void getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const;
2559 
2564  void getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih, UErrorCode& status) const;
2565 
2566 #endif /* U_HIDE_INTERNAL_API */
2567 
2568  private:
2569  // Can't use LocalPointer because UFormattedNumberData is forward-declared
2570  const impl::UFormattedNumberData *fData;
2571 
2572  // Error code for the terminal methods
2573  UErrorCode fErrorCode;
2574 
2579  explicit FormattedNumber(impl::UFormattedNumberData *results)
2580  : fData(results), fErrorCode(U_ZERO_ERROR) {}
2581 
2582  explicit FormattedNumber(UErrorCode errorCode)
2583  : fData(nullptr), fErrorCode(errorCode) {}
2584 
2585  // TODO(ICU-20775): Propose this as API.
2586  void toDecimalNumber(ByteSink& sink, UErrorCode& status) const;
2587 
2588  // To give LocalizedNumberFormatter format methods access to this class's constructor:
2589  friend class LocalizedNumberFormatter;
2590 
2591  // To give C API access to internals
2592  friend struct impl::UFormattedNumberImpl;
2593 };
2594 
2595 #ifndef U_HIDE_DRAFT_API
2596 // Note: This is draft ICU 65
2597 template<typename StringClass>
2598 StringClass FormattedNumber::toDecimalNumber(UErrorCode& status) const {
2599  StringClass result;
2600  StringByteSink<StringClass> sink(&result);
2601  toDecimalNumber(sink, status);
2602  return result;
2603 };
2604 #endif // U_HIDE_DRAFT_API
2605 
2612  public:
2621 
2632 
2648 
2649 #ifndef U_HIDE_DRAFT_API
2668  UParseError& perror, UErrorCode& status);
2669 #endif
2670 
2674  NumberFormatter() = delete;
2675 };
2676 
2677 } // namespace number
2678 U_NAMESPACE_END
2679 
2680 #endif /* #if !UCONFIG_NO_FORMATTING */
2681 
2682 #endif /* U_SHOW_CPLUSPLUS_API */
2683 
2684 #endif // __NUMBERFORMATTER_H__
2685 
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
FieldPositionIterator returns the field ids and their start/limit positions generated by a call to Fo...
Definition: fpositer.h:58
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:110
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:40
Defines numbering systems.
Definition: numsys.h:60
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:200
Implementation of ByteSink that writes to a "string".
Definition: bytestream.h:235
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:60
UMemory is the common ICU base class.
Definition: uobject.h:115
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
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.
UBool nextFieldPosition(FieldPosition &fieldPosition, UErrorCode &status) const
Determines the start (inclusive) and end (exclusive) indices of the next occurrence of the given fiel...
virtual ~FormattedNumber() U_OVERRIDE
Destruct an instance of FormattedNumber.
FormattedNumber(FormattedNumber &&src) U_NOEXCEPT
Move constructor: Leaves the source FormattedNumber in an undefined state.
void getAllFieldPositions(FieldPositionIterator &iterator, UErrorCode &status) const
Export the formatted number to a FieldPositionIterator.
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 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 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 adoptSymbols(NumberingSystem *symbols) const &
Specifies that the given numbering system should be used when fetching symbols.
Derived precision(const Precision &precision) const &
Specifies the rounding precision to use when formatting numbers.
Derived decimal(UNumberDecimalSeparatorDisplay style) &&
Overload of decimal() for use on an rvalue reference.
Derived unitWidth(UNumberUnitWidth width) const &
Sets the width of the unit (measure unit or currency).
Derived adoptUnit(icu::MeasureUnit *unit) const &
Like unit(), but takes ownership of a pointer.
Derived perUnit(const icu::MeasureUnit &perUnit) &&
Overload of perUnit() for use on an rvalue reference.
Derived padding(const impl::Padder &padder) &&
Derived adoptSymbols(NumberingSystem *symbols) &&
Overload of adoptSymbols() for use on an rvalue reference.
Derived macros(const impl::MacroProps &macros) &&
Derived roundingMode(UNumberFormatRoundingMode roundingMode) &&
Overload of roundingMode() for use on an rvalue reference.
Derived integerWidth(const IntegerWidth &style) const &
Specifies the minimum and maximum number of digits to render before the decimal mark.
Derived macros(const impl::MacroProps &macros) const &
Internal fluent setter to overwrite the entire macros object.
Derived threshold(int32_t threshold) const &
Internal fluent setter to support a custom regulation threshold.
Derived perUnit(const icu::MeasureUnit &perUnit) const &
Sets a unit to be used in the denominator.
Derived integerWidth(const IntegerWidth &style) &&
Overload of integerWidth() for use on an rvalue reference.
Derived grouping(UNumberGroupingStrategy strategy) const &
Specifies the grouping strategy to use when formatting numbers.
Derived unit(const icu::MeasureUnit &unit) const &
Specifies the unit (unit of measure, currency, or percent) to associate with rendered numbers.
UBool copyErrorTo(UErrorCode &outErrorCode) const
Sets the UErrorCode if an error occurred in the fluent chain.
Derived adoptPerUnit(icu::MeasureUnit *perUnit) const &
Like perUnit(), but takes ownership of a pointer.
Derived adoptUnit(icu::MeasureUnit *unit) &&
Overload of adoptUnit() for use on an rvalue reference.
Derived scale(const Scale &scale) &&
Overload of scale() for use on an rvalue reference.
Derived precision(const Precision &precision) &&
Overload of precision() for use on an rvalue reference.
Derived symbols(const DecimalFormatSymbols &symbols) &&
Overload of symbols() for use on an rvalue reference.
Derived padding(const impl::Padder &padder) const &
Set the padding strategy.
Derived notation(const Notation &notation) const &
Specifies the notation style (simple, scientific, or compact) for rendering numbers.
Derived sign(UNumberSignDisplay style) const &
Sets the plus/minus sign display strategy.
Derived threshold(int32_t threshold) &&
Derived roundingMode(UNumberFormatRoundingMode roundingMode) const &
Specifies how to determine the direction to round a number when it has more digits than fit in the de...
Derived symbols(const DecimalFormatSymbols &symbols) const &
Specifies the symbols (decimal separator, grouping separator, percent sign, numerals,...
Derived macros(impl::MacroProps &&macros) &&
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 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,...
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)
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:425
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261
#define U_OVERRIDE
Defined to the C++11 "override" keyword if available.
Definition: umachine.h:129
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:265
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:269
C API: Compatibility APIs for number formatting.
UNumberFormatRoundingMode
The possible number format rounding modes.
Definition: unum.h:279
@ UNUM_ROUND_HALFEVEN
Half-even rounding.
Definition: unum.h:288
UNumberCompactStyle
Constants for specifying short or long format.
Definition: unum.h:319
UNumberFormatPadPosition
The possible number format pad positions.
Definition: unum.h:308
C-compatible API for localized number formatting; not recommended for C++.
UNumberSignDisplay
An enum declaring how to denote positive and negative numbers.
@ UNUM_SIGN_COUNT
One more than the highest UNumberSignDisplay value.
UNumberDecimalSeparatorDisplay
An enum declaring how to render the decimal separator.
@ UNUM_DECIMAL_SEPARATOR_COUNT
One more than the highest UNumberDecimalSeparatorDisplay value.
UNumberUnitWidth
An enum declaring how to render units, including currencies.
@ UNUM_UNIT_WIDTH_COUNT
One more than the highest UNumberUnitWidth value.
UNumberGroupingStrategy
An enum declaring the strategy for when and how to display grouping separators (i....
C++ API: Common ICU base class UObject.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
@ U_MEMORY_ALLOCATION_ERROR
Memory allocation error.
Definition: utypes.h:457
@ U_INVALID_STATE_ERROR
Requested operation can not be completed with ICU in its current state.
Definition: utypes.h:478
@ U_ZERO_ERROR
No error, no warning.
Definition: utypes.h:449
#define U_FAILURE(x)
Does the error code indicate a failure?
Definition: utypes.h:709
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:301