]> granicus.if.org Git - icu/commitdiff
ICU-13415 Refactoring shadowed virtual method in IFixedDecimal.
authorShane Carr <shane@unicode.org>
Mon, 23 Oct 2017 07:12:39 +0000 (07:12 +0000)
committerShane Carr <shane@unicode.org>
Mon, 23 Oct 2017 07:12:39 +0000 (07:12 +0000)
X-SVN-Rev: 40626

icu4c/source/i18n/plurrule.cpp
icu4c/source/i18n/plurrule_impl.h

index 48b7976baf388f5b465aa10ab79cbdc3c2b25b61..dcf28b2bc1a1beb7fa72c8f1bd852e0bee0f4982 100644 (file)
@@ -789,7 +789,9 @@ AndConstraint::isFulfilled(const IFixedDecimal &number) {
         // An empty AndConstraint, created by a rule with a keyword but no following expression.
         return TRUE;
     }
-    double n = number.getPluralOperand(digitsType);  // pulls n | i | v | f value for the number.
+
+    PluralOperand operand = tokenTypeToPluralOperand(digitsType);
+    double n = number.getPluralOperand(operand);     // pulls n | i | v | f value for the number.
                                                      // Will always be positive.
                                                      // May be non-integer (n option only)
     do {
@@ -1405,6 +1407,24 @@ PluralKeywordEnumeration::count(UErrorCode& /*status*/) const {
 PluralKeywordEnumeration::~PluralKeywordEnumeration() {
 }
 
+PluralOperand tokenTypeToPluralOperand(tokenType tt) {
+    switch(tt) {
+    case tVariableN:
+        return PLURAL_OPERAND_N;
+    case tVariableI:
+        return PLURAL_OPERAND_I;
+    case tVariableF:
+        return PLURAL_OPERAND_F;
+    case tVariableV:
+        return PLURAL_OPERAND_V;
+    case tVariableT:
+        return PLURAL_OPERAND_T;
+    default:
+        U_ASSERT(FALSE);  // unexpected.
+        return PLURAL_OPERAND_N;
+    }
+}
+
 IFixedDecimal::~IFixedDecimal() = default;
 
 FixedDecimal::FixedDecimal(const VisibleDigits &digits) {
index e4f3f3f6eaeb49483e1bf6578c685cc45442672f..b93fc501baced2d3b2961084659ac002ed107d0a 100644 (file)
@@ -221,6 +221,12 @@ enum PluralOperand {
     PLURAL_OPERAND_J
 };
 
+/**
+ * Converts from the tokenType enum to PluralOperand. Asserts that the given
+ * tokenType can be mapped to a PluralOperand.
+ */
+PluralOperand tokenTypeToPluralOperand(tokenType tt);
+
 /**
  * An interface to FixedDecimal, allowing for other implementations.
  * @internal
@@ -235,25 +241,6 @@ class U_I18N_API IFixedDecimal {
      */
     virtual double getPluralOperand(PluralOperand operand) const = 0;
 
-    /** Converts from the tokenType enum to PluralOperand. */
-    virtual double getPluralOperand(tokenType tt) const {
-        switch(tt) {
-        case tVariableN:
-            return getPluralOperand(PLURAL_OPERAND_N);
-        case tVariableI:
-            return getPluralOperand(PLURAL_OPERAND_I);
-        case tVariableF:
-            return getPluralOperand(PLURAL_OPERAND_F);
-        case tVariableV:
-            return getPluralOperand(PLURAL_OPERAND_V);
-        case tVariableT:
-            return getPluralOperand(PLURAL_OPERAND_T);
-        default:
-            U_ASSERT(FALSE);  // unexpected.
-            return 0.0;
-        }
-    }
-
     virtual bool isNaN() const = 0;
 
     virtual bool isInfinite() const = 0;