ICU 59.1  59.1
compactdecimalformat.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ********************************************************************************
5 * Copyright (C) 2012-2016, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 ********************************************************************************
8 *
9 * File COMPACTDECIMALFORMAT.H
10 ********************************************************************************
11 */
12 
13 #ifndef __COMPACT_DECIMAL_FORMAT_H__
14 #define __COMPACT_DECIMAL_FORMAT_H__
15 
16 #include "unicode/utypes.h"
22 #if !UCONFIG_NO_FORMATTING
23 
24 #include "unicode/decimfmt.h"
25 
26 struct UHashtable;
27 
29 
30 class PluralRules;
31 
55 public:
56 
64  static CompactDecimalFormat* U_EXPORT2 createInstance(
65  const Locale& inLocale, UNumberCompactStyle style, UErrorCode& status);
66 
74 
79  virtual ~CompactDecimalFormat();
80 
88 
96  virtual Format* clone() const;
97 
106  virtual UBool operator==(const Format& other) const;
107 
108 
109  using DecimalFormat::format;
110 
122  virtual UnicodeString& format(double number,
123  UnicodeString& appendTo,
124  FieldPosition& pos) const;
125 
138  virtual UnicodeString& format(double number,
139  UnicodeString& appendTo,
140  FieldPosition& pos,
141  UErrorCode &status) const;
142 
157  virtual UnicodeString& format(double number,
158  UnicodeString& appendTo,
159  FieldPositionIterator* posIter,
160  UErrorCode& status) const;
161 
173  virtual UnicodeString& format(int32_t number,
174  UnicodeString& appendTo,
175  FieldPosition& pos) const;
176 
188  virtual UnicodeString& format(int32_t number,
189  UnicodeString& appendTo,
190  FieldPosition& pos,
191  UErrorCode &status) const;
192 
207  virtual UnicodeString& format(int32_t number,
208  UnicodeString& appendTo,
209  FieldPositionIterator* posIter,
210  UErrorCode& status) const;
211 
223  virtual UnicodeString& format(int64_t number,
224  UnicodeString& appendTo,
225  FieldPosition& pos) const;
226 
238  virtual UnicodeString& format(int64_t number,
239  UnicodeString& appendTo,
240  FieldPosition& pos,
241  UErrorCode &status) const;
242 
257  virtual UnicodeString& format(int64_t number,
258  UnicodeString& appendTo,
259  FieldPositionIterator* posIter,
260  UErrorCode& status) const;
261 
278  virtual UnicodeString& format(StringPiece number,
279  UnicodeString& appendTo,
280  FieldPositionIterator* posIter,
281  UErrorCode& status) const;
282 
298  virtual UnicodeString& format(const DigitList &number,
299  UnicodeString& appendTo,
300  FieldPositionIterator* posIter,
301  UErrorCode& status) const;
302 
318  virtual UnicodeString& format(const DigitList &number,
319  UnicodeString& appendTo,
320  FieldPosition& pos,
321  UErrorCode& status) const;
322 
332  virtual void parse(const UnicodeString& text,
333  Formattable& result,
334  ParsePosition& parsePosition) const;
335 
345  virtual void parse(const UnicodeString& text,
346  Formattable& result,
347  UErrorCode& status) const;
348 
369  virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
370  ParsePosition& pos) const;
371 
383  static UClassID U_EXPORT2 getStaticClassID();
384 
396  virtual UClassID getDynamicClassID() const;
397 
398 private:
399 
400  const UHashtable* _unitsByVariant;
401  const double* _divisors;
402  PluralRules* _pluralRules;
403 
404  // Default constructor not implemented.
405  CompactDecimalFormat(const DecimalFormat &, const UHashtable* unitsByVariant, const double* divisors, PluralRules* pluralRules);
406 
407  UBool eqHelper(const CompactDecimalFormat& that) const;
408 };
409 
411 
412 #endif /* #if !UCONFIG_NO_FORMATTING */
413 
414 #endif // __COMPACT_DECIMAL_FORMAT_H__
415 //eof
Base class for all formats.
Definition: format.h:96
DecimalFormat & operator=(const DecimalFormat &rhs)
Assignment operator.
DecimalFormat is a concrete subclass of NumberFormat that formats decimal numbers.
Definition: decimfmt.h:669
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:93
static NumberFormat * createInstance(UErrorCode &)
Create a default style NumberFormat for the current default locale.
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:197
virtual UnicodeString & format(double number, UnicodeString &appendTo, FieldPosition &pos) const
Format a double or long number using base-10 representation.
The CompactDecimalFormat produces abbreviated numbers, suitable for display in environments will limi...
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:360
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
FieldPositionIterator returns the field ids and their start/limit positions generated by a call to Fo...
Definition: fpositer.h:55
virtual Format * clone(void) const
Clone this Format object polymorphically.
virtual void parse(const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const
Parse the given string using this object's choices.
static UClassID getStaticClassID(void)
Return the class ID for this class.
#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:310
virtual CurrencyAmount * parseCurrency(const UnicodeString &text, ParsePosition &pos) const
Parses text from the given string as a currency amount.
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
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:49
C++ API: Formats decimal numbers.
virtual UBool operator==(const Format &other) const
Return true if the given Format objects are semantically equal.
Basic definitions for ICU, for both C and C++ APIs.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:68
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:54
A currency together with a numeric amount, such as 200 USD.
Definition: curramt.h:37
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:188