X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/374ca955a76ecab1204ca8bfa63ff9238d998416..3d1f044b704633e2e541231cd17ae9ecf9ad5c7a:/icuSources/i18n/nfrule.h diff --git a/icuSources/i18n/nfrule.h b/icuSources/i18n/nfrule.h index 757a524a..cfd43506 100644 --- a/icuSources/i18n/nfrule.h +++ b/icuSources/i18n/nfrule.h @@ -1,6 +1,9 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* -* Copyright (C) 1997-2004, International Business Machines Corporation and others. All Rights Reserved. +* Copyright (C) 1997-2015, International Business Machines +* Corporation and others. All Rights Reserved. ******************************************************************************* */ @@ -14,7 +17,6 @@ #include "unicode/utypes.h" #include "unicode/uobject.h" #include "unicode/unistr.h" -#include "putilimp.h" U_NAMESPACE_BEGIN @@ -24,6 +26,7 @@ class NFRuleList; class NFRuleSet; class NFSubstitution; class ParsePosition; +class PluralFormat; class RuleBasedNumberFormat; class UnicodeString; @@ -36,17 +39,19 @@ public: kImproperFractionRule = -2, kProperFractionRule = -3, kMasterRule = -4, - kOtherRule = -5 + kInfinityRule = -5, + kNaNRule = -6, + kOtherRule = -7 }; static void makeRules(UnicodeString& definition, - const NFRuleSet* ruleSet, + NFRuleSet* ruleSet, const NFRule* predecessor, const RuleBasedNumberFormat* rbnf, NFRuleList& ruleList, UErrorCode& status); - NFRule(const RuleBasedNumberFormat* rbnf); + NFRule(const RuleBasedNumberFormat* rbnf, const UnicodeString &ruleText, UErrorCode &status); ~NFRule(); UBool operator==(const NFRule& rhs) const; @@ -58,35 +63,45 @@ public: int64_t getBaseValue() const { return baseValue; } void setBaseValue(int64_t value, UErrorCode& status); - double getDivisor() const { return uprv_pow(radix, exponent); } + UChar getDecimalPoint() const { return decimalPoint; } - void doFormat(int64_t number, UnicodeString& toAppendTo, int32_t pos) const; - void doFormat(double number, UnicodeString& toAppendTo, int32_t pos) const; + int64_t getDivisor() const; + + void doFormat(int64_t number, UnicodeString& toAppendTo, int32_t pos, int32_t recursionCount, UErrorCode& status) const; + void doFormat(double number, UnicodeString& toAppendTo, int32_t pos, int32_t recursionCount, UErrorCode& status) const; UBool doParse(const UnicodeString& text, ParsePosition& pos, UBool isFractional, double upperBound, - Formattable& result) const; + uint32_t nonNumericalExecutedRuleMask, + Formattable& result, + UBool isDecimFmtParseable=TRUE) const; + + UBool shouldRollBack(int64_t number) const; - UBool shouldRollBack(double number) const; + void _appendRuleText(UnicodeString& result) const; + + int32_t findTextLenient(const UnicodeString& str, const UnicodeString& key, + int32_t startingAt, int32_t* resultCount) const; - void appendRuleText(UnicodeString& result) const; + void setDecimalFormatSymbols(const DecimalFormatSymbols &newSymbols, UErrorCode& status); private: void parseRuleDescriptor(UnicodeString& descriptor, UErrorCode& status); - void extractSubstitutions(const NFRuleSet* ruleSet, const NFRule* predecessor, const RuleBasedNumberFormat* rbnf, UErrorCode& status); - NFSubstitution* extractSubstitution(const NFRuleSet* ruleSet, const NFRule* predecessor, const RuleBasedNumberFormat* rbnf, UErrorCode& status); + void extractSubstitutions(const NFRuleSet* ruleSet, const UnicodeString &ruleText, const NFRule* predecessor, UErrorCode& status); + NFSubstitution* extractSubstitution(const NFRuleSet* ruleSet, const NFRule* predecessor, UErrorCode& status); int16_t expectedExponent() const; - int32_t indexOfAny(const UChar* const strings[]) const; + int32_t indexOfAnyRulePrefix() const; double matchToDelimiter(const UnicodeString& text, int32_t startPos, double baseValue, const UnicodeString& delimiter, ParsePosition& pp, const NFSubstitution* sub, + uint32_t nonNumericalExecutedRuleMask, double upperBound) const; void stripPrefix(UnicodeString& text, const UnicodeString& prefix, ParsePosition& pp) const; - int32_t prefixLength(const UnicodeString& str, const UnicodeString& prefix) const; - UBool allIgnorable(const UnicodeString& str) const; + int32_t prefixLength(const UnicodeString& str, const UnicodeString& prefix, UErrorCode& status) const; + UBool allIgnorable(const UnicodeString& str, UErrorCode& status) const; int32_t findText(const UnicodeString& str, const UnicodeString& key, int32_t startingAt, int32_t* resultCount) const; @@ -94,10 +109,12 @@ private: int64_t baseValue; int32_t radix; int16_t exponent; - UnicodeString ruleText; + UChar decimalPoint; + UnicodeString fRuleText; NFSubstitution* sub1; NFSubstitution* sub2; const RuleBasedNumberFormat* formatter; + const PluralFormat* rulePatternFormat; NFRule(const NFRule &other); // forbid copying of this class NFRule &operator=(const NFRule &other); // forbid copying of this class