ICU 60.1  60.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 
99 typedef enum UNumberUnitWidth {
112 
128 
139 
150 
159 
167 
186 typedef enum UNumberSignDisplay {
194 
201 
208 
224 
232 
240 
258 
265 
273 
274 U_NAMESPACE_BEGIN namespace number { // icu::number
275 
276 // Forward declarations:
277 class UnlocalizedNumberFormatter;
278 class LocalizedNumberFormatter;
279 class FormattedNumber;
280 class Notation;
281 class ScientificNotation;
282 class Rounder;
283 class FractionRounder;
284 class CurrencyRounder;
285 class IncrementRounder;
286 class Grouper;
287 class IntegerWidth;
288 
289 namespace impl {
290 
291 // Forward declarations:
292 class Padder;
293 struct MacroProps;
294 struct MicroProps;
295 class DecimalQuantity;
296 struct NumberFormatterResults;
297 class NumberFormatterImpl;
298 struct ParsedPatternInfo;
299 class ScientificModifier;
300 class MultiplierProducer;
301 class MutablePatternModifier;
302 class LongNameHandler;
303 class ScientificHandler;
304 class CompactHandler;
305 class Modifier;
306 class NumberStringBuilder;
307 
308 } // namespace impl
309 
310 // Reserve extra names in case they are added as classes in the future:
311 typedef Notation CompactNotation;
312 typedef Notation SimpleNotation;
313 
319 class U_I18N_API Notation : public UMemory {
320  public:
345  static ScientificNotation scientific();
346 
369  static ScientificNotation engineering();
370 
412  static CompactNotation compactShort();
413 
436  static CompactNotation compactLong();
437 
462  static SimpleNotation simple();
463 
464  private:
465  enum NotationType {
466  NTN_SCIENTIFIC, NTN_COMPACT, NTN_SIMPLE, NTN_ERROR
467  } fType;
468 
469  union NotationUnion {
470  // For NTN_SCIENTIFIC
472  int8_t fEngineeringInterval;
473  bool fRequireMinInt;
474  int8_t fMinExponentDigits;
475  UNumberSignDisplay fExponentSignDisplay;
476  } scientific;
477 
478  // For NTN_COMPACT
479  UNumberCompactStyle compactStyle;
480 
481  // For NTN_ERROR
482  UErrorCode errorCode;
483  } fUnion;
484 
486 
487  Notation(const NotationType &type, const NotationUnion &union_) : fType(type), fUnion(union_) {}
488 
489  Notation(UErrorCode errorCode) : fType(NTN_ERROR) {
490  fUnion.errorCode = errorCode;
491  }
492 
493  Notation() : fType(NTN_SIMPLE), fUnion() {}
494 
495  UBool copyErrorTo(UErrorCode &status) const {
496  if (fType == NTN_ERROR) {
497  status = fUnion.errorCode;
498  return TRUE;
499  }
500  return FALSE;
501  }
502 
503  // To allow MacroProps to initialize empty instances:
504  friend struct impl::MacroProps;
505  friend class ScientificNotation;
506 
507  // To allow implementation to access internal types:
508  friend class impl::NumberFormatterImpl;
509  friend class impl::ScientificModifier;
510  friend class impl::ScientificHandler;
511 };
512 
522  public:
536  ScientificNotation withMinExponentDigits(int32_t minExponentDigits) const;
537 
551  ScientificNotation withExponentSignDisplay(UNumberSignDisplay exponentSignDisplay) const;
552 
553  private:
554  // Inherit constructor
555  using Notation::Notation;
556 
557  friend class Notation;
558 };
559 
560 // Reserve extra names in case they are added as classes in the future:
561 typedef Rounder DigitRounder;
562 
571 class U_I18N_API Rounder : public UMemory {
572 
573  public:
590  static Rounder unlimited();
591 
598  static FractionRounder integer();
599 
627  static FractionRounder fixedFraction(int32_t minMaxFractionPlaces);
628 
642  static FractionRounder minFraction(int32_t minFractionPlaces);
643 
654  static FractionRounder maxFraction(int32_t maxFractionPlaces);
655 
669  static FractionRounder minMaxFraction(int32_t minFractionPlaces, int32_t maxFractionPlaces);
670 
684  static DigitRounder fixedDigits(int32_t minMaxSignificantDigits);
685 
698  static DigitRounder minDigits(int32_t minSignificantDigits);
699 
708  static DigitRounder maxDigits(int32_t maxSignificantDigits);
709 
721  static DigitRounder minMaxDigits(int32_t minSignificantDigits, int32_t maxSignificantDigits);
722 
742  static IncrementRounder increment(double roundingIncrement);
743 
760  static CurrencyRounder currency(UCurrencyUsage currencyUsage);
761 
771  Rounder withMode(UNumberFormatRoundingMode roundingMode) const;
772 
773  private:
774  enum RounderType {
775  RND_BOGUS,
776  RND_NONE,
777  RND_FRACTION,
778  RND_SIGNIFICANT,
779  RND_FRACTION_SIGNIFICANT,
780  RND_INCREMENT,
781  RND_CURRENCY,
782  RND_PASS_THROUGH,
783  RND_ERROR
784  } fType;
785 
786  union RounderUnion {
788  // For RND_FRACTION, RND_SIGNIFICANT, and RND_FRACTION_SIGNIFICANT
789  int8_t fMinFrac;
790  int8_t fMaxFrac;
791  int8_t fMinSig;
792  int8_t fMaxSig;
793  } fracSig;
795  double fIncrement;
796  int32_t fMinFrac;
797  } increment; // For RND_INCREMENT
798  UCurrencyUsage currencyUsage; // For RND_CURRENCY
799  UErrorCode errorCode; // For RND_ERROR
800  } fUnion;
801 
804 
805  UNumberFormatRoundingMode fRoundingMode;
806 
807  Rounder(const RounderType &type, const RounderUnion &union_, UNumberFormatRoundingMode roundingMode)
808  : fType(type), fUnion(union_), fRoundingMode(roundingMode) {}
809 
810  Rounder(UErrorCode errorCode) : fType(RND_ERROR) {
811  fUnion.errorCode = errorCode;
812  }
813 
814  Rounder() : fType(RND_BOGUS) {}
815 
816  bool isBogus() const {
817  return fType == RND_BOGUS;
818  }
819 
820  UBool copyErrorTo(UErrorCode &status) const {
821  if (fType == RND_ERROR) {
822  status = fUnion.errorCode;
823  return TRUE;
824  }
825  return FALSE;
826  }
827 
828  // On the parent type so that this method can be called internally on Rounder instances.
829  Rounder withCurrency(const CurrencyUnit &currency, UErrorCode &status) const;
830 
832  void setLocaleData(const CurrencyUnit &currency, UErrorCode &status);
833 
834  void apply(impl::DecimalQuantity &value, UErrorCode &status) const;
835 
837  void apply(impl::DecimalQuantity &value, int32_t minInt, UErrorCode status);
838 
839  int32_t
840  chooseMultiplierAndApply(impl::DecimalQuantity &input, const impl::MultiplierProducer &producer,
841  UErrorCode &status);
842 
843  static FractionRounder constructFraction(int32_t minFrac, int32_t maxFrac);
844 
845  static Rounder constructSignificant(int32_t minSig, int32_t maxSig);
846 
847  static Rounder
848  constructFractionSignificant(const FractionRounder &base, int32_t minSig, int32_t maxSig);
849 
850  static IncrementRounder constructIncrement(double increment, int32_t minFrac);
851 
852  static CurrencyRounder constructCurrency(UCurrencyUsage usage);
853 
854  static Rounder constructPassThrough();
855 
856  // To allow MacroProps/MicroProps to initialize bogus instances:
857  friend struct impl::MacroProps;
858  friend struct impl::MicroProps;
859 
860  // To allow NumberFormatterImpl to access isBogus() and other internal methods:
861  friend class impl::NumberFormatterImpl;
862 
863  // To give access to apply() and chooseMultiplierAndApply():
864  friend class impl::MutablePatternModifier;
865  friend class impl::LongNameHandler;
866  friend class impl::ScientificHandler;
867  friend class impl::CompactHandler;
868 
869  // To allow child classes to call private methods:
870  friend class FractionRounder;
871  friend class CurrencyRounder;
872  friend class IncrementRounder;
873 };
874 
885  public:
902  Rounder withMinDigits(int32_t minSignificantDigits) const;
903 
921  Rounder withMaxDigits(int32_t maxSignificantDigits) const;
922 
923  private:
924  // Inherit constructor
925  using Rounder::Rounder;
926 
927  // To allow parent class to call this class's constructor:
928  friend class Rounder;
929 };
930 
941  public:
959  Rounder withCurrency(const CurrencyUnit &currency) const;
960 
961  private:
962  // Inherit constructor
963  using Rounder::Rounder;
964 
965  // To allow parent class to call this class's constructor:
966  friend class Rounder;
967 };
968 
979  public:
995  Rounder withMinFraction(int32_t minFrac) const;
996 
997  private:
998  // Inherit constructor
999  using Rounder::Rounder;
1000 
1001  // To allow parent class to call this class's constructor:
1002  friend class Rounder;
1003 };
1004 
1008 class U_I18N_API Grouper : public UMemory {
1009  public:
1013  static Grouper defaults();
1014 
1018  static Grouper minTwoDigits();
1019 
1023  static Grouper none();
1024 
1025  private:
1026  int8_t fGrouping1; // -3 means "bogus"; -2 means "needs locale data"; -1 means "no grouping"
1027  int8_t fGrouping2;
1028  bool fMin2;
1029 
1030  Grouper(int8_t grouping1, int8_t grouping2, bool min2)
1031  : fGrouping1(grouping1), fGrouping2(grouping2), fMin2(min2) {}
1032 
1033  Grouper() : fGrouping1(-3) {};
1034 
1035  bool isBogus() const {
1036  return fGrouping1 == -3;
1037  }
1038 
1040  void setLocaleData(const impl::ParsedPatternInfo &patternInfo);
1041 
1042  bool groupAtPosition(int32_t position, const impl::DecimalQuantity &value) const;
1043 
1044  // To allow MacroProps/MicroProps to initialize empty instances:
1045  friend struct impl::MacroProps;
1046  friend struct impl::MicroProps;
1047 
1048  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1049  friend class impl::NumberFormatterImpl;
1050 };
1051 
1062  public:
1075  static IntegerWidth zeroFillTo(int32_t minInt);
1076 
1088  IntegerWidth truncateAt(int32_t maxInt);
1089 
1090  private:
1091  union {
1092  struct {
1093  int8_t fMinInt;
1094  int8_t fMaxInt;
1095  } minMaxInt;
1096  UErrorCode errorCode;
1097  } fUnion;
1098  bool fHasError = false;
1099 
1100  IntegerWidth(int8_t minInt, int8_t maxInt);
1101 
1102  IntegerWidth(UErrorCode errorCode) { // NOLINT
1103  fUnion.errorCode = errorCode;
1104  fHasError = true;
1105  }
1106 
1107  IntegerWidth() { // NOLINT
1108  fUnion.minMaxInt.fMinInt = -1;
1109  }
1110 
1111  bool isBogus() const {
1112  return !fHasError && fUnion.minMaxInt.fMinInt == -1;
1113  }
1114 
1115  UBool copyErrorTo(UErrorCode &status) const {
1116  if (fHasError) {
1117  status = fUnion.errorCode;
1118  return TRUE;
1119  }
1120  return FALSE;
1121  }
1122 
1123  void apply(impl::DecimalQuantity &quantity, UErrorCode &status) const;
1124 
1125  // To allow MacroProps/MicroProps to initialize empty instances:
1126  friend struct impl::MacroProps;
1127  friend struct impl::MicroProps;
1128 
1129  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1130  friend class impl::NumberFormatterImpl;
1131 };
1132 
1133 namespace impl {
1134 
1141 static constexpr int32_t DEFAULT_THRESHOLD = 3;
1142 
1145  public:
1147  SymbolsWrapper() : fType(SYMPTR_NONE), fPtr{nullptr} {}
1148 
1150  SymbolsWrapper(const SymbolsWrapper &other);
1151 
1153  ~SymbolsWrapper();
1154 
1156  SymbolsWrapper &operator=(const SymbolsWrapper &other);
1157 
1162  void setTo(const DecimalFormatSymbols &dfs);
1163 
1168  void setTo(const NumberingSystem *ns);
1169 
1174  bool isDecimalFormatSymbols() const;
1175 
1180  bool isNumberingSystem() const;
1181 
1186  const DecimalFormatSymbols *getDecimalFormatSymbols() const;
1187 
1192  const NumberingSystem *getNumberingSystem() const;
1193 
1195  UBool copyErrorTo(UErrorCode &status) const {
1196  if (fType == SYMPTR_DFS && fPtr.dfs == nullptr) {
1197  status = U_MEMORY_ALLOCATION_ERROR;
1198  return TRUE;
1199  } else if (fType == SYMPTR_NS && fPtr.ns == nullptr) {
1200  status = U_MEMORY_ALLOCATION_ERROR;
1201  return TRUE;
1202  }
1203  return FALSE;
1204  }
1205 
1206  private:
1207  enum SymbolsPointerType {
1208  SYMPTR_NONE, SYMPTR_DFS, SYMPTR_NS
1209  } fType;
1210 
1211  union {
1212  const DecimalFormatSymbols *dfs;
1213  const NumberingSystem *ns;
1214  } fPtr;
1215 
1216  void doCopyFrom(const SymbolsWrapper &other);
1217 
1218  void doCleanup();
1219 };
1220 
1222 class U_I18N_API Padder : public UMemory {
1223  public:
1225  static Padder none();
1226 
1228  static Padder codePoints(UChar32 cp, int32_t targetWidth, UNumberFormatPadPosition position);
1229 
1230  private:
1231  UChar32 fWidth; // -3 = error; -2 = bogus; -1 = no padding
1232  union {
1233  struct {
1234  int32_t fCp;
1235  UNumberFormatPadPosition fPosition;
1236  } padding;
1237  UErrorCode errorCode;
1238  } fUnion;
1239 
1240  Padder(UChar32 cp, int32_t width, UNumberFormatPadPosition position);
1241 
1242  Padder(int32_t width);
1243 
1244  Padder(UErrorCode errorCode) : fWidth(-3) { // NOLINT
1245  fUnion.errorCode = errorCode;
1246  }
1247 
1248  Padder() : fWidth(-2) {} // NOLINT
1249 
1250  bool isBogus() const {
1251  return fWidth == -2;
1252  }
1253 
1254  UBool copyErrorTo(UErrorCode &status) const {
1255  if (fWidth == -3) {
1256  status = fUnion.errorCode;
1257  return TRUE;
1258  }
1259  return FALSE;
1260  }
1261 
1262  bool isValid() const {
1263  return fWidth > 0;
1264  }
1265 
1266  int32_t padAndApply(const impl::Modifier &mod1, const impl::Modifier &mod2,
1267  impl::NumberStringBuilder &string, int32_t leftIndex, int32_t rightIndex,
1268  UErrorCode &status) const;
1269 
1270  // To allow MacroProps/MicroProps to initialize empty instances:
1271  friend struct MacroProps;
1272  friend struct MicroProps;
1273 
1274  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1275  friend class impl::NumberFormatterImpl;
1276 };
1277 
1279 struct U_I18N_API MacroProps : public UMemory {
1282 
1284  MeasureUnit unit; // = NoUnit::base();
1285 
1287  Rounder rounder; // = Rounder(); (bogus)
1288 
1290  Grouper grouper; // = Grouper(); (bogus)
1291 
1293  Padder padder; // = Padder(); (bogus)
1294 
1296  IntegerWidth integerWidth; // = IntegerWidth(); (bogus)
1297 
1300 
1301  // UNUM_XYZ_COUNT denotes null (bogus) values.
1302 
1305 
1308 
1311 
1313  PluralRules *rules = nullptr; // no ownership
1314 
1316  int32_t threshold = DEFAULT_THRESHOLD;
1317  Locale locale;
1318 
1323  bool copyErrorTo(UErrorCode &status) const {
1324  return notation.copyErrorTo(status) || rounder.copyErrorTo(status) ||
1325  padder.copyErrorTo(status) || integerWidth.copyErrorTo(status) ||
1326  symbols.copyErrorTo(status);
1327  }
1328 };
1329 
1330 } // namespace impl
1331 
1336 template<typename Derived>
1338  public:
1367  Derived notation(const Notation &notation) const;
1368 
1411  Derived unit(const icu::MeasureUnit &unit) const;
1412 
1424  Derived adoptUnit(const icu::MeasureUnit *unit) const;
1425 
1457  Derived rounding(const Rounder &rounder) const;
1458 
1459 #ifndef U_HIDE_INTERNAL_API
1460 
1490  Derived grouping(const Grouper &grouper) const;
1491 
1492 #endif /* U_HIDE_INTERNAL_API */
1493 
1518  Derived integerWidth(const IntegerWidth &style) const;
1519 
1560  Derived symbols(const DecimalFormatSymbols &symbols) const;
1561 
1595  Derived adoptSymbols(const NumberingSystem *symbols) const;
1596 
1622  Derived unitWidth(const UNumberUnitWidth &width) const;
1623 
1650  Derived sign(const UNumberSignDisplay &width) const;
1651 
1678  Derived decimal(const UNumberDecimalSeparatorDisplay &width) const;
1679 
1680 #ifndef U_HIDE_INTERNAL_API
1681 
1687  Derived padding(const impl::Padder &padder) const;
1688 
1695  Derived threshold(int32_t threshold) const;
1696 
1697 #endif /* U_HIDE_INTERNAL_API */
1698 
1705  UBool copyErrorTo(UErrorCode &outErrorCode) const {
1706  if (U_FAILURE(outErrorCode)) {
1707  // Do not overwrite the older error code
1708  return TRUE;
1709  }
1710  fMacros.copyErrorTo(outErrorCode);
1711  return U_FAILURE(outErrorCode);
1712  }
1713 
1714  protected:
1715  impl::MacroProps fMacros;
1716 
1717  private:
1718  // Don't construct me directly! Use (Un)LocalizedNumberFormatter.
1719  NumberFormatterSettings() = default;
1720 
1721  friend class LocalizedNumberFormatter;
1722  friend class UnlocalizedNumberFormatter;
1723 };
1724 
1732  : public NumberFormatterSettings<UnlocalizedNumberFormatter>, public UMemory {
1733 
1734  public:
1751  LocalizedNumberFormatter locale(const icu::Locale &locale) const;
1752 
1753  // Make default copy constructor call the NumberFormatterSettings copy constructor.
1759  static_cast<const NumberFormatterSettings<UnlocalizedNumberFormatter> &>(other)) {}
1760 
1761  private:
1762  UnlocalizedNumberFormatter() = default;
1763 
1764  explicit UnlocalizedNumberFormatter(
1766 
1767  // To give the fluent setters access to this class's constructor:
1768  friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
1769 
1770  // To give NumberFormatter::with() access to this class's constructor:
1771  friend class NumberFormatter;
1772 };
1773 
1781  : public NumberFormatterSettings<LocalizedNumberFormatter>, public UMemory {
1782  public:
1794  FormattedNumber formatInt(int64_t value, UErrorCode &status) const;
1795 
1807  FormattedNumber formatDouble(double value, UErrorCode &status) const;
1808 
1823  FormattedNumber formatDecimal(StringPiece value, UErrorCode &status) const;
1824 
1825  // Make default copy constructor call the NumberFormatterSettings copy constructor.
1831  static_cast<const NumberFormatterSettings<LocalizedNumberFormatter> &>(other)) {}
1832 
1838 
1839  private:
1840  const impl::NumberFormatterImpl* fCompiled {nullptr};
1841  char fUnsafeCallCount[8] {}; // internally cast to u_atomic_int32_t
1842 
1843  LocalizedNumberFormatter() = default;
1844 
1846 
1847  LocalizedNumberFormatter(const impl::MacroProps &macros, const Locale &locale);
1848 
1860  FormattedNumber formatImpl(impl::NumberFormatterResults *results, UErrorCode &status) const;
1861 
1862  // To give the fluent setters access to this class's constructor:
1863  friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
1864  friend class NumberFormatterSettings<LocalizedNumberFormatter>;
1865 
1866  // To give UnlocalizedNumberFormatter::locale() access to this class's constructor:
1867  friend class UnlocalizedNumberFormatter;
1868 };
1869 
1877  public:
1884  UnicodeString toString() const;
1885 
1895  Appendable &appendTo(Appendable &appendable);
1896 
1916  void populateFieldPosition(FieldPosition &fieldPosition, UErrorCode &status);
1917 
1932  void populateFieldPositionIterator(FieldPositionIterator &iterator, UErrorCode &status);
1933 
1938  ~FormattedNumber();
1939 
1940  private:
1941  // Can't use LocalPointer because NumberFormatterResults is forward-declared
1942  const impl::NumberFormatterResults *fResults;
1943 
1944  // Error code for the terminal methods
1945  UErrorCode fErrorCode;
1946 
1947  explicit FormattedNumber(impl::NumberFormatterResults *results)
1948  : fResults(results), fErrorCode(U_ZERO_ERROR) {};
1949 
1950  explicit FormattedNumber(UErrorCode errorCode)
1951  : fResults(nullptr), fErrorCode(errorCode) {};
1952 
1953  // To give LocalizedNumberFormatter format methods access to this class's constructor:
1954  friend class LocalizedNumberFormatter;
1955 };
1956 
1963  public:
1971  static UnlocalizedNumberFormatter with();
1972 
1982  static LocalizedNumberFormatter withLocale(const Locale &locale);
1983 
1988  NumberFormatter() = delete;
1989 };
1990 
1991 } // namespace number
1993 
1994 #endif // U_HIDE_DRAFT_API
1995 
1996 #endif // __NUMBERFORMATTER_H__
1997 
1998 #endif /* #if !UCONFIG_NO_FORMATTING */
This class represents the set of symbols needed by DecimalFormat to format numbers.
Definition: dcfmtsym.h:88
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:275
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.
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:688
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.
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.
#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:131
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:396
UBool copyErrorTo(UErrorCode &outErrorCode) const
Sets the UErrorCode if an error occurred in the fluent chain.
UNumberUnitWidth
An enum declaring how to render units, including currencies.
#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:304
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:132
UNumberCompactStyle
Constants for specifying short or long format.
Definition: unum.h:315
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...
Print an abbreviated version of the unit name.
Show the minus sign on negative numbers and the plus sign on positive numbers.
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.
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.
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
bool copyErrorTo(UErrorCode &status) const
Check all members for errors.
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.
UBool copyErrorTo(UErrorCode &status) const
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:188