]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/scientificnumberformatter.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / i18n / scientificnumberformatter.cpp
index b3bc09939ceb9f13616990de01a336cdc7d39693..6c2cb3aeed27433b79bf0fda128bb20fb497eed7 100644 (file)
@@ -1,3 +1,5 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 **********************************************************************
 * Copyright (c) 2014, International Business Machines
@@ -13,8 +15,8 @@
 #include "unicode/fpositer.h"
 #include "unicode/utf16.h"
 #include "unicode/uniset.h"
-#include "decfmtst.h"
 #include "unicode/decimfmt.h"
+#include "static_unicode_sets.h"
 
 U_NAMESPACE_BEGIN
 
@@ -119,7 +121,7 @@ ScientificNumberFormatter *ScientificNumberFormatter::createInstance(
     return result;
 }
 
-ScientificNumberFormatter::Style *ScientificNumberFormatter::SuperscriptStyle::clone() const {
+ScientificNumberFormatter::SuperscriptStyle *ScientificNumberFormatter::SuperscriptStyle::clone() const {
     return new ScientificNumberFormatter::SuperscriptStyle(*this);
 }
 
@@ -127,7 +129,6 @@ UnicodeString &ScientificNumberFormatter::SuperscriptStyle::format(
         const UnicodeString &original,
         FieldPositionIterator &fpi,
         const UnicodeString &preExponent,
-        const DecimalFormatStaticSets &staticSets,
         UnicodeString &appendTo,
         UErrorCode &status) const {
     if (U_FAILURE(status)) {
@@ -147,16 +148,17 @@ UnicodeString &ScientificNumberFormatter::SuperscriptStyle::format(
             break;
         case UNUM_EXPONENT_SIGN_FIELD:
             {
+                using namespace icu::numparse::impl;
                 int32_t beginIndex = fp.getBeginIndex();
                 int32_t endIndex = fp.getEndIndex();
                 UChar32 aChar = original.char32At(beginIndex);
-                if (staticSets.fMinusSigns->contains(aChar)) {
+                if (unisets::get(unisets::MINUS_SIGN)->contains(aChar)) {
                     appendTo.append(
                             original,
                             copyFromOffset,
                             beginIndex - copyFromOffset);
                     appendTo.append(kSuperscriptMinusSign);
-                } else if (staticSets.fPlusSigns->contains(aChar)) {
+                } else if (unisets::get(unisets::PLUS_SIGN)->contains(aChar)) {
                     appendTo.append(
                            original,
                            copyFromOffset,
@@ -193,7 +195,7 @@ UnicodeString &ScientificNumberFormatter::SuperscriptStyle::format(
     return appendTo;
 }
 
-ScientificNumberFormatter::Style *ScientificNumberFormatter::MarkupStyle::clone() const {
+ScientificNumberFormatter::MarkupStyle *ScientificNumberFormatter::MarkupStyle::clone() const {
     return new ScientificNumberFormatter::MarkupStyle(*this);
 }
 
@@ -201,7 +203,6 @@ UnicodeString &ScientificNumberFormatter::MarkupStyle::format(
         const UnicodeString &original,
         FieldPositionIterator &fpi,
         const UnicodeString &preExponent,
-        const DecimalFormatStaticSets & /*unusedDecimalFormatSets*/,
         UnicodeString &appendTo,
         UErrorCode &status) const {
     if (U_FAILURE(status)) {
@@ -241,8 +242,7 @@ ScientificNumberFormatter::ScientificNumberFormatter(
         DecimalFormat *fmtToAdopt, Style *styleToAdopt, UErrorCode &status)
         : fPreExponent(),
           fDecimalFormat(fmtToAdopt),
-          fStyle(styleToAdopt),
-          fStaticSets(NULL) {
+          fStyle(styleToAdopt) {
     if (U_FAILURE(status)) {
         return;
     }
@@ -256,7 +256,6 @@ ScientificNumberFormatter::ScientificNumberFormatter(
         return;
     }
     getPreExponent(*sym, fPreExponent);
-    fStaticSets = DecimalFormatStaticSets::getStaticSets(status);
 }
 
 ScientificNumberFormatter::ScientificNumberFormatter(
@@ -264,8 +263,7 @@ ScientificNumberFormatter::ScientificNumberFormatter(
         : UObject(other),
           fPreExponent(other.fPreExponent),
           fDecimalFormat(NULL),
-          fStyle(NULL),
-          fStaticSets(other.fStaticSets) {
+          fStyle(NULL) {
     fDecimalFormat = static_cast<DecimalFormat *>(
             other.fDecimalFormat->clone());
     fStyle = other.fStyle->clone();
@@ -290,7 +288,6 @@ UnicodeString &ScientificNumberFormatter::format(
             original,
             fpi,
             fPreExponent,
-            *fStaticSets,
             appendTo,
             status);
 }