1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 4 ********************************************************************** 5 * Copyright (c) 2004-2016, International Business Machines 6 * Corporation and others. All Rights Reserved. 7 ********************************************************************** 9 * Created: April 20, 2004 11 ********************************************************************** 13 #ifndef MEASUREFORMAT_H 14 #define MEASUREFORMAT_H 18 #if U_SHOW_CPLUSPLUS_API 20 #if !UCONFIG_NO_FORMATTING 40 // Wide, short, and narrow must be first and in this order. 66 #ifndef U_HIDE_DEPRECATED_API 72 #endif// U_HIDE_DEPRECATED_API 83 classMeasureFormatCacheData;
84 classSharedNumberFormat;
85 classSharedPluralRules;
86 classQuantityFormatter;
169 #ifndef U_FORCE_HIDE_DRAFT_API 180 #endif// U_FORCE_HIDE_DRAFT_API 200 int32_t measureCount,
298 #ifndef U_HIDE_INTERNAL_API 357 #endif/* U_HIDE_INTERNAL_API */ 360 const MeasureFormatCacheData *cache;
361 const SharedNumberFormat *numberFormat;
362 const SharedPluralRules *pluralRules;
365 // Declared outside of MeasureFormatSharedData because ListFormatter 366 // objects are relatively cheap to copy; therefore, they don't need to be 367 // shared across instances. 379 int32_t measureCount,
385 constFormattable *hms,
// always length 3: [0] is hour; [1] is 386 // minute; [2] is second. 387 int32_t bitMap,
// 1=hour set, 2=minute set, 4=second set 394 #endif// #if !UCONFIG_NO_FORMATTING 396 #endif/* U_SHOW_CPLUSPLUS_API */ 398 #endif// #ifndef MEASUREFORMAT_H FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Base class for all formats.
U_I18N_API UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
Formats an object to produce a string.
virtual U_I18N_API void parseObject(const UnicodeString &source, Formattable &result, ParsePosition &parse_pos) const =0
Parse a string to produce an object.
Formattable objects can be passed to the Format class or its subclasses for formatting.
An immutable class for formatting a list, using data from CLDR (or supplied separately).
A Locale object represents a specific geographical, political, or cultural region.
static MeasureFormat * createCurrencyFormat(UErrorCode &ec)
Return a formatter for CurrencyAmount objects in the default locale.
virtual void parseObject(const UnicodeString &source, Formattable &reslt, ParsePosition &pos) const override
Parse a string to produce an object.
MeasureFormat & operator=(const MeasureFormat &rhs)
Assignment operator.
MeasureFormat(const Locale &locale, UMeasureFormatWidth width, UErrorCode &status)
Constructor.
void initMeasureFormat(const Locale &locale, UMeasureFormatWidth width, NumberFormat *nfToAdopt, UErrorCode &status)
ICU use only.
UnicodeString & formatMeasurePerUnit(const Measure &measure, const MeasureUnit &perUnit, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Formats a single measure per unit.
const NumberFormat & getNumberFormatInternal() const
ICU use only.
MeasureFormat(const MeasureFormat &other)
Copy constructor.
static UClassID getStaticClassID()
Return the class ID for this class.
const NumberFormat & getCurrencyFormatInternal() const
ICU use only.
virtual ~MeasureFormat()
Destructor.
UnicodeString getUnitDisplayName(const MeasureUnit &unit, UErrorCode &status) const
Gets the display name of the specified MeasureUnit corresponding to the current locale and format wid...
const char * getLocaleID(UErrorCode &status) const
ICU use only.
virtual UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const override
Formats object to produce a string.
virtual MeasureFormat * clone() const override
Clones this object polymorphically.
static MeasureFormat * createCurrencyFormat(const Locale &locale, UErrorCode &ec)
Return a formatter for CurrencyAmount objects in the given locale.
const PluralRules & getPluralRules() const
ICU use only.
virtual UClassID getDynamicClassID() const override
Returns a unique class ID POLYMORPHICALLY.
UBool setMeasureFormatLocale(const Locale &locale, UErrorCode &status)
ICU use only.
MeasureFormat()
Default constructor.
virtual bool operator==(const Format &other) const override
Return true if given Format objects are semantically equal.
void adoptNumberFormat(NumberFormat *nfToAdopt, UErrorCode &status)
ICU use only.
UnicodeString & formatMeasures(const Measure *measures, int32_t measureCount, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Formats measure objects to produce a string.
Locale getLocale(UErrorCode &status) const
ICU use only.
MeasureFormat(const Locale &locale, UMeasureFormatWidth width, NumberFormat *nfToAdopt, UErrorCode &status)
Constructor.
A unit such as length, mass, volume, currency, etc.
An amount of a specified unit, consisting of a number and a Unit.
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Defines rules for mapping non-negative numeric values onto a small set of keywords.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
C++ API: Base class for all formats.
UMeasureFormatWidth
Constants for various widths.
@ UMEASFMT_WIDTH_NARROW
Use symbols for measure units when possible.
@ UMEASFMT_WIDTH_WIDE
Spell out measure units.
@ UMEASFMT_WIDTH_COUNT
One more than the highest normal UMeasureFormatWidth value.
@ UMEASFMT_WIDTH_NUMERIC
Completely omit measure units when possible.
@ UMEASFMT_WIDTH_SHORT
Abbreviate measure units.
int8_t UBool
The ICU boolean type, a signed-byte integer.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.