]> granicus.if.org Git - icu/commitdiff
ICU-13634 Removing superfluous abstraction "CharSequence" and "UnicodeStringCharSeque...
authorShane Carr <shane@unicode.org>
Sat, 21 Apr 2018 09:08:53 +0000 (09:08 +0000)
committerShane Carr <shane@unicode.org>
Sat, 21 Apr 2018 09:08:53 +0000 (09:08 +0000)
X-SVN-Rev: 41260

12 files changed:
icu4c/source/i18n/decimfmt.cpp
icu4c/source/i18n/number_affixutils.cpp
icu4c/source/i18n/number_affixutils.h
icu4c/source/i18n/number_mapper.cpp
icu4c/source/i18n/number_patternmodifier.cpp
icu4c/source/i18n/number_patternstring.cpp
icu4c/source/i18n/number_types.h
icu4c/source/i18n/number_utils.h
icu4c/source/i18n/numparse_affixes.cpp
icu4c/source/i18n/numparse_currency.cpp
icu4c/source/i18n/numparse_types.h
icu4c/source/test/intltest/numbertest_affixutils.cpp

index b9b95077fc21d8adf97319d431aebe155fc7126d..4a42fd187079b65cdc0aa88975876aa7bce90958 100644 (file)
@@ -920,13 +920,10 @@ UnicodeString& DecimalFormat::toPattern(UnicodeString& result) const {
     DecimalFormatProperties tprops(*fProperties);
     bool useCurrency = ((!tprops.currency.isNull()) || !tprops.currencyPluralInfo.fPtr.isNull() ||
                         !tprops.currencyUsage.isNull() || AffixUtils::hasCurrencySymbols(
-            UnicodeStringCharSequence(tprops.positivePrefixPattern), localStatus) ||
-                        AffixUtils::hasCurrencySymbols(
-                                UnicodeStringCharSequence(tprops.positiveSuffixPattern), localStatus) ||
-                        AffixUtils::hasCurrencySymbols(
-                                UnicodeStringCharSequence(tprops.negativePrefixPattern), localStatus) ||
-                        AffixUtils::hasCurrencySymbols(
-                                UnicodeStringCharSequence(tprops.negativeSuffixPattern), localStatus));
+            tprops.positivePrefixPattern, localStatus) || AffixUtils::hasCurrencySymbols(
+            tprops.positiveSuffixPattern, localStatus) || AffixUtils::hasCurrencySymbols(
+            tprops.negativePrefixPattern, localStatus) || AffixUtils::hasCurrencySymbols(
+            tprops.negativeSuffixPattern, localStatus));
     if (useCurrency) {
         tprops.minimumFractionDigits = fExportedProperties->minimumFractionDigits;
         tprops.maximumFractionDigits = fExportedProperties->maximumFractionDigits;
index 2d08414ddd68b6198f3045f5f1bde0141b01ad79..a61d8cdda42e02aaa78e58f9a06243affce0912a 100644 (file)
@@ -13,12 +13,12 @@ using namespace icu;
 using namespace icu::number;
 using namespace icu::number::impl;
 
-int32_t AffixUtils::estimateLength(const CharSequence &patternString, UErrorCode &status) {
+int32_t AffixUtils::estimateLength(const UnicodeString &patternString, UErrorCode &status) {
     AffixPatternState state = STATE_BASE;
     int32_t offset = 0;
     int32_t length = 0;
     for (; offset < patternString.length();) {
-        UChar32 cp = patternString.codePointAt(offset);
+        UChar32 cp = patternString.char32At(offset);
 
         switch (state) {
             case STATE_BASE:
@@ -79,12 +79,12 @@ int32_t AffixUtils::estimateLength(const CharSequence &patternString, UErrorCode
     return length;
 }
 
-UnicodeString AffixUtils::escape(const CharSequence &input) {
+UnicodeString AffixUtils::escape(const UnicodeString &input) {
     AffixPatternState state = STATE_BASE;
     int32_t offset = 0;
     UnicodeString output;
     for (; offset < input.length();) {
-        UChar32 cp = input.codePointAt(offset);
+        UChar32 cp = input.char32At(offset);
 
         switch (cp) {
             case u'\'':
@@ -154,7 +154,7 @@ Field AffixUtils::getFieldForType(AffixPatternType type) {
 }
 
 int32_t
-AffixUtils::unescape(const CharSequence &affixPattern, NumberStringBuilder &output, int32_t position,
+AffixUtils::unescape(const UnicodeString &affixPattern, NumberStringBuilder &output, int32_t position,
                      const SymbolProvider &provider, UErrorCode &status) {
     int32_t length = 0;
     AffixTag tag;
@@ -174,7 +174,7 @@ AffixUtils::unescape(const CharSequence &affixPattern, NumberStringBuilder &outp
     return length;
 }
 
-int32_t AffixUtils::unescapedCodePointCount(const CharSequence &affixPattern,
+int32_t AffixUtils::unescapedCodePointCount(const UnicodeString &affixPattern,
                                             const SymbolProvider &provider, UErrorCode &status) {
     int32_t length = 0;
     AffixTag tag;
@@ -193,7 +193,7 @@ int32_t AffixUtils::unescapedCodePointCount(const CharSequence &affixPattern,
 }
 
 bool
-AffixUtils::containsType(const CharSequence &affixPattern, AffixPatternType type, UErrorCode &status) {
+AffixUtils::containsType(const UnicodeString &affixPattern, AffixPatternType type, UErrorCode &status) {
     if (affixPattern.length() == 0) {
         return false;
     }
@@ -208,7 +208,7 @@ AffixUtils::containsType(const CharSequence &affixPattern, AffixPatternType type
     return false;
 }
 
-bool AffixUtils::hasCurrencySymbols(const CharSequence &affixPattern, UErrorCode &status) {
+bool AffixUtils::hasCurrencySymbols(const UnicodeString &affixPattern, UErrorCode &status) {
     if (affixPattern.length() == 0) {
         return false;
     }
@@ -223,9 +223,9 @@ bool AffixUtils::hasCurrencySymbols(const CharSequence &affixPattern, UErrorCode
     return false;
 }
 
-UnicodeString AffixUtils::replaceType(const CharSequence &affixPattern, AffixPatternType type,
+UnicodeString AffixUtils::replaceType(const UnicodeString &affixPattern, AffixPatternType type,
                                       char16_t replacementChar, UErrorCode &status) {
-    UnicodeString output = affixPattern.toUnicodeString();
+    UnicodeString output(affixPattern); // copy
     if (affixPattern.length() == 0) {
         return output;
     };
@@ -240,7 +240,7 @@ UnicodeString AffixUtils::replaceType(const CharSequence &affixPattern, AffixPat
     return output;
 }
 
-bool AffixUtils::containsOnlySymbolsAndIgnorables(const CharSequence& affixPattern,
+bool AffixUtils::containsOnlySymbolsAndIgnorables(const UnicodeString& affixPattern,
                                                   const UnicodeSet& ignorables, UErrorCode& status) {
     if (affixPattern.length() == 0) {
         return true;
@@ -256,7 +256,7 @@ bool AffixUtils::containsOnlySymbolsAndIgnorables(const CharSequence& affixPatte
     return true;
 }
 
-void AffixUtils::iterateWithConsumer(const CharSequence& affixPattern, TokenConsumer& consumer,
+void AffixUtils::iterateWithConsumer(const UnicodeString& affixPattern, TokenConsumer& consumer,
                                      UErrorCode& status) {
     if (affixPattern.length() == 0) {
         return;
@@ -270,11 +270,11 @@ void AffixUtils::iterateWithConsumer(const CharSequence& affixPattern, TokenCons
     }
 }
 
-AffixTag AffixUtils::nextToken(AffixTag tag, const CharSequence &patternString, UErrorCode &status) {
+AffixTag AffixUtils::nextToken(AffixTag tag, const UnicodeString &patternString, UErrorCode &status) {
     int32_t offset = tag.offset;
     int32_t state = tag.state;
     for (; offset < patternString.length();) {
-        UChar32 cp = patternString.codePointAt(offset);
+        UChar32 cp = patternString.char32At(offset);
         int32_t count = U16_LENGTH(cp);
 
         switch (state) {
@@ -413,7 +413,7 @@ AffixTag AffixUtils::nextToken(AffixTag tag, const CharSequence &patternString,
     }
 }
 
-bool AffixUtils::hasNext(const AffixTag &tag, const CharSequence &string) {
+bool AffixUtils::hasNext(const AffixTag &tag, const UnicodeString &string) {
     // First check for the {-1} and default initializer syntax.
     if (tag.offset < 0) {
         return false;
index d8b525a6e1f523ca6b4b014d50dd4db28aff045b..b34420dfeede46cedf22ab115be489db11d9cb47 100644 (file)
@@ -113,7 +113,7 @@ class U_I18N_API AffixUtils {
      * @param patternString The original string whose width will be estimated.
      * @return The length of the unescaped string.
      */
-    static int32_t estimateLength(const CharSequence& patternString, UErrorCode& status);
+    static int32_t estimateLength(const UnicodeString& patternString, UErrorCode& status);
 
     /**
      * Takes a string and escapes (quotes) characters that have special meaning in the affix pattern
@@ -124,7 +124,7 @@ class U_I18N_API AffixUtils {
      * @param input The string to be escaped.
      * @return The resulting UnicodeString.
      */
-    static UnicodeString escape(const CharSequence& input);
+    static UnicodeString escape(const UnicodeString& input);
 
     static Field getFieldForType(AffixPatternType type);
 
@@ -140,7 +140,7 @@ class U_I18N_API AffixUtils {
      * @param position The index into the NumberStringBuilder to insert the string.
      * @param provider An object to generate locale symbols.
      */
-    static int32_t unescape(const CharSequence& affixPattern, NumberStringBuilder& output,
+    static int32_t unescape(const UnicodeString& affixPattern, NumberStringBuilder& output,
                             int32_t position, const SymbolProvider& provider, UErrorCode& status);
 
     /**
@@ -151,7 +151,7 @@ class U_I18N_API AffixUtils {
      * @param provider An object to generate locale symbols.
      * @return The same return value as if you called {@link #unescape}.
      */
-    static int32_t unescapedCodePointCount(const CharSequence& affixPattern,
+    static int32_t unescapedCodePointCount(const UnicodeString& affixPattern,
                                            const SymbolProvider& provider, UErrorCode& status);
 
     /**
@@ -162,7 +162,7 @@ class U_I18N_API AffixUtils {
      * @param type The token type.
      * @return true if the affix pattern contains the given token type; false otherwise.
      */
-    static bool containsType(const CharSequence& affixPattern, AffixPatternType type, UErrorCode& status);
+    static bool containsType(const UnicodeString& affixPattern, AffixPatternType type, UErrorCode& status);
 
     /**
      * Checks whether the specified affix pattern has any unquoted currency symbols ("ยค").
@@ -170,7 +170,7 @@ class U_I18N_API AffixUtils {
      * @param affixPattern The string to check for currency symbols.
      * @return true if the literal has at least one unquoted currency symbol; false otherwise.
      */
-    static bool hasCurrencySymbols(const CharSequence& affixPattern, UErrorCode& status);
+    static bool hasCurrencySymbols(const UnicodeString& affixPattern, UErrorCode& status);
 
     /**
      * Replaces all occurrences of tokens with the given type with the given replacement char.
@@ -180,20 +180,20 @@ class U_I18N_API AffixUtils {
      * @param replacementChar The char to substitute in place of chars of the given token type.
      * @return A string containing the new affix pattern.
      */
-    static UnicodeString replaceType(const CharSequence& affixPattern, AffixPatternType type,
+    static UnicodeString replaceType(const UnicodeString& affixPattern, AffixPatternType type,
                                      char16_t replacementChar, UErrorCode& status);
 
     /**
      * Returns whether the given affix pattern contains only symbols and ignorables as defined by the
      * given ignorables set.
      */
-    static bool containsOnlySymbolsAndIgnorables(const CharSequence& affixPattern,
+    static bool containsOnlySymbolsAndIgnorables(const UnicodeString& affixPattern,
                                                  const UnicodeSet& ignorables, UErrorCode& status);
 
     /**
      * Iterates over the affix pattern, calling the TokenConsumer for each token.
      */
-    static void iterateWithConsumer(const CharSequence& affixPattern, TokenConsumer& consumer,
+    static void iterateWithConsumer(const UnicodeString& affixPattern, TokenConsumer& consumer,
                                     UErrorCode& status);
 
     /**
@@ -206,7 +206,7 @@ class U_I18N_API AffixUtils {
      *     (never negative), or -1 if there were no more tokens in the affix pattern.
      * @see #hasNext
      */
-    static AffixTag nextToken(AffixTag tag, const CharSequence& patternString, UErrorCode& status);
+    static AffixTag nextToken(AffixTag tag, const UnicodeString& patternString, UErrorCode& status);
 
     /**
      * Returns whether the affix pattern string has any more tokens to be retrieved from a call to
@@ -216,7 +216,7 @@ class U_I18N_API AffixUtils {
      * @param string The affix pattern.
      * @return true if there are more tokens to consume; false otherwise.
      */
-    static bool hasNext(const AffixTag& tag, const CharSequence& string);
+    static bool hasNext(const AffixTag& tag, const UnicodeString& string);
 
   private:
     /**
index b2cad1224d7deb885f3c52c037b56a79a1bb2503..cf48143ced4d5a5072c9ef699e7de7d07f5289f9 100644 (file)
@@ -326,10 +326,10 @@ void PropertiesAffixPatternProvider::setTo(const DecimalFormatProperties& proper
     // [p/n] => p for positive, n for negative
     // [p/s] => p for prefix, s for suffix
     // [o/p] => o for escaped custom override string, p for pattern string
-    UnicodeString ppo = AffixUtils::escape(UnicodeStringCharSequence(properties.positivePrefix));
-    UnicodeString pso = AffixUtils::escape(UnicodeStringCharSequence(properties.positiveSuffix));
-    UnicodeString npo = AffixUtils::escape(UnicodeStringCharSequence(properties.negativePrefix));
-    UnicodeString nso = AffixUtils::escape(UnicodeStringCharSequence(properties.negativeSuffix));
+    UnicodeString ppo = AffixUtils::escape(properties.positivePrefix);
+    UnicodeString pso = AffixUtils::escape(properties.positiveSuffix);
+    UnicodeString npo = AffixUtils::escape(properties.negativePrefix);
+    UnicodeString nso = AffixUtils::escape(properties.negativeSuffix);
     const UnicodeString& ppp = properties.positivePrefixPattern;
     const UnicodeString& psp = properties.positiveSuffixPattern;
     const UnicodeString& npp = properties.negativePrefixPattern;
@@ -402,8 +402,8 @@ const UnicodeString& PropertiesAffixPatternProvider::getStringInternal(int32_t f
 bool PropertiesAffixPatternProvider::positiveHasPlusSign() const {
     // TODO: Change the internal APIs to propagate out the error?
     ErrorCode localStatus;
-    return AffixUtils::containsType(UnicodeStringCharSequence(posPrefix), TYPE_PLUS_SIGN, localStatus) ||
-           AffixUtils::containsType(UnicodeStringCharSequence(posSuffix), TYPE_PLUS_SIGN, localStatus);
+    return AffixUtils::containsType(posPrefix, TYPE_PLUS_SIGN, localStatus) ||
+           AffixUtils::containsType(posSuffix, TYPE_PLUS_SIGN, localStatus);
 }
 
 bool PropertiesAffixPatternProvider::hasNegativeSubpattern() const {
@@ -413,23 +413,23 @@ bool PropertiesAffixPatternProvider::hasNegativeSubpattern() const {
 
 bool PropertiesAffixPatternProvider::negativeHasMinusSign() const {
     ErrorCode localStatus;
-    return AffixUtils::containsType(UnicodeStringCharSequence(negPrefix), TYPE_MINUS_SIGN, localStatus) ||
-           AffixUtils::containsType(UnicodeStringCharSequence(negSuffix), TYPE_MINUS_SIGN, localStatus);
+    return AffixUtils::containsType(negPrefix, TYPE_MINUS_SIGN, localStatus) ||
+           AffixUtils::containsType(negSuffix, TYPE_MINUS_SIGN, localStatus);
 }
 
 bool PropertiesAffixPatternProvider::hasCurrencySign() const {
     ErrorCode localStatus;
-    return AffixUtils::hasCurrencySymbols(UnicodeStringCharSequence(posPrefix), localStatus) ||
-           AffixUtils::hasCurrencySymbols(UnicodeStringCharSequence(posSuffix), localStatus) ||
-           AffixUtils::hasCurrencySymbols(UnicodeStringCharSequence(negPrefix), localStatus) ||
-           AffixUtils::hasCurrencySymbols(UnicodeStringCharSequence(negSuffix), localStatus);
+    return AffixUtils::hasCurrencySymbols(posPrefix, localStatus) ||
+           AffixUtils::hasCurrencySymbols(posSuffix, localStatus) ||
+           AffixUtils::hasCurrencySymbols(negPrefix, localStatus) ||
+           AffixUtils::hasCurrencySymbols(negSuffix, localStatus);
 }
 
 bool PropertiesAffixPatternProvider::containsSymbolType(AffixPatternType type, UErrorCode& status) const {
-    return AffixUtils::containsType(UnicodeStringCharSequence(posPrefix), type, status) ||
-           AffixUtils::containsType(UnicodeStringCharSequence(posSuffix), type, status) ||
-           AffixUtils::containsType(UnicodeStringCharSequence(negPrefix), type, status) ||
-           AffixUtils::containsType(UnicodeStringCharSequence(negSuffix), type, status);
+    return AffixUtils::containsType(posPrefix, type, status) ||
+           AffixUtils::containsType(posSuffix, type, status) ||
+           AffixUtils::containsType(negPrefix, type, status) ||
+           AffixUtils::containsType(negSuffix, type, status);
 }
 
 bool PropertiesAffixPatternProvider::hasBody() const {
index 52f0e4ef46d89071916d185d7232b09254bde218..1f88742608911ed1596b285d146588b0c16b0629 100644 (file)
@@ -206,10 +206,7 @@ int32_t MutablePatternModifier::getPrefixLength(UErrorCode& status) const {
 
     // Enter and exit CharSequence Mode to get the length.
     nonConstThis->prepareAffix(true);
-    int result = AffixUtils::unescapedCodePointCount(
-            UnicodeStringCharSequence(currentAffix),
-            *this,
-            status);  // prefix length
+    int result = AffixUtils::unescapedCodePointCount(currentAffix, *this, status);  // prefix length
     return result;
 }
 
@@ -220,15 +217,9 @@ int32_t MutablePatternModifier::getCodePointCount(UErrorCode& status) const {
 
     // Render the affixes to get the length
     nonConstThis->prepareAffix(true);
-    int result = AffixUtils::unescapedCodePointCount(
-            UnicodeStringCharSequence(currentAffix),
-            *this,
-            status);  // prefix length
+    int result = AffixUtils::unescapedCodePointCount(currentAffix, *this, status);  // prefix length
     nonConstThis->prepareAffix(false);
-    result += AffixUtils::unescapedCodePointCount(
-            UnicodeStringCharSequence(currentAffix),
-            *this,
-            status);  // suffix length
+    result += AffixUtils::unescapedCodePointCount(currentAffix, *this, status);  // suffix length
     return result;
 }
 
@@ -238,15 +229,13 @@ bool MutablePatternModifier::isStrong() const {
 
 int32_t MutablePatternModifier::insertPrefix(NumberStringBuilder& sb, int position, UErrorCode& status) {
     prepareAffix(true);
-    int length = AffixUtils::unescape(
-            UnicodeStringCharSequence(currentAffix), sb, position, *this, status);
+    int length = AffixUtils::unescape(currentAffix, sb, position, *this, status);
     return length;
 }
 
 int32_t MutablePatternModifier::insertSuffix(NumberStringBuilder& sb, int position, UErrorCode& status) {
     prepareAffix(false);
-    int length = AffixUtils::unescape(
-            UnicodeStringCharSequence(currentAffix), sb, position, *this, status);
+    int length = AffixUtils::unescape(currentAffix, sb, position, *this, status);
     return length;
 }
 
index 21bccbab697d64551d6cce25123721ba12dccf64..3dea96330efb89d3a1757d046de6b04acc3c3af1 100644 (file)
@@ -107,7 +107,7 @@ bool ParsedPatternInfo::hasCurrencySign() const {
 }
 
 bool ParsedPatternInfo::containsSymbolType(AffixPatternType type, UErrorCode& status) const {
-    return AffixUtils::containsType(UnicodeStringCharSequence(pattern), type, status);
+    return AffixUtils::containsType(pattern, type, status);
 }
 
 bool ParsedPatternInfo::hasBody() const {
@@ -592,8 +592,8 @@ PatternParser::patternInfoToProperties(DecimalFormatProperties& properties, Pars
     if (positive.hasPadding) {
         // The width of the positive prefix and suffix templates are included in the padding
         int paddingWidth = positive.widthExceptAffixes +
-                           AffixUtils::estimateLength(UnicodeStringCharSequence(posPrefix), status) +
-                           AffixUtils::estimateLength(UnicodeStringCharSequence(posSuffix), status);
+                           AffixUtils::estimateLength(posPrefix, status) +
+                           AffixUtils::estimateLength(posSuffix, status);
         properties.formatWidth = paddingWidth;
         UnicodeString rawPaddingString = patternInfo.getString(AffixPatternProvider::AFFIX_PADDING);
         if (rawPaddingString.length() == 1) {
@@ -677,7 +677,7 @@ UnicodeString PatternStringUtils::propertiesToPatternString(const DecimalFormatP
     if (!ppp.isBogus()) {
         sb.append(ppp);
     }
-    sb.append(AffixUtils::escape(UnicodeStringCharSequence(pp)));
+    sb.append(AffixUtils::escape(pp));
     int afterPrefixPos = sb.length();
 
     // Figure out the grouping sizes.
@@ -774,7 +774,7 @@ UnicodeString PatternStringUtils::propertiesToPatternString(const DecimalFormatP
     if (!psp.isBogus()) {
         sb.append(psp);
     }
-    sb.append(AffixUtils::escape(UnicodeStringCharSequence(ps)));
+    sb.append(AffixUtils::escape(ps));
 
     // Resolve Padding
     if (paddingWidth != -1 && !paddingLocation.isNull()) {
@@ -816,7 +816,7 @@ UnicodeString PatternStringUtils::propertiesToPatternString(const DecimalFormatP
         if (!npp.isBogus()) {
             sb.append(npp);
         }
-        sb.append(AffixUtils::escape(UnicodeStringCharSequence(np)));
+        sb.append(AffixUtils::escape(np));
         // Copy the positive digit format into the negative.
         // This is optional; the pattern is the same as if '#' were appended here instead.
         // NOTE: It is not safe to append the UnicodeString to itself, so we need to copy.
@@ -826,7 +826,7 @@ UnicodeString PatternStringUtils::propertiesToPatternString(const DecimalFormatP
         if (!nsp.isBogus()) {
             sb.append(nsp);
         }
-        sb.append(AffixUtils::escape(UnicodeStringCharSequence(ns)));
+        sb.append(AffixUtils::escape(ns));
     }
 
     return sb;
index ac7b095932555ce05531530716a37323d2d0dd50..5aaf538a17864c148e96f0e7146300db175992cd 100644 (file)
@@ -87,39 +87,6 @@ enum CompactType {
 };
 
 
-// TODO: Should this be moved somewhere else, maybe where other ICU classes can use it?
-// Exported as U_I18N_API because it is a base class for other exported types
-class U_I18N_API CharSequence {
-  public:
-    virtual ~CharSequence() = default;
-
-    virtual int32_t length() const = 0;
-
-    virtual char16_t charAt(int32_t index) const = 0;
-
-    virtual UChar32 codePointAt(int32_t index) const {
-        // Default implementation; can be overridden with a more efficient version
-        char16_t leading = charAt(index);
-        if (U16_IS_LEAD(leading) && length() > index + 1) {
-            char16_t trailing = charAt(index + 1);
-            return U16_GET_SUPPLEMENTARY(leading, trailing);
-        } else {
-            return leading;
-        }
-    }
-
-    /**
-     * Gets a "safe" UnicodeString that can be used even after the CharSequence is destructed.
-     * */
-    virtual UnicodeString toUnicodeString() const = 0;
-
-    /**
-     * Gets an "unsafe" UnicodeString that is valid only as long as the CharSequence is alive and
-     * unchanged. Slightly faster than toUnicodeString().
-     */
-    virtual const UnicodeString toTempUnicodeString() const = 0;
-};
-
 class U_I18N_API AffixPatternProvider {
   public:
     static const int32_t AFFIX_PLURAL_MASK = 0xff;
index 1b4000d78c1fd209f49aff8335fe002e509524b4..3ac541de023968f12a92b527a4bd971eb9c23bb2 100644 (file)
 U_NAMESPACE_BEGIN namespace number {
 namespace impl {
 
-class UnicodeStringCharSequence : public CharSequence {
-  public:
-    explicit UnicodeStringCharSequence(const UnicodeString& other) {
-        fStr = other;
-    }
-
-    ~UnicodeStringCharSequence() U_OVERRIDE = default;
-
-    int32_t length() const U_OVERRIDE {
-        return fStr.length();
-    }
-
-    char16_t charAt(int32_t index) const U_OVERRIDE {
-        return fStr.charAt(index);
-    }
-
-    UChar32 codePointAt(int32_t index) const U_OVERRIDE {
-        return fStr.char32At(index);
-    }
-
-    UnicodeString toUnicodeString() const U_OVERRIDE {
-        // Performs a copy:
-        return fStr;
-    }
-
-    const UnicodeString toTempUnicodeString() const U_OVERRIDE {
-        // Readonly alias:
-        return UnicodeString().fastCopyFrom(fStr);
-    }
-
-  private:
-    UnicodeString fStr;
-};
-
 struct MicroProps : public MicroPropsGenerator {
 
     // NOTE: All of these fields are properly initialized in NumberFormatterImpl.
index 0ac1fe7c0e9ff0ee0ca98a454060628dd0408fd6..259fab7c6c3d899855d14b803542ec9c64220030 100644 (file)
@@ -240,7 +240,7 @@ AffixPatternMatcher AffixPatternMatcher::fromAffixPattern(const UnicodeString& a
     }
 
     AffixPatternMatcherBuilder builder(affixPattern, tokenWarehouse, ignorables);
-    AffixUtils::iterateWithConsumer(UnicodeStringCharSequence(affixPattern), builder, status);
+    AffixUtils::iterateWithConsumer(affixPattern, builder, status);
     return builder.build();
 }
 
@@ -264,13 +264,13 @@ AffixMatcherWarehouse::AffixMatcherWarehouse(AffixTokenMatcherWarehouse* tokenWa
 bool AffixMatcherWarehouse::isInteresting(const AffixPatternProvider& patternInfo,
                                           const IgnorablesMatcher& ignorables, parse_flags_t parseFlags,
                                           UErrorCode& status) {
-    UnicodeStringCharSequence posPrefixString(patternInfo.getString(AffixPatternProvider::AFFIX_POS_PREFIX));
-    UnicodeStringCharSequence posSuffixString(patternInfo.getString(AffixPatternProvider::AFFIX_POS_SUFFIX));
-    UnicodeStringCharSequence negPrefixString(UnicodeString(u""));
-    UnicodeStringCharSequence negSuffixString(UnicodeString(u""));
+    UnicodeString posPrefixString = patternInfo.getString(AffixPatternProvider::AFFIX_POS_PREFIX);
+    UnicodeString posSuffixString = patternInfo.getString(AffixPatternProvider::AFFIX_POS_SUFFIX);
+    UnicodeString negPrefixString;
+    UnicodeString negSuffixString;
     if (patternInfo.hasNegativeSubpattern()) {
-        negPrefixString = UnicodeStringCharSequence(patternInfo.getString(AffixPatternProvider::AFFIX_NEG_PREFIX));
-        negSuffixString = UnicodeStringCharSequence(patternInfo.getString(AffixPatternProvider::AFFIX_NEG_SUFFIX));
+        negPrefixString = patternInfo.getString(AffixPatternProvider::AFFIX_NEG_PREFIX);
+        negSuffixString = patternInfo.getString(AffixPatternProvider::AFFIX_NEG_SUFFIX);
     }
 
     if (0 == (parseFlags & PARSE_FLAG_USE_FULL_AFFIXES) &&
index 7b59885072d6e98cb5e2191ce89c5aad7bc3b2f5..52bbb51794084955716311d698b8f60deb1d1822 100644 (file)
@@ -126,7 +126,7 @@ bool CombinedCurrencyMatcher::matchCurrency(StringSegment& segment, ParsedNumber
            partialMatchLen == segment.length();
 }
 
-bool CombinedCurrencyMatcher::smokeTest(const StringSegment& segment) const {
+bool CombinedCurrencyMatcher::smokeTest(const StringSegment&) const {
     // TODO: See constructor
     return true;
     //return segment.startsWith(fLeadCodePoints);
index aa64497545266a2d7a47b7997246d4ebaa55d000..469d827040da3c9712dfd2163d2d4ac16d1c2f74 100644 (file)
@@ -171,7 +171,7 @@ class ParsedNumber {
  *
  * @author sffc
  */
-class StringSegment : public UMemory, public ::icu::number::impl::CharSequence {
+class StringSegment : public UMemory {
   public:
     StringSegment(const UnicodeString& str, bool ignoreCase);
 
@@ -198,15 +198,15 @@ class StringSegment : public UMemory, public ::icu::number::impl::CharSequence {
 
     void resetLength();
 
-    int32_t length() const override;
+    int32_t length() const;
 
-    char16_t charAt(int32_t index) const override;
+    char16_t charAt(int32_t index) const;
 
-    UChar32 codePointAt(int32_t index) const override;
+    UChar32 codePointAt(int32_t index) const;
 
-    UnicodeString toUnicodeString() const override;
+    UnicodeString toUnicodeString() const;
 
-    const UnicodeString toTempUnicodeString() const override;
+    const UnicodeString toTempUnicodeString() const;
 
     /**
      * Returns the first code point in the string segment, or -1 if the string starts with an invalid
index 1d0dcc710b8aa75f2412d3a594ced0601722ca8c..cf0bf39944fc0573d5a1a92b28090bdd03df2b1b 100644 (file)
@@ -77,7 +77,7 @@ void AffixUtilsTest::testEscape() {
     for (auto &cas : cases) {
         UnicodeString input(cas[0]);
         UnicodeString expected(cas[1]);
-        UnicodeString result = AffixUtils::escape(UnicodeStringCharSequence(input));
+        UnicodeString result = AffixUtils::escape(input);
         assertEquals(input, expected, result);
     }
 }
@@ -130,16 +130,16 @@ void AffixUtilsTest::testUnescape() {
         UnicodeString input(cas.input);
         UnicodeString output(cas.output);
 
-        assertEquals(input, cas.currency, AffixUtils::hasCurrencySymbols(UnicodeStringCharSequence(input), status));
+        assertEquals(input, cas.currency, AffixUtils::hasCurrencySymbols(input, status));
         assertSuccess("Spot 1", status);
-        assertEquals(input, cas.expectedLength, AffixUtils::estimateLength(UnicodeStringCharSequence(input), status));
+        assertEquals(input, cas.expectedLength, AffixUtils::estimateLength(input, status));
         assertSuccess("Spot 2", status);
 
         UnicodeString actual = unescapeWithDefaults(defaultProvider, input, status);
         assertSuccess("Spot 3", status);
         assertEquals(input, output, actual);
 
-        int32_t ulength = AffixUtils::unescapedCodePointCount(UnicodeStringCharSequence(input), defaultProvider, status);
+        int32_t ulength = AffixUtils::unescapedCodePointCount(input, defaultProvider, status);
         assertSuccess("Spot 4", status);
         assertEquals(input, output.countChar32(), ulength);
     }
@@ -165,10 +165,10 @@ void AffixUtilsTest::testContainsReplaceType() {
         UnicodeString output(cas.output);
 
         assertEquals(
-                input, hasMinusSign, AffixUtils::containsType(UnicodeStringCharSequence(input), TYPE_MINUS_SIGN, status));
+                input, hasMinusSign, AffixUtils::containsType(input, TYPE_MINUS_SIGN, status));
         assertSuccess("Spot 1", status);
         assertEquals(
-                input, output, AffixUtils::replaceType(UnicodeStringCharSequence(input), TYPE_MINUS_SIGN, u'+', status));
+                input, output, AffixUtils::replaceType(input, TYPE_MINUS_SIGN, u'+', status));
         assertSuccess("Spot 2", status);
     }
 }
@@ -185,11 +185,11 @@ void AffixUtilsTest::testInvalid() {
         UnicodeString str(strPtr);
 
         status = U_ZERO_ERROR;
-        AffixUtils::hasCurrencySymbols(UnicodeStringCharSequence(str), status);
+        AffixUtils::hasCurrencySymbols(str, status);
         assertEquals("Should set error code spot 1", status, U_ILLEGAL_ARGUMENT_ERROR);
 
         status = U_ZERO_ERROR;
-        AffixUtils::estimateLength(UnicodeStringCharSequence(str), status);
+        AffixUtils::estimateLength(str, status);
         assertEquals("Should set error code spot 2", status, U_ILLEGAL_ARGUMENT_ERROR);
 
         status = U_ZERO_ERROR;
@@ -219,11 +219,11 @@ void AffixUtilsTest::testUnescapeWithSymbolProvider() {
 
     UErrorCode status = U_ZERO_ERROR;
     NumberStringBuilder sb;
-    for (auto cas : cases) {
+    for (auto& cas : cases) {
         UnicodeString input(cas[0]);
         UnicodeString expected(cas[1]);
         sb.clear();
-        AffixUtils::unescape(UnicodeStringCharSequence(input), sb, 0, provider, status);
+        AffixUtils::unescape(input, sb, 0, provider, status);
         assertSuccess("Spot 1", status);
         assertEquals(input, expected, sb.toUnicodeString());
         assertEquals(input, expected, sb.toTempUnicodeString());
@@ -233,7 +233,7 @@ void AffixUtilsTest::testUnescapeWithSymbolProvider() {
     sb.clear();
     sb.append(u"abcdefg", UNUM_FIELD_COUNT, status);
     assertSuccess("Spot 2", status);
-    AffixUtils::unescape(UnicodeStringCharSequence(UnicodeString(u"-+%")), sb, 4, provider, status);
+    AffixUtils::unescape(u"-+%", sb, 4, provider, status);
     assertSuccess("Spot 3", status);
     assertEquals(u"Symbol provider into middle", u"abcd123efg", sb.toUnicodeString());
 }
@@ -241,7 +241,7 @@ void AffixUtilsTest::testUnescapeWithSymbolProvider() {
 UnicodeString AffixUtilsTest::unescapeWithDefaults(const SymbolProvider &defaultProvider,
                                                           UnicodeString input, UErrorCode &status) {
     NumberStringBuilder nsb;
-    int32_t length = AffixUtils::unescape(UnicodeStringCharSequence(input), nsb, 0, defaultProvider, status);
+    int32_t length = AffixUtils::unescape(input, nsb, 0, defaultProvider, status);
     assertEquals("Return value of unescape", nsb.length(), length);
     return nsb.toUnicodeString();
 }