2018-03-03 08:26:58 +00:00
|
|
|
// © 2018 and later: Unicode, Inc. and others.
|
2016-06-15 18:58:17 +00:00
|
|
|
// License & terms of use: http://www.unicode.org/copyright.html
|
2012-11-14 18:49:38 +00:00
|
|
|
|
2018-03-03 08:26:58 +00:00
|
|
|
#include "unicode/utypes.h"
|
2012-11-14 18:49:38 +00:00
|
|
|
|
2018-04-23 23:02:26 +00:00
|
|
|
#if !UCONFIG_NO_FORMATTING
|
2012-11-14 18:49:38 +00:00
|
|
|
|
2018-03-03 08:26:58 +00:00
|
|
|
// Allow implicit conversion from char16_t* to UnicodeString for this file:
|
|
|
|
// Helpful in toString methods and elsewhere.
|
|
|
|
#define UNISTR_FROM_STRING_EXPLICIT
|
2016-05-31 22:48:47 +00:00
|
|
|
|
2018-03-13 08:12:05 +00:00
|
|
|
#include "unicode/compactdecimalformat.h"
|
2018-04-26 00:17:30 +00:00
|
|
|
#include "number_mapper.h"
|
2018-03-16 09:20:43 +00:00
|
|
|
#include "number_decimfmtprops.h"
|
2018-03-13 08:12:05 +00:00
|
|
|
|
2018-03-03 08:26:58 +00:00
|
|
|
using namespace icu;
|
2016-05-31 22:48:47 +00:00
|
|
|
|
|
|
|
|
2018-03-16 09:20:43 +00:00
|
|
|
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CompactDecimalFormat)
|
|
|
|
|
|
|
|
|
2018-03-13 08:12:05 +00:00
|
|
|
CompactDecimalFormat*
|
|
|
|
CompactDecimalFormat::createInstance(const Locale& inLocale, UNumberCompactStyle style,
|
2018-03-16 09:20:43 +00:00
|
|
|
UErrorCode& status) {
|
|
|
|
return new CompactDecimalFormat(inLocale, style, status);
|
|
|
|
}
|
|
|
|
|
|
|
|
CompactDecimalFormat::CompactDecimalFormat(const Locale& inLocale, UNumberCompactStyle style,
|
|
|
|
UErrorCode& status)
|
|
|
|
: DecimalFormat(new DecimalFormatSymbols(inLocale, status), status) {
|
2018-03-17 01:31:52 +00:00
|
|
|
if (U_FAILURE(status)) return;
|
2018-03-16 09:20:43 +00:00
|
|
|
// Minimal properties: let the non-shim code path do most of the logic for us.
|
2018-04-26 00:17:30 +00:00
|
|
|
fields->properties->compactStyle = style;
|
|
|
|
fields->properties->groupingSize = -2; // do not forward grouping information
|
|
|
|
fields->properties->minimumGroupingDigits = 2;
|
2018-04-19 09:29:39 +00:00
|
|
|
touch(status);
|
2018-03-16 09:20:43 +00:00
|
|
|
}
|
2018-03-13 08:12:05 +00:00
|
|
|
|
|
|
|
CompactDecimalFormat::CompactDecimalFormat(const CompactDecimalFormat& source) = default;
|
|
|
|
|
|
|
|
CompactDecimalFormat::~CompactDecimalFormat() = default;
|
|
|
|
|
2018-03-16 09:20:43 +00:00
|
|
|
CompactDecimalFormat& CompactDecimalFormat::operator=(const CompactDecimalFormat& rhs) {
|
|
|
|
DecimalFormat::operator=(rhs);
|
|
|
|
return *this;
|
|
|
|
}
|
2012-11-14 18:49:38 +00:00
|
|
|
|
2018-04-24 01:19:44 +00:00
|
|
|
Format* CompactDecimalFormat::clone() const {
|
|
|
|
return new CompactDecimalFormat(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompactDecimalFormat::parse(
|
|
|
|
const UnicodeString& /* text */,
|
|
|
|
Formattable& /* result */,
|
|
|
|
ParsePosition& /* parsePosition */) const {
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompactDecimalFormat::parse(
|
|
|
|
const UnicodeString& /* text */,
|
|
|
|
Formattable& /* result */,
|
|
|
|
UErrorCode& status) const {
|
|
|
|
status = U_UNSUPPORTED_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
CurrencyAmount*
|
|
|
|
CompactDecimalFormat::parseCurrency(
|
|
|
|
const UnicodeString& /* text */,
|
|
|
|
ParsePosition& /* pos */) const {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-11-14 18:49:38 +00:00
|
|
|
|
2018-03-03 08:26:58 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|