ICU 61.1  61.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 
60 public:
61 
72  static CompactDecimalFormat* U_EXPORT2 createInstance(
73  const Locale& inLocale, UNumberCompactStyle style, UErrorCode& status);
74 
82 
87  virtual ~CompactDecimalFormat();
88 
96 
104  virtual Format* clone() const;
105 
114  virtual UBool operator==(const Format& other) const;
115 
116 
117  using DecimalFormat::format;
118 
130  virtual UnicodeString& format(double number,
131  UnicodeString& appendTo,
132  FieldPosition& pos) const;
133 
146  virtual UnicodeString& format(double number,
147  UnicodeString& appendTo,
148  FieldPosition& pos,
149  UErrorCode &status) const;
150 
165  virtual UnicodeString& format(double number,
166  UnicodeString& appendTo,
167  FieldPositionIterator* posIter,
168  UErrorCode& status) const;
169 
181  virtual UnicodeString& format(int32_t number,
182  UnicodeString& appendTo,
183  FieldPosition& pos) const;
184 
196  virtual UnicodeString& format(int32_t number,
197  UnicodeString& appendTo,
198  FieldPosition& pos,
199  UErrorCode &status) const;
200 
215  virtual UnicodeString& format(int32_t number,
216  UnicodeString& appendTo,
217  FieldPositionIterator* posIter,
218  UErrorCode& status) const;
219 
231  virtual UnicodeString& format(int64_t number,
232  UnicodeString& appendTo,
233  FieldPosition& pos) const;
234 
246  virtual UnicodeString& format(int64_t number,
247  UnicodeString& appendTo,
248  FieldPosition& pos,
249  UErrorCode &status) const;
250 
265  virtual UnicodeString& format(int64_t number,
266  UnicodeString& appendTo,
267  FieldPositionIterator* posIter,
268  UErrorCode& status) const;
269 
286  virtual UnicodeString& format(StringPiece number,
287  UnicodeString& appendTo,
288  FieldPositionIterator* posIter,
289  UErrorCode& status) const;
290 
306  virtual UnicodeString& format(const DigitList &number,
307  UnicodeString& appendTo,
308  FieldPositionIterator* posIter,
309  UErrorCode& status) const;
310 
326  virtual UnicodeString& format(const DigitList &number,
327  UnicodeString& appendTo,
328  FieldPosition& pos,
329  UErrorCode& status) const;
330 
340  virtual void parse(const UnicodeString& text,
341  Formattable& result,
342  ParsePosition& parsePosition) const;
343 
353  virtual void parse(const UnicodeString& text,
354  Formattable& result,
355  UErrorCode& status) const;
356 
377  virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
378  ParsePosition& pos) const;
379 
391  static UClassID U_EXPORT2 getStaticClassID();
392 
404  virtual UClassID getDynamicClassID() const;
405 
406 private:
407 
408  const UHashtable* _unitsByVariant;
409  const double* _divisors;
410  PluralRules* _pluralRules;
411 
412  // Default constructor not implemented.
413  CompactDecimalFormat(const DecimalFormat &, const UHashtable* unitsByVariant, const double* divisors, PluralRules* pluralRules);
414 
415  UBool eqHelper(const CompactDecimalFormat& that) const;
416 };
417 
419 
420 #endif /* #if !UCONFIG_NO_FORMATTING */
421 
422 #endif // __COMPACT_DECIMAL_FORMAT_H__
423 //eof
Base class for all formats.
Definition: format.h:96
DecimalFormat & operator=(const DecimalFormat &rhs)
Assignment operator.
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.
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:197
#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:137
FieldPositionIterator returns the field ids and their start/limit positions generated by a call to Fo...
Definition: fpositer.h:62
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
virtual CurrencyAmount * parseCurrency(const UnicodeString &text, ParsePosition &pos) const
Parses text from the given string as a currency amount.
virtual UnicodeString & format(double number, UnicodeString &appendTo, FieldPosition &pos) const
Format a double or long number using base-10 representation.
virtual Format * clone(void) const
Clone this Format object polymorphically.
static UClassID getStaticClassID(void)
Return the class ID for this class.
virtual void parse(const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const
Parse the given string using this object's choices.
#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
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
virtual UBool operator==(const Format &other) const
Return true if the given Format objects are semantically equal.
C++ API: Compatibility APIs for decimal formatting.
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:286
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