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
|
2010-01-28 19:39:24 +00:00
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
2018-03-03 08:26:58 +00:00
|
|
|
#if !UCONFIG_NO_FORMATTING && !UPRV_INCOMPLETE_CPP11_SUPPORT
|
2002-09-20 01:54:48 +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
|
2013-10-17 18:44:44 +00:00
|
|
|
|
2018-03-13 09:25:41 +00:00
|
|
|
#include "unicode/errorcode.h"
|
2018-03-03 10:53:01 +00:00
|
|
|
#include "unicode/decimfmt.h"
|
|
|
|
#include "number_decimalquantity.h"
|
2018-03-13 09:25:41 +00:00
|
|
|
#include "number_types.h"
|
|
|
|
#include "numparse_impl.h"
|
|
|
|
#include "number_mapper.h"
|
|
|
|
#include "number_patternstring.h"
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-03 08:26:58 +00:00
|
|
|
using namespace icu;
|
2018-03-03 10:53:01 +00:00
|
|
|
using namespace icu::number;
|
|
|
|
using namespace icu::number::impl;
|
2018-03-13 09:25:41 +00:00
|
|
|
using namespace icu::numparse;
|
|
|
|
using namespace icu::numparse::impl;
|
2018-03-03 10:53:01 +00:00
|
|
|
using ERoundingMode = icu::DecimalFormat::ERoundingMode;
|
|
|
|
using EPadPosition = icu::DecimalFormat::EPadPosition;
|
|
|
|
|
|
|
|
|
2018-03-13 09:25:41 +00:00
|
|
|
DecimalFormat::DecimalFormat(UErrorCode& status)
|
|
|
|
: DecimalFormat(nullptr, status) {
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-13 09:25:41 +00:00
|
|
|
DecimalFormat::DecimalFormat(const UnicodeString& pattern, UErrorCode& status)
|
|
|
|
: DecimalFormat(nullptr, status) {
|
|
|
|
setPropertiesFromPattern(pattern, IGNORE_ROUNDING_IF_CURRENCY, status);
|
|
|
|
refreshFormatter(status);
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
DecimalFormat::DecimalFormat(const UnicodeString& pattern, DecimalFormatSymbols* symbolsToAdopt,
|
2018-03-13 09:25:41 +00:00
|
|
|
UErrorCode& status)
|
|
|
|
: DecimalFormat(symbolsToAdopt, status) {
|
|
|
|
setPropertiesFromPattern(pattern, IGNORE_ROUNDING_IF_CURRENCY, status);
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
DecimalFormat::DecimalFormat(const UnicodeString& pattern, DecimalFormatSymbols* symbolsToAdopt,
|
2018-03-13 09:25:41 +00:00
|
|
|
UNumberFormatStyle style, UErrorCode& status)
|
|
|
|
: DecimalFormat(symbolsToAdopt, status) {
|
|
|
|
// If choice is a currency type, ignore the rounding information.
|
|
|
|
if (style == UNumberFormatStyle::UNUM_CURRENCY || style == UNumberFormatStyle::UNUM_CURRENCY_ISO ||
|
|
|
|
style == UNumberFormatStyle::UNUM_CURRENCY_ACCOUNTING ||
|
|
|
|
style == UNumberFormatStyle::UNUM_CASH_CURRENCY ||
|
|
|
|
style == UNumberFormatStyle::UNUM_CURRENCY_STANDARD ||
|
|
|
|
style == UNumberFormatStyle::UNUM_CURRENCY_PLURAL) {
|
|
|
|
setPropertiesFromPattern(pattern, IGNORE_ROUNDING_ALWAYS, status);
|
|
|
|
} else {
|
|
|
|
setPropertiesFromPattern(pattern, IGNORE_ROUNDING_IF_CURRENCY, status);
|
|
|
|
}
|
|
|
|
refreshFormatter(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
DecimalFormat::DecimalFormat(const DecimalFormatSymbols* symbolsToAdopt, UErrorCode& status) {
|
|
|
|
properties = new DecimalFormatProperties();
|
|
|
|
exportedProperties = new DecimalFormatProperties();
|
|
|
|
if (symbolsToAdopt == nullptr) {
|
|
|
|
symbols = new DecimalFormatSymbols(status);
|
|
|
|
} else {
|
|
|
|
symbols = symbolsToAdopt;
|
|
|
|
}
|
|
|
|
if (properties == nullptr || exportedProperties == nullptr || symbols == nullptr) {
|
|
|
|
status = U_MEMORY_ALLOCATION_ERROR;
|
|
|
|
}
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-13 10:11:36 +00:00
|
|
|
#if UCONFIG_HAVE_PARSEALLINPUT
|
|
|
|
|
|
|
|
void DecimalFormat::setParseAllInput(UNumberFormatAttributeValue value) {
|
|
|
|
properties->parseAllInput = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
DecimalFormat&
|
2018-03-13 10:11:36 +00:00
|
|
|
DecimalFormat::setAttribute(UNumberFormatAttribute attr, int32_t newValue, UErrorCode& status) {
|
|
|
|
if (U_FAILURE(status)) { return *this; }
|
|
|
|
|
|
|
|
switch (attr) {
|
|
|
|
case UNUM_LENIENT_PARSE:
|
|
|
|
setLenient(newValue != 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_PARSE_INT_ONLY:
|
|
|
|
setParseIntegerOnly(newValue != 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_GROUPING_USED:
|
|
|
|
setGroupingUsed(newValue != 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_DECIMAL_ALWAYS_SHOWN:
|
|
|
|
setDecimalSeparatorAlwaysShown(newValue != 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_MAX_INTEGER_DIGITS:
|
|
|
|
setMaximumIntegerDigits(newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_MIN_INTEGER_DIGITS:
|
|
|
|
setMinimumIntegerDigits(newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_INTEGER_DIGITS:
|
|
|
|
setMinimumIntegerDigits(newValue);
|
|
|
|
setMaximumIntegerDigits(newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_MAX_FRACTION_DIGITS:
|
|
|
|
setMaximumFractionDigits(newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_MIN_FRACTION_DIGITS:
|
|
|
|
setMinimumFractionDigits(newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_FRACTION_DIGITS:
|
|
|
|
setMinimumFractionDigits(newValue);
|
|
|
|
setMaximumFractionDigits(newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_SIGNIFICANT_DIGITS_USED:
|
|
|
|
setSignificantDigitsUsed(newValue != 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_MAX_SIGNIFICANT_DIGITS:
|
|
|
|
setMaximumSignificantDigits(newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_MIN_SIGNIFICANT_DIGITS:
|
|
|
|
setMinimumSignificantDigits(newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_MULTIPLIER:
|
|
|
|
setMultiplier(newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_GROUPING_SIZE:
|
|
|
|
setGroupingSize(newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_ROUNDING_MODE:
|
|
|
|
setRoundingMode((DecimalFormat::ERoundingMode) newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_FORMAT_WIDTH:
|
|
|
|
setFormatWidth(newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_PADDING_POSITION:
|
|
|
|
/** The position at which padding will take place. */
|
|
|
|
setPadPosition((DecimalFormat::EPadPosition) newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_SECONDARY_GROUPING_SIZE:
|
|
|
|
setSecondaryGroupingSize(newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
#if UCONFIG_HAVE_PARSEALLINPUT
|
|
|
|
case UNUM_PARSE_ALL_INPUT:
|
|
|
|
setParseAllInput((UNumberFormatAttributeValue) newValue);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case UNUM_PARSE_NO_EXPONENT:
|
|
|
|
setParseNoExponent((UBool) newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_PARSE_DECIMAL_MARK_REQUIRED:
|
|
|
|
setDecimalPatternMatchRequired((UBool) newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_CURRENCY_USAGE:
|
|
|
|
setCurrencyUsage((UCurrencyUsage) newValue, &status);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNUM_MINIMUM_GROUPING_DIGITS:
|
|
|
|
setMinimumGroupingDigits(newValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
status = U_UNSUPPORTED_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// TODO: UNUM_SCALE?
|
|
|
|
// TODO: UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS?
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t DecimalFormat::getAttribute(UNumberFormatAttribute attr, UErrorCode& status) const {
|
|
|
|
if (U_FAILURE(status)) { return -1; }
|
|
|
|
switch (attr) {
|
|
|
|
case UNUM_LENIENT_PARSE:
|
|
|
|
return isLenient();
|
|
|
|
|
|
|
|
case UNUM_PARSE_INT_ONLY:
|
|
|
|
return isParseIntegerOnly();
|
|
|
|
|
|
|
|
case UNUM_GROUPING_USED:
|
|
|
|
return isGroupingUsed();
|
|
|
|
|
|
|
|
case UNUM_DECIMAL_ALWAYS_SHOWN:
|
|
|
|
return isDecimalSeparatorAlwaysShown();
|
|
|
|
|
|
|
|
case UNUM_MAX_INTEGER_DIGITS:
|
|
|
|
return getMaximumIntegerDigits();
|
|
|
|
|
|
|
|
case UNUM_MIN_INTEGER_DIGITS:
|
|
|
|
return getMinimumIntegerDigits();
|
|
|
|
|
|
|
|
case UNUM_INTEGER_DIGITS:
|
|
|
|
// TBD: what should this return?
|
|
|
|
return getMinimumIntegerDigits();
|
|
|
|
|
|
|
|
case UNUM_MAX_FRACTION_DIGITS:
|
|
|
|
return getMaximumFractionDigits();
|
|
|
|
|
|
|
|
case UNUM_MIN_FRACTION_DIGITS:
|
|
|
|
return getMinimumFractionDigits();
|
|
|
|
|
|
|
|
case UNUM_FRACTION_DIGITS:
|
|
|
|
// TBD: what should this return?
|
|
|
|
return getMinimumFractionDigits();
|
|
|
|
|
|
|
|
case UNUM_SIGNIFICANT_DIGITS_USED:
|
|
|
|
return areSignificantDigitsUsed();
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-13 10:11:36 +00:00
|
|
|
case UNUM_MAX_SIGNIFICANT_DIGITS:
|
|
|
|
return getMaximumSignificantDigits();
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-13 10:11:36 +00:00
|
|
|
case UNUM_MIN_SIGNIFICANT_DIGITS:
|
|
|
|
return getMinimumSignificantDigits();
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-13 10:11:36 +00:00
|
|
|
case UNUM_MULTIPLIER:
|
|
|
|
return getMultiplier();
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-13 10:11:36 +00:00
|
|
|
case UNUM_GROUPING_SIZE:
|
|
|
|
return getGroupingSize();
|
|
|
|
|
|
|
|
case UNUM_ROUNDING_MODE:
|
|
|
|
return getRoundingMode();
|
|
|
|
|
|
|
|
case UNUM_FORMAT_WIDTH:
|
|
|
|
return getFormatWidth();
|
|
|
|
|
|
|
|
case UNUM_PADDING_POSITION:
|
|
|
|
return getPadPosition();
|
|
|
|
|
|
|
|
case UNUM_SECONDARY_GROUPING_SIZE:
|
|
|
|
return getSecondaryGroupingSize();
|
|
|
|
|
|
|
|
case UNUM_PARSE_NO_EXPONENT:
|
|
|
|
return getParseNoExponent();
|
|
|
|
|
|
|
|
case UNUM_PARSE_DECIMAL_MARK_REQUIRED:
|
|
|
|
return isDecimalPatternMatchRequired();
|
|
|
|
|
|
|
|
case UNUM_CURRENCY_USAGE:
|
|
|
|
return getCurrencyUsage();
|
|
|
|
|
|
|
|
case UNUM_MINIMUM_GROUPING_DIGITS:
|
|
|
|
return getMinimumGroupingDigits();
|
|
|
|
|
|
|
|
default:
|
|
|
|
status = U_UNSUPPORTED_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// TODO: UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS?
|
|
|
|
// TODO: UNUM_SCALE?
|
|
|
|
|
|
|
|
return -1; /* undefined */
|
|
|
|
}
|
|
|
|
|
|
|
|
void DecimalFormat::setGroupingUsed(UBool enabled) {
|
|
|
|
if (enabled) {
|
|
|
|
// Set to a reasonable default value
|
|
|
|
properties->groupingSize = 3;
|
|
|
|
properties->secondaryGroupingSize = 3;
|
|
|
|
} else {
|
|
|
|
properties->groupingSize = 0;
|
|
|
|
properties->secondaryGroupingSize = 0;
|
|
|
|
}
|
|
|
|
refreshFormatterNoError();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DecimalFormat::setParseIntegerOnly(UBool value) {
|
|
|
|
properties->parseIntegerOnly = value;
|
|
|
|
refreshFormatterNoError();
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
DecimalFormat::DecimalFormat(const UnicodeString& pattern, DecimalFormatSymbols* symbolsToAdopt,
|
2018-03-13 09:25:41 +00:00
|
|
|
UParseError& parseError, UErrorCode& status)
|
|
|
|
: DecimalFormat(symbolsToAdopt, status) {
|
|
|
|
// TODO: What is parseError for?
|
|
|
|
setPropertiesFromPattern(pattern, IGNORE_ROUNDING_IF_CURRENCY, status);
|
|
|
|
refreshFormatter(status);
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
DecimalFormat::DecimalFormat(const UnicodeString& pattern, const DecimalFormatSymbols& symbols,
|
2018-03-13 09:25:41 +00:00
|
|
|
UErrorCode& status)
|
|
|
|
: DecimalFormat(new DecimalFormatSymbols(symbols), status) {
|
|
|
|
setPropertiesFromPattern(pattern, IGNORE_ROUNDING_IF_CURRENCY, status);
|
|
|
|
refreshFormatter(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
DecimalFormat::DecimalFormat(const DecimalFormat& source) {
|
|
|
|
properties = new DecimalFormatProperties();
|
|
|
|
exportedProperties = new DecimalFormatProperties();
|
|
|
|
symbols = new DecimalFormatSymbols(*source.symbols);
|
|
|
|
if (properties == nullptr || exportedProperties == nullptr || symbols == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2018-03-13 10:11:36 +00:00
|
|
|
refreshFormatterNoError();
|
2018-03-13 09:25:41 +00:00
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-13 10:11:36 +00:00
|
|
|
DecimalFormat& DecimalFormat::operator=(const DecimalFormat& rhs) {
|
|
|
|
*properties = *rhs.properties;
|
|
|
|
exportedProperties->clear();
|
|
|
|
symbols = new DecimalFormatSymbols(*rhs.symbols);
|
|
|
|
refreshFormatterNoError();
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
DecimalFormat::~DecimalFormat() = default;
|
|
|
|
|
2018-03-13 10:11:36 +00:00
|
|
|
Format* DecimalFormat::clone() const {
|
|
|
|
return new DecimalFormat(*this);
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-13 10:11:36 +00:00
|
|
|
UBool DecimalFormat::operator==(const Format& other) const {
|
|
|
|
const DecimalFormat* otherDF = dynamic_cast<const DecimalFormat*>(&other);
|
|
|
|
if (otherDF == nullptr) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return *properties == *otherDF->properties && *symbols == *otherDF->symbols;
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-13 10:11:36 +00:00
|
|
|
UnicodeString& DecimalFormat::format(double number, UnicodeString& appendTo, FieldPosition& pos) const {
|
|
|
|
ErrorCode localStatus;
|
|
|
|
FormattedNumber output = formatter->formatDouble(number, localStatus);
|
|
|
|
output.populateFieldPosition(pos, localStatus);
|
|
|
|
auto appendable = UnicodeStringAppendable(appendTo);
|
|
|
|
output.appendTo(appendable);
|
|
|
|
return appendTo;
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
UnicodeString& DecimalFormat::format(double number, UnicodeString& appendTo, FieldPosition& pos,
|
2018-03-13 10:11:36 +00:00
|
|
|
UErrorCode& status) const {
|
|
|
|
FormattedNumber output = formatter->formatDouble(number, status);
|
|
|
|
output.populateFieldPosition(pos, status);
|
|
|
|
auto appendable = UnicodeStringAppendable(appendTo);
|
|
|
|
output.appendTo(appendable);
|
|
|
|
return appendTo;
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
UnicodeString&
|
|
|
|
DecimalFormat::format(double number, UnicodeString& appendTo, FieldPositionIterator* posIter,
|
2018-03-13 10:11:36 +00:00
|
|
|
UErrorCode& status) const {
|
|
|
|
FormattedNumber output = formatter->formatDouble(number, status);
|
|
|
|
output.populateFieldPositionIterator(*posIter, status);
|
|
|
|
auto appendable = UnicodeStringAppendable(appendTo);
|
|
|
|
output.appendTo(appendable);
|
|
|
|
return appendTo;
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-13 10:11:36 +00:00
|
|
|
UnicodeString& DecimalFormat::format(int32_t number, UnicodeString& appendTo, FieldPosition& pos) const {
|
|
|
|
return format(static_cast<int64_t> (number), appendTo, pos);
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
UnicodeString& DecimalFormat::format(int32_t number, UnicodeString& appendTo, FieldPosition& pos,
|
2018-03-13 10:11:36 +00:00
|
|
|
UErrorCode& status) const {
|
|
|
|
return format(static_cast<int64_t> (number), appendTo, pos, status);
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
UnicodeString&
|
|
|
|
DecimalFormat::format(int32_t number, UnicodeString& appendTo, FieldPositionIterator* posIter,
|
2018-03-13 10:11:36 +00:00
|
|
|
UErrorCode& status) const {
|
|
|
|
return format(static_cast<int64_t> (number), appendTo, posIter, status);
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-13 10:11:36 +00:00
|
|
|
UnicodeString& DecimalFormat::format(int64_t number, UnicodeString& appendTo, FieldPosition& pos) const {
|
|
|
|
ErrorCode localStatus;
|
|
|
|
FormattedNumber output = formatter->formatInt(number, localStatus);
|
|
|
|
output.populateFieldPosition(pos, localStatus);
|
|
|
|
auto appendable = UnicodeStringAppendable(appendTo);
|
|
|
|
output.appendTo(appendable);
|
|
|
|
return appendTo;
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
UnicodeString& DecimalFormat::format(int64_t number, UnicodeString& appendTo, FieldPosition& pos,
|
2018-03-13 10:11:36 +00:00
|
|
|
UErrorCode& status) const {
|
|
|
|
FormattedNumber output = formatter->formatInt(number, status);
|
|
|
|
output.populateFieldPosition(pos, status);
|
|
|
|
auto appendable = UnicodeStringAppendable(appendTo);
|
|
|
|
output.appendTo(appendable);
|
|
|
|
return appendTo;
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
UnicodeString&
|
|
|
|
DecimalFormat::format(int64_t number, UnicodeString& appendTo, FieldPositionIterator* posIter,
|
2018-03-13 10:11:36 +00:00
|
|
|
UErrorCode& status) const {
|
|
|
|
FormattedNumber output = formatter->formatInt(number, status);
|
|
|
|
output.populateFieldPositionIterator(*posIter, status);
|
|
|
|
auto appendable = UnicodeStringAppendable(appendTo);
|
|
|
|
output.appendTo(appendable);
|
|
|
|
return appendTo;
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
UnicodeString&
|
|
|
|
DecimalFormat::format(StringPiece number, UnicodeString& appendTo, FieldPositionIterator* posIter,
|
2018-03-13 10:11:36 +00:00
|
|
|
UErrorCode& status) const {
|
|
|
|
ErrorCode localStatus;
|
|
|
|
FormattedNumber output = formatter->formatDecimal(number, localStatus);
|
|
|
|
output.populateFieldPositionIterator(*posIter, status);
|
|
|
|
auto appendable = UnicodeStringAppendable(appendTo);
|
|
|
|
output.appendTo(appendable);
|
|
|
|
return appendTo;
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-13 08:12:05 +00:00
|
|
|
UnicodeString& DecimalFormat::format(const DecimalQuantity& number, UnicodeString& appendTo,
|
2018-03-13 10:11:36 +00:00
|
|
|
FieldPositionIterator* posIter, UErrorCode& status) const {
|
|
|
|
FormattedNumber output = formatter->formatDecimalQuantity(number, status);
|
|
|
|
output.populateFieldPositionIterator(*posIter, status);
|
|
|
|
auto appendable = UnicodeStringAppendable(appendTo);
|
|
|
|
output.appendTo(appendable);
|
|
|
|
return appendTo;
|
|
|
|
}
|
2018-03-13 08:12:05 +00:00
|
|
|
|
2018-03-03 10:53:01 +00:00
|
|
|
UnicodeString&
|
2018-03-13 08:12:05 +00:00
|
|
|
DecimalFormat::format(const DecimalQuantity& number, UnicodeString& appendTo, FieldPosition& pos,
|
2018-03-13 10:11:36 +00:00
|
|
|
UErrorCode& status) const {
|
|
|
|
FormattedNumber output = formatter->formatDecimalQuantity(number, status);
|
|
|
|
output.populateFieldPosition(pos, status);
|
|
|
|
auto appendable = UnicodeStringAppendable(appendTo);
|
|
|
|
output.appendTo(appendable);
|
|
|
|
return appendTo;
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
void
|
2018-03-13 10:11:36 +00:00
|
|
|
DecimalFormat::parse(const UnicodeString& text, Formattable& result, ParsePosition& parsePosition) const {
|
|
|
|
// FIXME
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
2018-03-13 10:11:36 +00:00
|
|
|
CurrencyAmount* DecimalFormat::parseCurrency(const UnicodeString& text, ParsePosition& pos) const {
|
|
|
|
// FIXME
|
|
|
|
}
|
2018-03-03 10:53:01 +00:00
|
|
|
|
|
|
|
const DecimalFormatSymbols* DecimalFormat::getDecimalFormatSymbols(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt) {}
|
|
|
|
|
|
|
|
void DecimalFormat::setDecimalFormatSymbols(const DecimalFormatSymbols& symbols) {}
|
|
|
|
|
|
|
|
const CurrencyPluralInfo* DecimalFormat::getCurrencyPluralInfo(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt) {}
|
|
|
|
|
|
|
|
void DecimalFormat::setCurrencyPluralInfo(const CurrencyPluralInfo& info) {}
|
|
|
|
|
|
|
|
UnicodeString& DecimalFormat::getPositivePrefix(UnicodeString& result) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setPositivePrefix(const UnicodeString& newValue) {}
|
|
|
|
|
|
|
|
UnicodeString& DecimalFormat::getNegativePrefix(UnicodeString& result) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setNegativePrefix(const UnicodeString& newValue) {}
|
|
|
|
|
|
|
|
UnicodeString& DecimalFormat::getPositiveSuffix(UnicodeString& result) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setPositiveSuffix(const UnicodeString& newValue) {}
|
|
|
|
|
|
|
|
UnicodeString& DecimalFormat::getNegativeSuffix(UnicodeString& result) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setNegativeSuffix(const UnicodeString& newValue) {}
|
|
|
|
|
|
|
|
int32_t DecimalFormat::getMultiplier(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setMultiplier(int32_t newValue) {}
|
|
|
|
|
|
|
|
double DecimalFormat::getRoundingIncrement(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setRoundingIncrement(double newValue) {}
|
|
|
|
|
|
|
|
ERoundingMode DecimalFormat::getRoundingMode(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setRoundingMode(ERoundingMode roundingMode) {}
|
|
|
|
|
|
|
|
int32_t DecimalFormat::getFormatWidth(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setFormatWidth(int32_t width) {}
|
|
|
|
|
|
|
|
UnicodeString DecimalFormat::getPadCharacterString() const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setPadCharacter(const UnicodeString& padChar) {}
|
|
|
|
|
|
|
|
EPadPosition DecimalFormat::getPadPosition(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setPadPosition(EPadPosition padPos) {}
|
|
|
|
|
|
|
|
UBool DecimalFormat::isScientificNotation(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setScientificNotation(UBool useScientific) {}
|
|
|
|
|
|
|
|
int8_t DecimalFormat::getMinimumExponentDigits(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setMinimumExponentDigits(int8_t minExpDig) {}
|
|
|
|
|
|
|
|
UBool DecimalFormat::isExponentSignAlwaysShown(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setExponentSignAlwaysShown(UBool expSignAlways) {}
|
|
|
|
|
|
|
|
int32_t DecimalFormat::getGroupingSize(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setGroupingSize(int32_t newValue) {}
|
|
|
|
|
|
|
|
int32_t DecimalFormat::getSecondaryGroupingSize(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setSecondaryGroupingSize(int32_t newValue) {}
|
|
|
|
|
|
|
|
int32_t DecimalFormat::getMinimumGroupingDigits() const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setMinimumGroupingDigits(int32_t newValue) {}
|
|
|
|
|
|
|
|
UBool DecimalFormat::isDecimalSeparatorAlwaysShown(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setDecimalSeparatorAlwaysShown(UBool newValue) {}
|
|
|
|
|
|
|
|
UBool DecimalFormat::isDecimalPatternMatchRequired(void) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setDecimalPatternMatchRequired(UBool newValue) {}
|
|
|
|
|
|
|
|
UnicodeString& DecimalFormat::toPattern(UnicodeString& result) const {}
|
|
|
|
|
|
|
|
UnicodeString& DecimalFormat::toLocalizedPattern(UnicodeString& result) const {}
|
|
|
|
|
|
|
|
void
|
|
|
|
DecimalFormat::applyPattern(const UnicodeString& pattern, UParseError& parseError, UErrorCode& status) {}
|
|
|
|
|
|
|
|
void DecimalFormat::applyPattern(const UnicodeString& pattern, UErrorCode& status) {}
|
|
|
|
|
|
|
|
void DecimalFormat::applyLocalizedPattern(const UnicodeString& pattern, UParseError& parseError,
|
|
|
|
UErrorCode& status) {}
|
|
|
|
|
|
|
|
void DecimalFormat::applyLocalizedPattern(const UnicodeString& pattern, UErrorCode& status) {}
|
|
|
|
|
|
|
|
void DecimalFormat::setMaximumIntegerDigits(int32_t newValue) {}
|
|
|
|
|
|
|
|
void DecimalFormat::setMinimumIntegerDigits(int32_t newValue) {}
|
|
|
|
|
|
|
|
void DecimalFormat::setMaximumFractionDigits(int32_t newValue) {}
|
|
|
|
|
|
|
|
void DecimalFormat::setMinimumFractionDigits(int32_t newValue) {}
|
|
|
|
|
|
|
|
int32_t DecimalFormat::getMinimumSignificantDigits() const {}
|
|
|
|
|
|
|
|
int32_t DecimalFormat::getMaximumSignificantDigits() const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setMinimumSignificantDigits(int32_t min) {}
|
|
|
|
|
|
|
|
void DecimalFormat::setMaximumSignificantDigits(int32_t max) {}
|
|
|
|
|
|
|
|
UBool DecimalFormat::areSignificantDigitsUsed() const {}
|
|
|
|
|
|
|
|
void DecimalFormat::setSignificantDigitsUsed(UBool useSignificantDigits) {}
|
|
|
|
|
|
|
|
void DecimalFormat::setCurrency(const char16_t* theCurrency, UErrorCode& ec) {}
|
|
|
|
|
|
|
|
void DecimalFormat::setCurrency(const char16_t* theCurrency) {}
|
|
|
|
|
|
|
|
void DecimalFormat::setCurrencyUsage(UCurrencyUsage newUsage, UErrorCode* ec) {}
|
2013-02-21 22:37:26 +00:00
|
|
|
|
2018-03-03 10:53:01 +00:00
|
|
|
UCurrencyUsage DecimalFormat::getCurrencyUsage() const {}
|
2013-06-20 22:09:42 +00:00
|
|
|
|
2018-03-13 08:12:05 +00:00
|
|
|
void
|
|
|
|
DecimalFormat::formatToDecimalQuantity(double number, DecimalQuantity& output, UErrorCode& status) const {}
|
|
|
|
|
|
|
|
void DecimalFormat::formatToDecimalQuantity(const Formattable& number, DecimalQuantity& output,
|
|
|
|
UErrorCode& status) const {}
|
|
|
|
|
2018-03-03 10:53:01 +00:00
|
|
|
number::LocalizedNumberFormatter DecimalFormat::toNumberFormatter() const {}
|
2010-01-16 19:59:59 +00:00
|
|
|
|
2018-03-03 10:53:01 +00:00
|
|
|
UClassID DecimalFormat::getStaticClassID() {}
|
2013-06-20 22:09:42 +00:00
|
|
|
|
2018-03-03 10:53:01 +00:00
|
|
|
UClassID DecimalFormat::getDynamicClassID() const {}
|
2013-06-20 22:09:42 +00:00
|
|
|
|
2018-03-13 09:25:41 +00:00
|
|
|
/** Rebuilds the formatter object from the property bag. */
|
|
|
|
void DecimalFormat::refreshFormatter(UErrorCode& status) {
|
|
|
|
if (exportedProperties == nullptr) {
|
|
|
|
// exportedProperties is null only when the formatter is not ready yet.
|
|
|
|
// The only time when this happens is during legacy deserialization.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Locale locale = getLocale(ULOC_ACTUAL_LOCALE, status);
|
|
|
|
if (U_FAILURE(status)) {
|
|
|
|
// Constructor
|
|
|
|
locale = symbols->getLocale(ULOC_ACTUAL_LOCALE, status);
|
|
|
|
}
|
|
|
|
if (U_FAILURE(status)) {
|
|
|
|
// Deserialization
|
|
|
|
locale = symbols->getLocale();
|
|
|
|
}
|
|
|
|
if (U_FAILURE(status)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
*formatter = NumberPropertyMapper::create(*properties, *symbols, *exportedProperties, status).locale(
|
|
|
|
locale);
|
|
|
|
parser = NumberParserImpl::createParserFromProperties(*properties, *symbols, false, false, status);
|
|
|
|
parserWithCurrency = NumberParserImpl::createParserFromProperties(
|
|
|
|
*properties, *symbols, true, false, status);
|
|
|
|
}
|
|
|
|
|
2018-03-13 10:11:36 +00:00
|
|
|
void DecimalFormat::refreshFormatterNoError() {
|
|
|
|
ErrorCode localStatus;
|
|
|
|
refreshFormatter(localStatus);
|
|
|
|
}
|
|
|
|
|
2018-03-13 09:25:41 +00:00
|
|
|
void DecimalFormat::setPropertiesFromPattern(const UnicodeString& pattern, int32_t ignoreRounding,
|
|
|
|
UErrorCode& status) {
|
|
|
|
// Cast workaround to get around putting the enum in the public header file
|
|
|
|
auto actualIgnoreRounding = static_cast<IgnoreRounding>(ignoreRounding);
|
|
|
|
PatternParser::parseToExistingProperties(pattern, *properties, actualIgnoreRounding, status);
|
|
|
|
}
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|