ICU 53.1  53.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
compactdecimalformat.h
Go to the documentation of this file.
1 /*
2 ********************************************************************************
3 * Copyright (C) 2012-2014, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ********************************************************************************
6 *
7 * File COMPACTDECIMALFORMAT.H
8 ********************************************************************************
9 */
10 
11 #ifndef __COMPACT_DECIMAL_FORMAT_H__
12 #define __COMPACT_DECIMAL_FORMAT_H__
13 
14 #include "unicode/utypes.h"
20 #if !UCONFIG_NO_FORMATTING
21 
22 #include "unicode/decimfmt.h"
23 
24 struct UHashtable;
25 
27 
28 class PluralRules;
29 
53 public:
54 
62  static CompactDecimalFormat* U_EXPORT2 createInstance(
63  const Locale& inLocale, UNumberCompactStyle style, UErrorCode& status);
64 
72 
77  virtual ~CompactDecimalFormat();
78 
86 
94  virtual Format* clone() const;
95 
104  virtual UBool operator==(const Format& other) const;
105 
106 
107  using DecimalFormat::format;
108 
120  virtual UnicodeString& format(double number,
121  UnicodeString& appendTo,
122  FieldPosition& pos) const;
123 
138  virtual UnicodeString& format(double number,
139  UnicodeString& appendTo,
140  FieldPositionIterator* posIter,
141  UErrorCode& status) const;
142 
154  virtual UnicodeString& format(int64_t number,
155  UnicodeString& appendTo,
156  FieldPosition& pos) const;
157 
172  virtual UnicodeString& format(int64_t number,
173  UnicodeString& appendTo,
174  FieldPositionIterator* posIter,
175  UErrorCode& status) const;
176 
193  virtual UnicodeString& format(const StringPiece &number,
194  UnicodeString& appendTo,
195  FieldPositionIterator* posIter,
196  UErrorCode& status) const;
197 
213  virtual UnicodeString& format(const DigitList &number,
214  UnicodeString& appendTo,
215  FieldPositionIterator* posIter,
216  UErrorCode& status) const;
217 
233  virtual UnicodeString& format(const DigitList &number,
234  UnicodeString& appendTo,
235  FieldPosition& pos,
236  UErrorCode& status) const;
237 
247  virtual void parse(const UnicodeString& text,
248  Formattable& result,
249  ParsePosition& parsePosition) const;
250 
260  virtual void parse(const UnicodeString& text,
261  Formattable& result,
262  UErrorCode& status) const;
263 
284  virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
285  ParsePosition& pos) const;
286 
298  static UClassID U_EXPORT2 getStaticClassID();
299 
311  virtual UClassID getDynamicClassID() const;
312 
313 private:
314 
315  const UHashtable* _unitsByVariant;
316  const double* _divisors;
317  PluralRules* _pluralRules;
318 
319  // Default constructor not implemented.
320  CompactDecimalFormat(const DecimalFormat &, const UHashtable* unitsByVariant, const double* divisors, PluralRules* pluralRules);
321 
322  UBool eqHelper(const CompactDecimalFormat& that) const;
323 };
324 
326 
327 #endif /* #if !UCONFIG_NO_FORMATTING */
328 
329 #endif // __COMPACT_DECIMAL_FORMAT_H__
330 //eof
Base class for all formats.
Definition: format.h:94
DecimalFormat & operator=(const DecimalFormat &rhs)
Assignment operator.
DecimalFormat is a concrete subclass of NumberFormat that formats decimal numbers.
Definition: decimfmt.h:663
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
static NumberFormat * createInstance(UErrorCode &)
Returns the default number format for the current default locale.
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:191
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:358
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
FieldPositionIterator returns the field ids and their start/limit positions generated by a call to Fo...
Definition: fpositer.h:53
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:130
UNumberCompactStyle
Constants for specifying short or long format.
Definition: unum.h:268
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:106
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:47
virtual UBool operator==(const Format &other) const
Return true if the given Format objects are semantically equal.
C++ API: Formats decimal numbers.
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:245
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:66
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:52
A currency together with a numeric amount, such as 200 USD.
Definition: curramt.h:35
int8_t UBool
The ICU boolean type.
Definition: umachine.h:200
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185