X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/374ca955a76ecab1204ca8bfa63ff9238d998416..b331163bffd790ced0e88b73f44f86d49ccc48a5:/icuSources/i18n/nfrs.h diff --git a/icuSources/i18n/nfrs.h b/icuSources/i18n/nfrs.h index d28fde1d..769d3277 100644 --- a/icuSources/i18n/nfrs.h +++ b/icuSources/i18n/nfrs.h @@ -1,6 +1,6 @@ /* ****************************************************************************** -* Copyright (C) 1997-2004, International Business Machines +* Copyright (C) 1997-2014, International Business Machines * Corporation and others. All Rights Reserved. ****************************************************************************** * file name: nfrs.h @@ -29,45 +29,56 @@ U_NAMESPACE_BEGIN class NFRuleSet : public UMemory { - public: - NFRuleSet(UnicodeString* descriptions, int32_t index, UErrorCode& status); - void parseRules(UnicodeString& rules, const RuleBasedNumberFormat* owner, UErrorCode& status); - void makeIntoFractionRuleSet() { fIsFractionRuleSet = TRUE; } +public: + NFRuleSet(UnicodeString* descriptions, int32_t index, UErrorCode& status); + void parseRules(UnicodeString& rules, const RuleBasedNumberFormat* owner, UErrorCode& status); + void makeIntoFractionRuleSet() { fIsFractionRuleSet = TRUE; } - ~NFRuleSet(); + ~NFRuleSet(); - UBool operator==(const NFRuleSet& rhs) const; - UBool operator!=(const NFRuleSet& rhs) const { return !operator==(rhs); } + UBool operator==(const NFRuleSet& rhs) const; + UBool operator!=(const NFRuleSet& rhs) const { return !operator==(rhs); } - UBool isPublic() const { return fIsPublic; } - UBool isFractionRuleSet() const { return fIsFractionRuleSet; } + UBool isPublic() const { return fIsPublic; } - void getName(UnicodeString& result) const { result.setTo(name); } - UBool isNamed(const UnicodeString& _name) const { return this->name == _name; } + UBool isParseable() const { return fIsParseable; } - void format(int64_t number, UnicodeString& toAppendTo, int32_t pos) const; - void format(double number, UnicodeString& toAppendTo, int32_t pos) const; + UBool isDecimalFormatRuleParseable() const { + UnicodeString numberingYear = UNICODE_STRING_SIMPLE("spellout-numbering-year"); + UnicodeString ordinal = UNICODE_STRING_SIMPLE("spellout-ordinal"); - UBool parse(const UnicodeString& text, ParsePosition& pos, double upperBound, Formattable& result) const; + return ( name.indexOf(numberingYear) == -1 && name.indexOf(ordinal) == -1 ); + } - void appendRules(UnicodeString& result) const; // toString + UBool isFractionRuleSet() const { return fIsFractionRuleSet; } - private: - NFRule * findNormalRule(int64_t number) const; - NFRule * findDoubleRule(double number) const; - NFRule * findFractionRuleSetRule(double number) const; + void getName(UnicodeString& result) const { result.setTo(name); } + UBool isNamed(const UnicodeString& _name) const { return this->name == _name; } - private: - UnicodeString name; - NFRuleList rules; - NFRule *negativeNumberRule; - NFRule *fractionRules[3]; - UBool fIsFractionRuleSet; - UBool fIsPublic; - int32_t fRecursionCount; + void format(int64_t number, UnicodeString& toAppendTo, int32_t pos, UErrorCode& status) const; + void format(double number, UnicodeString& toAppendTo, int32_t pos, UErrorCode& status) const; - NFRuleSet(const NFRuleSet &other); // forbid copying of this class - NFRuleSet &operator=(const NFRuleSet &other); // forbid copying of this class + UBool parse(const UnicodeString& text, ParsePosition& pos, double upperBound, Formattable& result, UBool lenient=FALSE) const; + + void appendRules(UnicodeString& result) const; // toString + +private: + NFRule * findNormalRule(int64_t number) const; + NFRule * findDoubleRule(double number) const; + NFRule * findFractionRuleSetRule(double number) const; + +private: + UnicodeString name; + NFRuleList rules; + NFRule *negativeNumberRule; + NFRule *fractionRules[3]; + UBool fIsFractionRuleSet; + UBool fIsPublic; + UBool fIsParseable; + int32_t fRecursionCount; + + NFRuleSet(const NFRuleSet &other); // forbid copying of this class + NFRuleSet &operator=(const NFRuleSet &other); // forbid copying of this class }; // utilities from old llong.h @@ -79,9 +90,9 @@ int64_t util64_pow(int32_t radix, uint32_t exponent); // convert n to digit string in buffer, return length of string uint32_t util64_tou(int64_t n, UChar* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE); -int64_t util64_utoi(const UChar* str, uint32_t radix = 10); #ifdef RBNF_DEBUG +int64_t util64_utoi(const UChar* str, uint32_t radix = 10); uint32_t util64_toa(int64_t n, char* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE); int64_t util64_atoi(const char* str, uint32_t radix); #endif