compactdecimalformat.cpp 2.2 KB

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