Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: source/i18n/unicode/compactdecimalformat.h

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/i18n/unicode/coll.h ('k') | source/i18n/unicode/currunit.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ******************************************************************************** 2 ********************************************************************************
3 * Copyright (C) 2012-2013, International Business Machines 3 * Copyright (C) 2012-2014, International Business Machines
4 * Corporation and others. All Rights Reserved. 4 * Corporation and others. All Rights Reserved.
5 ******************************************************************************** 5 ********************************************************************************
6 * 6 *
7 * File COMPACTDECIMALFORMAT.H 7 * File COMPACTDECIMALFORMAT.H
8 ******************************************************************************** 8 ********************************************************************************
9 */ 9 */
10 10
11 #ifndef __COMPACT_DECIMAL_FORMAT_H__ 11 #ifndef __COMPACT_DECIMAL_FORMAT_H__
12 #define __COMPACT_DECIMAL_FORMAT_H__ 12 #define __COMPACT_DECIMAL_FORMAT_H__
13 13
14 #include "unicode/utypes.h" 14 #include "unicode/utypes.h"
15 /** 15 /**
16 * \file 16 * \file
17 * \brief C++ API: Formats decimal numbers in compact form. 17 * \brief C++ API: Formats decimal numbers in compact form.
18 */ 18 */
19 19
20 #if !UCONFIG_NO_FORMATTING 20 #if !UCONFIG_NO_FORMATTING
21 #ifndef U_HIDE_DRAFT_API
22 21
23 #include "unicode/decimfmt.h" 22 #include "unicode/decimfmt.h"
24 23
25 struct UHashtable; 24 struct UHashtable;
26 25
27 U_NAMESPACE_BEGIN 26 U_NAMESPACE_BEGIN
28 27
29 class PluralRules; 28 class PluralRules;
30 29
31 /** 30 /**
32 * The CompactDecimalFormat produces abbreviated numbers, suitable for display i n 31 * The CompactDecimalFormat produces abbreviated numbers, suitable for display i n
33 * environments will limited real estate. For example, 'Hits: 1.2B' instead of 32 * environments will limited real estate. For example, 'Hits: 1.2B' instead of
34 * 'Hits: 1,200,000,000'. The format will be appropriate for the given language, 33 * 'Hits: 1,200,000,000'. The format will be appropriate for the given language,
35 * such as "1,2 Mrd." for German. 34 * such as "1,2 Mrd." for German.
36 * <p> 35 * <p>
37 * For numbers under 1000 trillion (under 10^15, such as 123,456,789,012,345), 36 * For numbers under 1000 trillion (under 10^15, such as 123,456,789,012,345),
38 * the result will be short for supported languages. However, the result may 37 * the result will be short for supported languages. However, the result may
39 * sometimes exceed 7 characters, such as when there are combining marks or thin 38 * sometimes exceed 7 characters, such as when there are combining marks or thin
40 * characters. In such cases, the visual width in fonts should still be short. 39 * characters. In such cases, the visual width in fonts should still be short.
41 * <p> 40 * <p>
42 * By default, there are 3 significant digits. After creation, if more than 41 * By default, there are 3 significant digits. After creation, if more than
43 * three significant digits are set (with setMaximumSignificantDigits), or if a 42 * three significant digits are set (with setMaximumSignificantDigits), or if a
44 * fixed number of digits are set (with setMaximumIntegerDigits or 43 * fixed number of digits are set (with setMaximumIntegerDigits or
45 * setMaximumFractionDigits), then result may be wider. 44 * setMaximumFractionDigits), then result may be wider.
46 * <p> 45 * <p>
47 * At this time, parsing is not supported, and will produce a U_UNSUPPORTED_ERRO R. 46 * At this time, parsing is not supported, and will produce a U_UNSUPPORTED_ERRO R.
48 * Resetting the pattern prefixes or suffixes is not supported; the method calls 47 * Resetting the pattern prefixes or suffixes is not supported; the method calls
49 * are ignored. 48 * are ignored.
50 * <p> 49 * <p>
51 * @draft ICU 51 50 * @stable ICU 51
52 */ 51 */
53 class U_I18N_API CompactDecimalFormat : public DecimalFormat { 52 class U_I18N_API CompactDecimalFormat : public DecimalFormat {
54 public: 53 public:
55 54
56 /** 55 /**
57 * Returns a compact decimal instance for specified locale. 56 * Returns a compact decimal instance for specified locale.
58 * @param inLocale the given locale. 57 * @param inLocale the given locale.
59 * @param style whether to use short or long style. 58 * @param style whether to use short or long style.
60 * @param status error code returned here. 59 * @param status error code returned here.
61 * @draft ICU 51 60 * @stable ICU 51
62 */ 61 */
63 static CompactDecimalFormat* U_EXPORT2 createInstance( 62 static CompactDecimalFormat* U_EXPORT2 createInstance(
64 const Locale& inLocale, UNumberCompactStyle style, UErrorCode& status) ; 63 const Locale& inLocale, UNumberCompactStyle style, UErrorCode& status) ;
65 64
66 /** 65 /**
67 * Copy constructor. 66 * Copy constructor.
68 * 67 *
69 * @param source the DecimalFormat object to be copied from. 68 * @param source the DecimalFormat object to be copied from.
70 * @draft ICU 51 69 * @stable ICU 51
71 */ 70 */
72 CompactDecimalFormat(const CompactDecimalFormat& source); 71 CompactDecimalFormat(const CompactDecimalFormat& source);
73 72
74 /** 73 /**
75 * Destructor. 74 * Destructor.
76 * @draft ICU 51 75 * @stable ICU 51
77 */ 76 */
78 virtual ~CompactDecimalFormat(); 77 virtual ~CompactDecimalFormat();
79 78
80 /** 79 /**
81 * Assignment operator. 80 * Assignment operator.
82 * 81 *
83 * @param rhs the DecimalFormat object to be copied. 82 * @param rhs the DecimalFormat object to be copied.
84 * @draft ICU 51 83 * @stable ICU 51
85 */ 84 */
86 CompactDecimalFormat& operator=(const CompactDecimalFormat& rhs); 85 CompactDecimalFormat& operator=(const CompactDecimalFormat& rhs);
87 86
88 /** 87 /**
89 * Clone this Format object polymorphically. The caller owns the 88 * Clone this Format object polymorphically. The caller owns the
90 * result and should delete it when done. 89 * result and should delete it when done.
91 * 90 *
92 * @return a polymorphic copy of this CompactDecimalFormat. 91 * @return a polymorphic copy of this CompactDecimalFormat.
93 * @draft ICU 51 92 * @stable ICU 51
94 */ 93 */
95 virtual Format* clone() const; 94 virtual Format* clone() const;
96 95
97 /** 96 /**
98 * Return TRUE if the given Format objects are semantically equal. 97 * Return TRUE if the given Format objects are semantically equal.
99 * Objects of different subclasses are considered unequal. 98 * Objects of different subclasses are considered unequal.
100 * 99 *
101 * @param other the object to be compared with. 100 * @param other the object to be compared with.
102 * @return TRUE if the given Format objects are semantically equal. 101 * @return TRUE if the given Format objects are semantically equal.
103 * @draft ICU 51 102 * @stable ICU 51
104 */ 103 */
105 virtual UBool operator==(const Format& other) const; 104 virtual UBool operator==(const Format& other) const;
106 105
107 106
108 using DecimalFormat::format; 107 using DecimalFormat::format;
109 108
110 /** 109 /**
111 * Format a double or long number using base-10 representation. 110 * Format a double or long number using base-10 representation.
112 * 111 *
113 * @param number The value to be formatted. 112 * @param number The value to be formatted.
114 * @param appendTo Output parameter to receive result. 113 * @param appendTo Output parameter to receive result.
115 * Result is appended to existing contents. 114 * Result is appended to existing contents.
116 * @param pos On input: an alignment field, if desired. 115 * @param pos On input: an alignment field, if desired.
117 * On output: the offsets of the alignment field. 116 * On output: the offsets of the alignment field.
118 * @return Reference to 'appendTo' parameter. 117 * @return Reference to 'appendTo' parameter.
119 * @draft ICU 51 118 * @stable ICU 51
120 */ 119 */
121 virtual UnicodeString& format(double number, 120 virtual UnicodeString& format(double number,
122 UnicodeString& appendTo, 121 UnicodeString& appendTo,
123 FieldPosition& pos) const; 122 FieldPosition& pos) const;
124 123
125 /** 124 /**
126 * Format a double or long number using base-10 representation. 125 * Format a double or long number using base-10 representation.
127 * Currently sets status to U_UNSUPPORTED_ERROR. 126 * Currently sets status to U_UNSUPPORTED_ERROR.
128 * 127 *
129 * @param number The value to be formatted. 128 * @param number The value to be formatted.
(...skipping 13 matching lines...) Expand all
143 142
144 /** 143 /**
145 * Format an int64 number using base-10 representation. 144 * Format an int64 number using base-10 representation.
146 * 145 *
147 * @param number The value to be formatted. 146 * @param number The value to be formatted.
148 * @param appendTo Output parameter to receive result. 147 * @param appendTo Output parameter to receive result.
149 * Result is appended to existing contents. 148 * Result is appended to existing contents.
150 * @param pos On input: an alignment field, if desired. 149 * @param pos On input: an alignment field, if desired.
151 * On output: the offsets of the alignment field. 150 * On output: the offsets of the alignment field.
152 * @return Reference to 'appendTo' parameter. 151 * @return Reference to 'appendTo' parameter.
153 * @draft ICU 51 152 * @stable ICU 51
154 */ 153 */
155 virtual UnicodeString& format(int64_t number, 154 virtual UnicodeString& format(int64_t number,
156 UnicodeString& appendTo, 155 UnicodeString& appendTo,
157 FieldPosition& pos) const; 156 FieldPosition& pos) const;
158 157
159 /** 158 /**
160 * Format an int64 number using base-10 representation. 159 * Format an int64 number using base-10 representation.
161 * Currently sets status to U_UNSUPPORTED_ERROR 160 * Currently sets status to U_UNSUPPORTED_ERROR
162 * 161 *
163 * @param number The value to be formatted. 162 * @param number The value to be formatted.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 FieldPosition& pos, 235 FieldPosition& pos,
237 UErrorCode& status) const; 236 UErrorCode& status) const;
238 237
239 /** 238 /**
240 * CompactDecimalFormat does not support parsing. This implementation 239 * CompactDecimalFormat does not support parsing. This implementation
241 * does nothing. 240 * does nothing.
242 * @param text Unused. 241 * @param text Unused.
243 * @param result Does not change. 242 * @param result Does not change.
244 * @param parsePosition Does not change. 243 * @param parsePosition Does not change.
245 * @see Formattable 244 * @see Formattable
246 * @draft ICU 51 245 * @stable ICU 51
247 */ 246 */
248 virtual void parse(const UnicodeString& text, 247 virtual void parse(const UnicodeString& text,
249 Formattable& result, 248 Formattable& result,
250 ParsePosition& parsePosition) const; 249 ParsePosition& parsePosition) const;
251 250
252 /** 251 /**
253 * CompactDecimalFormat does not support parsing. This implementation 252 * CompactDecimalFormat does not support parsing. This implementation
254 * sets status to U_UNSUPPORTED_ERROR 253 * sets status to U_UNSUPPORTED_ERROR
255 * 254 *
256 * @param text Unused. 255 * @param text Unused.
257 * @param result Does not change. 256 * @param result Does not change.
258 * @param status Always set to U_UNSUPPORTED_ERROR. 257 * @param status Always set to U_UNSUPPORTED_ERROR.
259 * @draft ICU 51 258 * @stable ICU 51
260 */ 259 */
261 virtual void parse(const UnicodeString& text, 260 virtual void parse(const UnicodeString& text,
262 Formattable& result, 261 Formattable& result,
263 UErrorCode& status) const; 262 UErrorCode& status) const;
264 263
265 /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following draft method since i t is virtual */
266 /** 264 /**
267 * Parses text from the given string as a currency amount. Unlike 265 * Parses text from the given string as a currency amount. Unlike
268 * the parse() method, this method will attempt to parse a generic 266 * the parse() method, this method will attempt to parse a generic
269 * currency name, searching for a match of this object's locale's 267 * currency name, searching for a match of this object's locale's
270 * currency display names, or for a 3-letter ISO currency code. 268 * currency display names, or for a 3-letter ISO currency code.
271 * This method will fail if this format is not a currency format, 269 * This method will fail if this format is not a currency format,
272 * that is, if it does not contain the currency pattern symbol 270 * that is, if it does not contain the currency pattern symbol
273 * (U+00A4) in its prefix or suffix. This implementation always returns 271 * (U+00A4) in its prefix or suffix. This implementation always returns
274 * NULL. 272 * NULL.
275 * 273 *
(...skipping 12 matching lines...) Expand all
288 286
289 /** 287 /**
290 * Return the class ID for this class. This is useful only for 288 * Return the class ID for this class. This is useful only for
291 * comparing to a return value from getDynamicClassID(). For example: 289 * comparing to a return value from getDynamicClassID(). For example:
292 * <pre> 290 * <pre>
293 * . Base* polymorphic_pointer = createPolymorphicObject(); 291 * . Base* polymorphic_pointer = createPolymorphicObject();
294 * . if (polymorphic_pointer->getDynamicClassID() == 292 * . if (polymorphic_pointer->getDynamicClassID() ==
295 * . Derived::getStaticClassID()) ... 293 * . Derived::getStaticClassID()) ...
296 * </pre> 294 * </pre>
297 * @return The class ID for all objects of this class. 295 * @return The class ID for all objects of this class.
298 * @draft ICU 51 296 * @stable ICU 51
299 */ 297 */
300 static UClassID U_EXPORT2 getStaticClassID(); 298 static UClassID U_EXPORT2 getStaticClassID();
301 299
302 /** 300 /**
303 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. 301 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override.
304 * This method is to implement a simple version of RTTI, since not all 302 * This method is to implement a simple version of RTTI, since not all
305 * C++ compilers support genuine RTTI. Polymorphic operator==() and 303 * C++ compilers support genuine RTTI. Polymorphic operator==() and
306 * clone() methods call this method. 304 * clone() methods call this method.
307 * 305 *
308 * @return The class ID for this object. All objects of a 306 * @return The class ID for this object. All objects of a
309 * given class have the same class ID. Objects of 307 * given class have the same class ID. Objects of
310 * other classes have different class IDs. 308 * other classes have different class IDs.
311 * @draft ICU 51 309 * @stable ICU 51
312 */ 310 */
313 virtual UClassID getDynamicClassID() const; 311 virtual UClassID getDynamicClassID() const;
314 312
315 private: 313 private:
316 314
317 const UHashtable* _unitsByVariant; 315 const UHashtable* _unitsByVariant;
318 const double* _divisors; 316 const double* _divisors;
319 PluralRules* _pluralRules; 317 PluralRules* _pluralRules;
320 318
321 // Default constructor not implemented. 319 // Default constructor not implemented.
322 CompactDecimalFormat(const DecimalFormat &, const UHashtable* unitsByVariant , const double* divisors, PluralRules* pluralRules); 320 CompactDecimalFormat(const DecimalFormat &, const UHashtable* unitsByVariant , const double* divisors, PluralRules* pluralRules);
323 321
324 UBool eqHelper(const CompactDecimalFormat& that) const; 322 UBool eqHelper(const CompactDecimalFormat& that) const;
325 }; 323 };
326 324
327 U_NAMESPACE_END 325 U_NAMESPACE_END
328 326
329 #endif /* U_HIDE_DRAFT_API */
330 #endif /* #if !UCONFIG_NO_FORMATTING */ 327 #endif /* #if !UCONFIG_NO_FORMATTING */
331 328
332 #endif // __COMPACT_DECIMAL_FORMAT_H__ 329 #endif // __COMPACT_DECIMAL_FORMAT_H__
333 //eof 330 //eof
OLDNEW
« no previous file with comments | « source/i18n/unicode/coll.h ('k') | source/i18n/unicode/currunit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698