| OLD | NEW |
| 1 /* | 1 /* |
| 2 ****************************************************************************** | 2 ****************************************************************************** |
| 3 * Copyright (C) 1997-2014, International Business Machines | 3 * Copyright (C) 1997-2015, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
| 5 ****************************************************************************** | 5 ****************************************************************************** |
| 6 * file name: nfrs.h | 6 * file name: nfrs.h |
| 7 * encoding: US-ASCII | 7 * encoding: US-ASCII |
| 8 * tab size: 8 (not used) | 8 * tab size: 8 (not used) |
| 9 * indentation:4 | 9 * indentation:4 |
| 10 * | 10 * |
| 11 * Modification history | 11 * Modification history |
| 12 * Date Name Comments | 12 * Date Name Comments |
| 13 * 10/11/2001 Doug Ported from ICU4J | 13 * 10/11/2001 Doug Ported from ICU4J |
| 14 */ | 14 */ |
| 15 | 15 |
| 16 #ifndef NFRS_H | 16 #ifndef NFRS_H |
| 17 #define NFRS_H | 17 #define NFRS_H |
| 18 | 18 |
| 19 #include "unicode/uobject.h" | 19 #include "unicode/uobject.h" |
| 20 #include "unicode/rbnf.h" | 20 #include "unicode/rbnf.h" |
| 21 | 21 |
| 22 #if U_HAVE_RBNF | 22 #if U_HAVE_RBNF |
| 23 | 23 |
| 24 #include "unicode/utypes.h" | 24 #include "unicode/utypes.h" |
| 25 #include "unicode/umisc.h" | 25 #include "unicode/umisc.h" |
| 26 | 26 |
| 27 #include "nfrlist.h" | 27 #include "nfrlist.h" |
| 28 | 28 |
| 29 U_NAMESPACE_BEGIN | 29 U_NAMESPACE_BEGIN |
| 30 | 30 |
| 31 class NFRuleSet : public UMemory { | 31 class NFRuleSet : public UMemory { |
| 32 public: | 32 public: |
| 33 NFRuleSet(UnicodeString* descriptions, int32_t index, UErrorCode& status); | 33 NFRuleSet(RuleBasedNumberFormat *owner, UnicodeString* descriptions, int32_t
index, UErrorCode& status); |
| 34 void parseRules(UnicodeString& rules, const RuleBasedNumberFormat* owner, UE
rrorCode& status); | 34 void parseRules(UnicodeString& rules, UErrorCode& status); |
| 35 void setNonNumericalRule(NFRule *rule); |
| 36 void setBestFractionRule(int32_t originalIndex, NFRule *newRule, UBool remem
berRule); |
| 35 void makeIntoFractionRuleSet() { fIsFractionRuleSet = TRUE; } | 37 void makeIntoFractionRuleSet() { fIsFractionRuleSet = TRUE; } |
| 36 | 38 |
| 37 ~NFRuleSet(); | 39 ~NFRuleSet(); |
| 38 | 40 |
| 39 UBool operator==(const NFRuleSet& rhs) const; | 41 UBool operator==(const NFRuleSet& rhs) const; |
| 40 UBool operator!=(const NFRuleSet& rhs) const { return !operator==(rhs); } | 42 UBool operator!=(const NFRuleSet& rhs) const { return !operator==(rhs); } |
| 41 | 43 |
| 42 UBool isPublic() const { return fIsPublic; } | 44 UBool isPublic() const { return fIsPublic; } |
| 43 | 45 |
| 44 UBool isParseable() const { return fIsParseable; } | 46 UBool isParseable() const { return fIsParseable; } |
| 45 | 47 |
| 46 UBool isFractionRuleSet() const { return fIsFractionRuleSet; } | 48 UBool isFractionRuleSet() const { return fIsFractionRuleSet; } |
| 47 | 49 |
| 48 void getName(UnicodeString& result) const { result.setTo(name); } | 50 void getName(UnicodeString& result) const { result.setTo(name); } |
| 49 UBool isNamed(const UnicodeString& _name) const { return this->name == _name
; } | 51 UBool isNamed(const UnicodeString& _name) const { return this->name == _name
; } |
| 50 | 52 |
| 51 void format(int64_t number, UnicodeString& toAppendTo, int32_t pos, UErrorC
ode& status) const; | 53 void format(int64_t number, UnicodeString& toAppendTo, int32_t pos, int32_t
recursionCount, UErrorCode& status) const; |
| 52 void format(double number, UnicodeString& toAppendTo, int32_t pos, UErrorCo
de& status) const; | 54 void format(double number, UnicodeString& toAppendTo, int32_t pos, int32_t
recursionCount, UErrorCode& status) const; |
| 53 | 55 |
| 54 UBool parse(const UnicodeString& text, ParsePosition& pos, double upperBound
, Formattable& result) const; | 56 UBool parse(const UnicodeString& text, ParsePosition& pos, double upperBound
, Formattable& result) const; |
| 55 | 57 |
| 56 void appendRules(UnicodeString& result) const; // toString | 58 void appendRules(UnicodeString& result) const; // toString |
| 57 | 59 |
| 60 void setDecimalFormatSymbols(const DecimalFormatSymbols &newSymbols, UErrorC
ode& status); |
| 61 |
| 62 const RuleBasedNumberFormat *getOwner() const { return owner; } |
| 58 private: | 63 private: |
| 59 NFRule * findNormalRule(int64_t number) const; | 64 const NFRule * findNormalRule(int64_t number) const; |
| 60 NFRule * findDoubleRule(double number) const; | 65 const NFRule * findDoubleRule(double number) const; |
| 61 NFRule * findFractionRuleSetRule(double number) const; | 66 const NFRule * findFractionRuleSetRule(double number) const; |
| 67 |
| 68 friend class NFSubstitution; |
| 62 | 69 |
| 63 private: | 70 private: |
| 64 UnicodeString name; | 71 UnicodeString name; |
| 65 NFRuleList rules; | 72 NFRuleList rules; |
| 66 NFRule *negativeNumberRule; | 73 NFRule *nonNumericalRules[6]; |
| 67 NFRule *fractionRules[3]; | 74 RuleBasedNumberFormat *owner; |
| 75 NFRuleList fractionRules; |
| 68 UBool fIsFractionRuleSet; | 76 UBool fIsFractionRuleSet; |
| 69 UBool fIsPublic; | 77 UBool fIsPublic; |
| 70 UBool fIsParseable; | 78 UBool fIsParseable; |
| 71 int32_t fRecursionCount; | |
| 72 | 79 |
| 73 NFRuleSet(const NFRuleSet &other); // forbid copying of this class | 80 NFRuleSet(const NFRuleSet &other); // forbid copying of this class |
| 74 NFRuleSet &operator=(const NFRuleSet &other); // forbid copying of this clas
s | 81 NFRuleSet &operator=(const NFRuleSet &other); // forbid copying of this clas
s |
| 75 }; | 82 }; |
| 76 | 83 |
| 77 // utilities from old llong.h | 84 // utilities from old llong.h |
| 78 // convert mantissa portion of double to int64 | 85 // convert mantissa portion of double to int64 |
| 79 int64_t util64_fromDouble(double d); | 86 int64_t util64_fromDouble(double d); |
| 80 | 87 |
| 81 // raise radix to the power exponent, only non-negative exponents | 88 // raise radix to the power exponent, only non-negative exponents |
| (...skipping 10 matching lines...) Expand all Loading... |
| 92 | 99 |
| 93 | 100 |
| 94 U_NAMESPACE_END | 101 U_NAMESPACE_END |
| 95 | 102 |
| 96 /* U_HAVE_RBNF */ | 103 /* U_HAVE_RBNF */ |
| 97 #endif | 104 #endif |
| 98 | 105 |
| 99 // NFRS_H | 106 // NFRS_H |
| 100 #endif | 107 #endif |
| 101 | 108 |
| OLD | NEW |