]>
Commit | Line | Data |
---|---|---|
3d1f044b | 1 | // © 2018 and later: Unicode, Inc. and others. |
f3c0d7a5 | 2 | // License & terms of use: http://www.unicode.org/copyright.html |
3d1f044b | 3 | |
51004dcb A |
4 | #include "unicode/utypes.h" |
5 | ||
6 | #if !UCONFIG_NO_FORMATTING | |
7 | ||
3d1f044b A |
8 | // Allow implicit conversion from char16_t* to UnicodeString for this file: |
9 | // Helpful in toString methods and elsewhere. | |
10 | #define UNISTR_FROM_STRING_EXPLICIT | |
51004dcb | 11 | |
3d1f044b A |
12 | #include "unicode/compactdecimalformat.h" |
13 | #include "number_mapper.h" | |
14 | #include "number_decimfmtprops.h" | |
51004dcb | 15 | |
3d1f044b | 16 | using namespace icu; |
51004dcb | 17 | |
51004dcb A |
18 | |
19 | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CompactDecimalFormat) | |
20 | ||
51004dcb | 21 | |
3d1f044b A |
22 | CompactDecimalFormat* |
23 | CompactDecimalFormat::createInstance(const Locale& inLocale, UNumberCompactStyle style, | |
24 | UErrorCode& status) { | |
25 | return new CompactDecimalFormat(inLocale, style, status); | |
51004dcb A |
26 | } |
27 | ||
3d1f044b A |
28 | CompactDecimalFormat::CompactDecimalFormat(const Locale& inLocale, UNumberCompactStyle style, |
29 | UErrorCode& status) | |
30 | : DecimalFormat(new DecimalFormatSymbols(inLocale, status), status) { | |
31 | if (U_FAILURE(status)) return; | |
32 | // Minimal properties: let the non-shim code path do most of the logic for us. | |
33 | fields->properties->compactStyle = style; | |
34 | fields->properties->groupingSize = -2; // do not forward grouping information | |
35 | fields->properties->minimumGroupingDigits = 2; | |
36 | touch(status); | |
2ca993e8 A |
37 | } |
38 | ||
3d1f044b | 39 | CompactDecimalFormat::CompactDecimalFormat(const CompactDecimalFormat& source) = default; |
51004dcb | 40 | |
3d1f044b | 41 | CompactDecimalFormat::~CompactDecimalFormat() = default; |
51004dcb | 42 | |
3d1f044b A |
43 | CompactDecimalFormat& CompactDecimalFormat::operator=(const CompactDecimalFormat& rhs) { |
44 | DecimalFormat::operator=(rhs); | |
45 | return *this; | |
51004dcb A |
46 | } |
47 | ||
3d1f044b A |
48 | Format* CompactDecimalFormat::clone() const { |
49 | return new CompactDecimalFormat(*this); | |
51004dcb A |
50 | } |
51 | ||
52 | void | |
53 | CompactDecimalFormat::parse( | |
3d1f044b A |
54 | const UnicodeString& /* text */, |
55 | Formattable& /* result */, | |
56 | ParsePosition& /* parsePosition */) const { | |
51004dcb A |
57 | } |
58 | ||
59 | void | |
60 | CompactDecimalFormat::parse( | |
3d1f044b A |
61 | const UnicodeString& /* text */, |
62 | Formattable& /* result */, | |
63 | UErrorCode& status) const { | |
64 | status = U_UNSUPPORTED_ERROR; | |
51004dcb A |
65 | } |
66 | ||
67 | CurrencyAmount* | |
68 | CompactDecimalFormat::parseCurrency( | |
3d1f044b A |
69 | const UnicodeString& /* text */, |
70 | ParsePosition& /* pos */) const { | |
71 | return nullptr; | |
51004dcb A |
72 | } |
73 | ||
51004dcb | 74 | |
3d1f044b | 75 | #endif /* #if !UCONFIG_NO_FORMATTING */ |