ICU 61.1  61.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 #include "unicode/utypes.h"
5 
6 #if !UCONFIG_NO_FORMATTING
7 #ifndef __NUMBERFORMATTER_H__
8 #define __NUMBERFORMATTER_H__
9 
10 #include "unicode/appendable.h"
11 #include "unicode/dcfmtsym.h"
12 #include "unicode/currunit.h"
13 #include "unicode/fieldpos.h"
14 #include "unicode/fpositer.h"
15 #include "unicode/measunit.h"
16 #include "unicode/nounit.h"
17 #include "unicode/plurrule.h"
18 #include "unicode/ucurr.h"
19 #include "unicode/unum.h"
20 
21 #ifndef U_HIDE_DRAFT_API
22 
95 typedef enum UNumberUnitWidth {
108 
124 
135 
146 
155 
156 #ifndef U_HIDE_INTERNAL_API
157  ,
164 #endif // U_HIDE_INTERNAL_API
166 
193 typedef enum UGroupingStrategy {
200 
216 
231 
247 
255 
257 
277 typedef enum UNumberSignDisplay {
285 
293 
300 
316 
326 
334 
343 
344 #ifndef U_HIDE_INTERNAL_API
345  ,
352 #endif // U_HIDE_INTERNAL_API
354 
372 
379 
380 #ifndef U_HIDE_INTERNAL_API
381  ,
388 #endif // U_HIDE_INTERNAL_API
390 
391 U_NAMESPACE_BEGIN namespace number { // icu::number
392 
393 // Forward declarations:
394 class UnlocalizedNumberFormatter;
395 class LocalizedNumberFormatter;
396 class FormattedNumber;
397 class Notation;
398 class ScientificNotation;
399 class Rounder;
400 class FractionRounder;
401 class CurrencyRounder;
402 class IncrementRounder;
403 class IntegerWidth;
404 
405 namespace impl {
406 
407 #ifndef U_HIDE_INTERNAL_API
408 
413 typedef int16_t digits_t;
414 
421 static constexpr int32_t DEFAULT_THRESHOLD = 3;
422 #endif // U_HIDE_INTERNAL_API
423 
424 // Forward declarations:
425 class Padder;
426 struct MacroProps;
427 struct MicroProps;
428 class DecimalQuantity;
429 struct NumberFormatterResults;
430 class NumberFormatterImpl;
431 struct ParsedPatternInfo;
432 class ScientificModifier;
433 class MultiplierProducer;
434 class MutablePatternModifier;
435 class LongNameHandler;
436 class ScientificHandler;
437 class CompactHandler;
438 class Modifier;
439 class NumberStringBuilder;
440 
441 } // namespace impl
442 
443 // Reserve extra names in case they are added as classes in the future:
444 typedef Notation CompactNotation;
445 typedef Notation SimpleNotation;
446 
452 class U_I18N_API Notation : public UMemory {
453  public:
478  static ScientificNotation scientific();
479 
502  static ScientificNotation engineering();
503 
545  static CompactNotation compactShort();
546 
569  static CompactNotation compactLong();
570 
595  static SimpleNotation simple();
596 
597  private:
598  enum NotationType {
599  NTN_SCIENTIFIC, NTN_COMPACT, NTN_SIMPLE, NTN_ERROR
600  } fType;
601 
602  union NotationUnion {
603  // For NTN_SCIENTIFIC
605  int8_t fEngineeringInterval;
606  bool fRequireMinInt;
607  impl::digits_t fMinExponentDigits;
608  UNumberSignDisplay fExponentSignDisplay;
609  } scientific;
610 
611  // For NTN_COMPACT
612  UNumberCompactStyle compactStyle;
613 
614  // For NTN_ERROR
615  UErrorCode errorCode;
616  } fUnion;
617 
619 
620  Notation(const NotationType &type, const NotationUnion &union_) : fType(type), fUnion(union_) {}
621 
622  Notation(UErrorCode errorCode) : fType(NTN_ERROR) {
623  fUnion.errorCode = errorCode;
624  }
625 
626  Notation() : fType(NTN_SIMPLE), fUnion() {}
627 
628  UBool copyErrorTo(UErrorCode &status) const {
629  if (fType == NTN_ERROR) {
630  status = fUnion.errorCode;
631  return TRUE;
632  }
633  return FALSE;
634  }
635 
636  // To allow MacroProps to initialize empty instances:
637  friend struct impl::MacroProps;
638  friend class ScientificNotation;
639 
640  // To allow implementation to access internal types:
641  friend class impl::NumberFormatterImpl;
642  friend class impl::ScientificModifier;
643  friend class impl::ScientificHandler;
644 };
645 
655  public:
669  ScientificNotation withMinExponentDigits(int32_t minExponentDigits) const;
670 
684  ScientificNotation withExponentSignDisplay(UNumberSignDisplay exponentSignDisplay) const;
685 
686  private:
687  // Inherit constructor
688  using Notation::Notation;
689 
690  friend class Notation;
691 };
692 
693 // Reserve extra names in case they are added as classes in the future:
694 typedef Rounder DigitRounder;
695 
704 class U_I18N_API Rounder : public UMemory {
705 
706  public:
723  static Rounder unlimited();
724 
731  static FractionRounder integer();
732 
760  static FractionRounder fixedFraction(int32_t minMaxFractionPlaces);
761 
775  static FractionRounder minFraction(int32_t minFractionPlaces);
776 
787  static FractionRounder maxFraction(int32_t maxFractionPlaces);
788 
802  static FractionRounder minMaxFraction(int32_t minFractionPlaces, int32_t maxFractionPlaces);
803 
817  static DigitRounder fixedDigits(int32_t minMaxSignificantDigits);
818 
831  static DigitRounder minDigits(int32_t minSignificantDigits);
832 
841  static DigitRounder maxDigits(int32_t maxSignificantDigits);
842 
854  static DigitRounder minMaxDigits(int32_t minSignificantDigits, int32_t maxSignificantDigits);
855 
875  static IncrementRounder increment(double roundingIncrement);
876 
893  static CurrencyRounder currency(UCurrencyUsage currencyUsage);
894 
904  Rounder withMode(UNumberFormatRoundingMode roundingMode) const;
905 
906  private:
907  enum RounderType {
908  RND_BOGUS,
909  RND_NONE,
910  RND_FRACTION,
911  RND_SIGNIFICANT,
912  RND_FRACTION_SIGNIFICANT,
913  RND_INCREMENT,
914  RND_CURRENCY,
915  RND_PASS_THROUGH,
916  RND_ERROR
917  } fType;
918 
919  union RounderUnion {
921  // For RND_FRACTION, RND_SIGNIFICANT, and RND_FRACTION_SIGNIFICANT
922  impl::digits_t fMinFrac;
923  impl::digits_t fMaxFrac;
924  impl::digits_t fMinSig;
925  impl::digits_t fMaxSig;
926  } fracSig;
928  double fIncrement;
929  impl::digits_t fMinFrac;
930  } increment; // For RND_INCREMENT
931  UCurrencyUsage currencyUsage; // For RND_CURRENCY
932  UErrorCode errorCode; // For RND_ERROR
933  } fUnion;
934 
937 
938  UNumberFormatRoundingMode fRoundingMode;
939 
940  Rounder(const RounderType &type, const RounderUnion &union_, UNumberFormatRoundingMode roundingMode)
941  : fType(type), fUnion(union_), fRoundingMode(roundingMode) {}
942 
943  Rounder(UErrorCode errorCode) : fType(RND_ERROR) {
944  fUnion.errorCode = errorCode;
945  }
946 
947  Rounder() : fType(RND_BOGUS) {}
948 
949  bool isBogus() const {
950  return fType == RND_BOGUS;
951  }
952 
953  UBool copyErrorTo(UErrorCode &status) const {
954  if (fType == RND_ERROR) {
955  status = fUnion.errorCode;
956  return TRUE;
957  }
958  return FALSE;
959  }
960 
961  // On the parent type so that this method can be called internally on Rounder instances.
962  Rounder withCurrency(const CurrencyUnit &currency, UErrorCode &status) const;
963 
965  void setLocaleData(const CurrencyUnit &currency, UErrorCode &status);
966 
967  void apply(impl::DecimalQuantity &value, UErrorCode &status) const;
968 
970  void apply(impl::DecimalQuantity &value, int32_t minInt, UErrorCode status);
971 
986  int32_t
987  chooseMultiplierAndApply(impl::DecimalQuantity &input, const impl::MultiplierProducer &producer,
988  UErrorCode &status);
989 
990  static FractionRounder constructFraction(int32_t minFrac, int32_t maxFrac);
991 
992  static Rounder constructSignificant(int32_t minSig, int32_t maxSig);
993 
994  static Rounder
995  constructFractionSignificant(const FractionRounder &base, int32_t minSig, int32_t maxSig);
996 
997  static IncrementRounder constructIncrement(double increment, int32_t minFrac);
998 
999  static CurrencyRounder constructCurrency(UCurrencyUsage usage);
1000 
1001  static Rounder constructPassThrough();
1002 
1003  // To allow MacroProps/MicroProps to initialize bogus instances:
1004  friend struct impl::MacroProps;
1005  friend struct impl::MicroProps;
1006 
1007  // To allow NumberFormatterImpl to access isBogus() and other internal methods:
1008  friend class impl::NumberFormatterImpl;
1009 
1010  // To give access to apply() and chooseMultiplierAndApply():
1011  friend class impl::MutablePatternModifier;
1012  friend class impl::LongNameHandler;
1013  friend class impl::ScientificHandler;
1014  friend class impl::CompactHandler;
1015 
1016  // To allow child classes to call private methods:
1017  friend class FractionRounder;
1018  friend class CurrencyRounder;
1019  friend class IncrementRounder;
1020 };
1021 
1032  public:
1049  Rounder withMinDigits(int32_t minSignificantDigits) const;
1050 
1068  Rounder withMaxDigits(int32_t maxSignificantDigits) const;
1069 
1070  private:
1071  // Inherit constructor
1072  using Rounder::Rounder;
1073 
1074  // To allow parent class to call this class's constructor:
1075  friend class Rounder;
1076 };
1077 
1088  public:
1106  Rounder withCurrency(const CurrencyUnit &currency) const;
1107 
1108  private:
1109  // Inherit constructor
1110  using Rounder::Rounder;
1111 
1112  // To allow parent class to call this class's constructor:
1113  friend class Rounder;
1114 };
1115 
1126  public:
1142  Rounder withMinFraction(int32_t minFrac) const;
1143 
1144  private:
1145  // Inherit constructor
1146  using Rounder::Rounder;
1147 
1148  // To allow parent class to call this class's constructor:
1149  friend class Rounder;
1150 };
1151 
1162  public:
1175  static IntegerWidth zeroFillTo(int32_t minInt);
1176 
1189  IntegerWidth truncateAt(int32_t maxInt);
1190 
1191  private:
1192  union {
1193  struct {
1194  impl::digits_t fMinInt;
1195  impl::digits_t fMaxInt;
1196  } minMaxInt;
1197  UErrorCode errorCode;
1198  } fUnion;
1199  bool fHasError = false;
1200 
1201  IntegerWidth(impl::digits_t minInt, impl::digits_t maxInt);
1202 
1203  IntegerWidth(UErrorCode errorCode) { // NOLINT
1204  fUnion.errorCode = errorCode;
1205  fHasError = true;
1206  }
1207 
1208  IntegerWidth() { // NOLINT
1209  fUnion.minMaxInt.fMinInt = -1;
1210  }
1211 
1212  bool isBogus() const {
1213  return !fHasError && fUnion.minMaxInt.fMinInt == -1;
1214  }
1215 
1216  UBool copyErrorTo(UErrorCode &status) const {
1217  if (fHasError) {
1218  status = fUnion.errorCode;
1219  return TRUE;
1220  }
1221  return FALSE;
1222  }
1223 
1224  void apply(impl::DecimalQuantity &quantity, UErrorCode &status) const;
1225 
1226  // To allow MacroProps/MicroProps to initialize empty instances:
1227  friend struct impl::MacroProps;
1228  friend struct impl::MicroProps;
1229 
1230  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1231  friend class impl::NumberFormatterImpl;
1232 };
1233 
1234 namespace impl {
1235 
1236 // Do not enclose entire SymbolsWrapper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1239  public:
1241  SymbolsWrapper() : fType(SYMPTR_NONE), fPtr{nullptr} {}
1242 
1244  SymbolsWrapper(const SymbolsWrapper &other);
1245 
1247  ~SymbolsWrapper();
1248 
1250  SymbolsWrapper &operator=(const SymbolsWrapper &other);
1251 
1252 #ifndef U_HIDE_INTERNAL_API
1253 
1257  void setTo(const DecimalFormatSymbols &dfs);
1258 
1263  void setTo(const NumberingSystem *ns);
1264 
1269  bool isDecimalFormatSymbols() const;
1270 
1275  bool isNumberingSystem() const;
1276 
1281  const DecimalFormatSymbols *getDecimalFormatSymbols() const;
1282 
1287  const NumberingSystem *getNumberingSystem() const;
1288 
1290  UBool copyErrorTo(UErrorCode &status) const {
1291  if (fType == SYMPTR_DFS && fPtr.dfs == nullptr) {
1292  status = U_MEMORY_ALLOCATION_ERROR;
1293  return TRUE;
1294  } else if (fType == SYMPTR_NS && fPtr.ns == nullptr) {
1295  status = U_MEMORY_ALLOCATION_ERROR;
1296  return TRUE;
1297  }
1298  return FALSE;
1299  }
1300 #endif // U_HIDE_INTERNAL_API
1301 
1302  private:
1303  enum SymbolsPointerType {
1304  SYMPTR_NONE, SYMPTR_DFS, SYMPTR_NS
1305  } fType;
1306 
1307  union {
1308  const DecimalFormatSymbols *dfs;
1309  const NumberingSystem *ns;
1310  } fPtr;
1311 
1312  void doCopyFrom(const SymbolsWrapper &other);
1313 
1314  void doCleanup();
1315 };
1316 
1317 // Do not enclose entire Grouper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1319 class U_I18N_API Grouper : public UMemory {
1320  public:
1321 #ifndef U_HIDE_INTERNAL_API
1322 
1323  static Grouper forStrategy(UGroupingStrategy grouping);
1324 
1325  // Future: static Grouper forProperties(DecimalFormatProperties& properties);
1326 
1328  Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping)
1329  : fGrouping1(grouping1), fGrouping2(grouping2), fMinGrouping(minGrouping) {}
1330 #endif // U_HIDE_INTERNAL_API
1331 
1332  private:
1341  int16_t fGrouping1;
1342  int16_t fGrouping2;
1343 
1351  int16_t fMinGrouping;
1352 
1353  Grouper() : fGrouping1(-3) {};
1354 
1355  bool isBogus() const {
1356  return fGrouping1 == -3;
1357  }
1358 
1360  void setLocaleData(const impl::ParsedPatternInfo &patternInfo, const Locale& locale);
1361 
1362  bool groupAtPosition(int32_t position, const impl::DecimalQuantity &value) const;
1363 
1364  // To allow MacroProps/MicroProps to initialize empty instances:
1365  friend struct MacroProps;
1366  friend struct MicroProps;
1367 
1368  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1369  friend class NumberFormatterImpl;
1370 };
1371 
1372 // Do not enclose entire Padder with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1374 class U_I18N_API Padder : public UMemory {
1375  public:
1376 #ifndef U_HIDE_INTERNAL_API
1377 
1378  static Padder none();
1379 
1381  static Padder codePoints(UChar32 cp, int32_t targetWidth, UNumberFormatPadPosition position);
1382 #endif // U_HIDE_INTERNAL_API
1383 
1384  private:
1385  UChar32 fWidth; // -3 = error; -2 = bogus; -1 = no padding
1386  union {
1387  struct {
1388  int32_t fCp;
1389  UNumberFormatPadPosition fPosition;
1390  } padding;
1391  UErrorCode errorCode;
1392  } fUnion;
1393 
1394  Padder(UChar32 cp, int32_t width, UNumberFormatPadPosition position);
1395 
1396  Padder(int32_t width);
1397 
1398  Padder(UErrorCode errorCode) : fWidth(-3) { // NOLINT
1399  fUnion.errorCode = errorCode;
1400  }
1401 
1402  Padder() : fWidth(-2) {} // NOLINT
1403 
1404  bool isBogus() const {
1405  return fWidth == -2;
1406  }
1407 
1408  UBool copyErrorTo(UErrorCode &status) const {
1409  if (fWidth == -3) {
1410  status = fUnion.errorCode;
1411  return TRUE;
1412  }
1413  return FALSE;
1414  }
1415 
1416  bool isValid() const {
1417  return fWidth > 0;
1418  }
1419 
1420  int32_t padAndApply(const impl::Modifier &mod1, const impl::Modifier &mod2,
1421  impl::NumberStringBuilder &string, int32_t leftIndex, int32_t rightIndex,
1422  UErrorCode &status) const;
1423 
1424  // To allow MacroProps/MicroProps to initialize empty instances:
1425  friend struct MacroProps;
1426  friend struct MicroProps;
1427 
1428  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1429  friend class impl::NumberFormatterImpl;
1430 };
1431 
1432 // Do not enclose entire MacroProps with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1434 struct U_I18N_API MacroProps : public UMemory {
1437 
1439  MeasureUnit unit; // = NoUnit::base();
1440 
1442  MeasureUnit perUnit; // = NoUnit::base();
1443 
1445  Rounder rounder; // = Rounder(); (bogus)
1446 
1448  Grouper grouper; // = Grouper(); (bogus)
1449 
1451  Padder padder; // = Padder(); (bogus)
1452 
1454  IntegerWidth integerWidth; // = IntegerWidth(); (bogus)
1455 
1458 
1459  // UNUM_XYZ_COUNT denotes null (bogus) values.
1460 
1463 
1466 
1469 
1471  PluralRules *rules = nullptr; // no ownership
1472 
1474  int32_t threshold = DEFAULT_THRESHOLD;
1475  Locale locale;
1476 
1481  bool copyErrorTo(UErrorCode &status) const {
1482  return notation.copyErrorTo(status) || rounder.copyErrorTo(status) ||
1483  padder.copyErrorTo(status) || integerWidth.copyErrorTo(status) ||
1484  symbols.copyErrorTo(status);
1485  }
1486 };
1487 
1488 } // namespace impl
1489 
1494 template<typename Derived>
1496  public:
1525  Derived notation(const Notation &notation) const;
1526 
1571  Derived unit(const icu::MeasureUnit &unit) const;
1572 
1588  Derived adoptUnit(icu::MeasureUnit *unit) const;
1589 
1607  Derived perUnit(const icu::MeasureUnit &perUnit) const;
1608 
1626  Derived adoptPerUnit(icu::MeasureUnit *perUnit) const;
1627 
1659  Derived rounding(const Rounder &rounder) const;
1660 
1688  Derived grouping(const UGroupingStrategy &strategy) const;
1689 
1714  Derived integerWidth(const IntegerWidth &style) const;
1715 
1756  Derived symbols(const DecimalFormatSymbols &symbols) const;
1757 
1791  Derived adoptSymbols(NumberingSystem *symbols) const;
1792 
1818  Derived unitWidth(const UNumberUnitWidth &width) const;
1819 
1846  Derived sign(const UNumberSignDisplay &width) const;
1847 
1874  Derived decimal(const UNumberDecimalSeparatorDisplay &width) const;
1875 
1876 #ifndef U_HIDE_INTERNAL_API
1877 
1883  Derived padding(const impl::Padder &padder) const;
1884 
1891  Derived threshold(int32_t threshold) const;
1892 
1893 #endif /* U_HIDE_INTERNAL_API */
1894 
1901  UBool copyErrorTo(UErrorCode &outErrorCode) const {
1902  if (U_FAILURE(outErrorCode)) {
1903  // Do not overwrite the older error code
1904  return TRUE;
1905  }
1906  fMacros.copyErrorTo(outErrorCode);
1907  return U_FAILURE(outErrorCode);
1908  }
1909 
1910  protected:
1911  impl::MacroProps fMacros;
1912 
1913  private:
1914  // Don't construct me directly! Use (Un)LocalizedNumberFormatter.
1915  NumberFormatterSettings() = default;
1916 
1917  friend class LocalizedNumberFormatter;
1918  friend class UnlocalizedNumberFormatter;
1919 };
1920 
1928  : public NumberFormatterSettings<UnlocalizedNumberFormatter>, public UMemory {
1929 
1930  public:
1947  LocalizedNumberFormatter locale(const icu::Locale &locale) const;
1948 
1949  // Make default copy constructor call the NumberFormatterSettings copy constructor.
1955  static_cast<const NumberFormatterSettings<UnlocalizedNumberFormatter> &>(other)) {}
1956 
1957  private:
1958  UnlocalizedNumberFormatter() = default;
1959 
1960  explicit UnlocalizedNumberFormatter(
1962 
1963  // To give the fluent setters access to this class's constructor:
1964  friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
1965 
1966  // To give NumberFormatter::with() access to this class's constructor:
1967  friend class NumberFormatter;
1968 };
1969 
1977  : public NumberFormatterSettings<LocalizedNumberFormatter>, public UMemory {
1978  public:
1990  FormattedNumber formatInt(int64_t value, UErrorCode &status) const;
1991 
2003  FormattedNumber formatDouble(double value, UErrorCode &status) const;
2004 
2019  FormattedNumber formatDecimal(StringPiece value, UErrorCode &status) const;
2020 
2021  // Make default copy constructor call the NumberFormatterSettings copy constructor.
2027  static_cast<const NumberFormatterSettings<LocalizedNumberFormatter> &>(other)) {}
2028 
2034 
2035  private:
2036  const impl::NumberFormatterImpl* fCompiled {nullptr};
2037  char fUnsafeCallCount[8] {}; // internally cast to u_atomic_int32_t
2038 
2039  LocalizedNumberFormatter() = default;
2040 
2042 
2043  LocalizedNumberFormatter(const impl::MacroProps &macros, const Locale &locale);
2044 
2056  FormattedNumber formatImpl(impl::NumberFormatterResults *results, UErrorCode &status) const;
2057 
2058  // To give the fluent setters access to this class's constructor:
2059  friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
2060  friend class NumberFormatterSettings<LocalizedNumberFormatter>;
2061 
2062  // To give UnlocalizedNumberFormatter::locale() access to this class's constructor:
2063  friend class UnlocalizedNumberFormatter;
2064 };
2065 
2073  public:
2080  UnicodeString toString() const;
2081 
2091  Appendable &appendTo(Appendable &appendable);
2092 
2112  void populateFieldPosition(FieldPosition &fieldPosition, UErrorCode &status);
2113 
2128  void populateFieldPositionIterator(FieldPositionIterator &iterator, UErrorCode &status);
2129 
2134  ~FormattedNumber();
2135 
2136  private:
2137  // Can't use LocalPointer because NumberFormatterResults is forward-declared
2138  const impl::NumberFormatterResults *fResults;
2139 
2140  // Error code for the terminal methods
2141  UErrorCode fErrorCode;
2142 
2143  explicit FormattedNumber(impl::NumberFormatterResults *results)
2144  : fResults(results), fErrorCode(U_ZERO_ERROR) {};
2145 
2146  explicit FormattedNumber(UErrorCode errorCode)
2147  : fResults(nullptr), fErrorCode(errorCode) {};
2148 
2149  // To give LocalizedNumberFormatter format methods access to this class's constructor:
2150  friend class LocalizedNumberFormatter;
2151 };
2152 
2159  public:
2167  static UnlocalizedNumberFormatter with();
2168 
2178  static LocalizedNumberFormatter withLocale(const Locale &locale);
2179 
2184  NumberFormatter() = delete;
2185 };
2186 
2187 } // namespace number
2189 
2190 #endif // U_HIDE_DRAFT_API
2191 
2192 #endif // __NUMBERFORMATTER_H__
2193 
2194 #endif /* #if !UCONFIG_NO_FORMATTING */
This class represents the set of symbols needed by DecimalFormat to format numbers.
Definition: dcfmtsym.h:84
Always show the decimal separator, even if there are no digits to display after the separator...
UNumberFormatRoundingMode
The possible number format rounding modes.
Definition: unum.h:278
One more than the highest UNumberSignDisplay value.
A class that defines a rounding strategy parameterized by a rounding increment to be used when format...
A unit such as length, mass, volume, currency, etc.
Definition: measunit.h:38
C++ API: Currency Unit Information.
Always display the grouping separator on values of at least 1000.
Display grouping using the default strategy for all locales.
bool copyErrorTo(UErrorCode &status) const
Check all members for errors.
Use the three-digit ISO XXX code in place of the symbol for displaying currencies.
See the main description in numberformatter.h for documentation and examples.
A class that defines a rounding strategy based on a number of fraction places and optionally signific...
Use the locale-dependent accounting format on negative numbers, and do not show the sign on positive ...
#define U_FAILURE(x)
Does the error code indicate a failure?
Definition: utypes.h:691
A class that defines the strategy for padding and truncating integers before the decimal separator...
enum UNumberDecimalSeparatorDisplay UNumberDecimalMarkDisplay
An enum declaring how to render the decimal separator.
C++ API: FieldPosition Iterator.
A class that defines the rounding strategy to be used when formatting numbers in NumberFormatter.
LocalizedNumberFormatter(const LocalizedNumberFormatter &other)
Returns a copy of this LocalizedNumberFormatter.
Use the Western defaults: groups of 3 and enabled for all numbers 1000 or greater.
Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping)
Defines numbering systems.
Definition: numsys.h:60
C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (char16_ts).
C++ API: units for percent and permille.
No error, no warning.
Definition: utypes.h:430
C++ API: PluralRules object.
Do not show the sign on positive or negative numbers.
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:197
Memory allocation error.
Definition: utypes.h:438
An abstract base class for specifying settings related to number formatting.
Use the locale-dependent accounting format on negative numbers, and show the plus sign on positive nu...
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:360
Format the number according to the specified unit, but do not display the unit.
C++ API: FieldPosition identifies the fields in a formatted output.
A class that defines the notation style to be used when formatting numbers in NumberFormatter.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
UNumberDecimalSeparatorDisplay
An enum declaring how to render the decimal separator.
FieldPositionIterator returns the field ids and their start/limit positions generated by a call to Fo...
Definition: fpositer.h:62
Show the decimal separator when there are one or more digits to display after the separator...
C++ API: A unit for measuring a quantity.
C API: Encapsulates information about a currency.
Print an abbreviated version of the unit name.
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:400
UNumberUnitWidth
An enum declaring how to render units, including currencies.
Do not display grouping separators in any locale.
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:240
A unit of currency, such as USD (U.S.
Definition: currunit.h:37
Use the locale-dependent accounting format on negative numbers, and show the plus sign on positive nu...
UNumberFormatPadPosition
The possible number format pad positions.
Definition: unum.h:307
UNumberSignDisplay
An enum declaring how to denote positive and negative numbers.
Print the full name of the unit, without any abbreviations.
A NumberFormatter that does not yet have a locale.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
UNumberCompactStyle
Constants for specifying short or long format.
Definition: unum.h:318
A class that defines a rounding strategy parameterized by a currency to be used when formatting numbe...
A NumberFormatter that has a locale associated with it; this means .format() methods are available...
UBool copyErrorTo(UErrorCode &outErrorCode) const
Sets the UErrorCode if an error occurred in the fluent chain.
Print an abbreviated version of the unit name.
Show the minus sign on negative numbers and the plus sign on positive numbers, including zero...
UBool copyErrorTo(UErrorCode &status) const
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:108
C++ API: Symbols for formatting numbers.
UnlocalizedNumberFormatter(const UnlocalizedNumberFormatter &other)
Returns a copy of this UnlocalizedNumberFormatter.
One more than the highest UNumberUnitWidth value.
A class that defines the scientific notation style to be used when formatting numbers in NumberFormat...
Basic definitions for ICU, for both C and C++ APIs.
Display grouping using locale defaults, except do not show grouping on values smaller than 10000 (suc...
Show the minus sign on negative numbers, and do not show the sign on positive numbers.
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:244
One more than the highest UNumberDecimalSeparatorDisplay value.
int16_t digits_t
Datatype for minimum/maximum fraction digits.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:286
The result of a number formatting operation.
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:54
UMemory is the common ICU base class.
Definition: uobject.h:112
UGroupingStrategy
An enum declaring the strategy for when and how to display grouping separators (i.e., the separator, often a comma or period, after every 2-3 powers of ten).
Show the minus sign on negative numbers and the plus sign on positive numbers.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236
Base class for objects to which Unicode characters and strings can be appended.
Definition: appendable.h:51
C API: NumberFormat.
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:188