Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ****************************************************************************** |
michael@0 | 3 | * Copyright (C) 1997-2012, International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ****************************************************************************** |
michael@0 | 6 | * file name: nfrs.h |
michael@0 | 7 | * encoding: US-ASCII |
michael@0 | 8 | * tab size: 8 (not used) |
michael@0 | 9 | * indentation:4 |
michael@0 | 10 | * |
michael@0 | 11 | * Modification history |
michael@0 | 12 | * Date Name Comments |
michael@0 | 13 | * 10/11/2001 Doug Ported from ICU4J |
michael@0 | 14 | */ |
michael@0 | 15 | |
michael@0 | 16 | #ifndef NFRS_H |
michael@0 | 17 | #define NFRS_H |
michael@0 | 18 | |
michael@0 | 19 | #include "unicode/uobject.h" |
michael@0 | 20 | #include "unicode/rbnf.h" |
michael@0 | 21 | |
michael@0 | 22 | #if U_HAVE_RBNF |
michael@0 | 23 | |
michael@0 | 24 | #include "unicode/utypes.h" |
michael@0 | 25 | #include "unicode/umisc.h" |
michael@0 | 26 | |
michael@0 | 27 | #include "nfrlist.h" |
michael@0 | 28 | |
michael@0 | 29 | U_NAMESPACE_BEGIN |
michael@0 | 30 | |
michael@0 | 31 | class NFRuleSet : public UMemory { |
michael@0 | 32 | public: |
michael@0 | 33 | NFRuleSet(UnicodeString* descriptions, int32_t index, UErrorCode& status); |
michael@0 | 34 | void parseRules(UnicodeString& rules, const RuleBasedNumberFormat* owner, UErrorCode& status); |
michael@0 | 35 | void makeIntoFractionRuleSet() { fIsFractionRuleSet = TRUE; } |
michael@0 | 36 | |
michael@0 | 37 | ~NFRuleSet(); |
michael@0 | 38 | |
michael@0 | 39 | UBool operator==(const NFRuleSet& rhs) const; |
michael@0 | 40 | UBool operator!=(const NFRuleSet& rhs) const { return !operator==(rhs); } |
michael@0 | 41 | |
michael@0 | 42 | UBool isPublic() const { return fIsPublic; } |
michael@0 | 43 | |
michael@0 | 44 | UBool isParseable() const { return fIsParseable; } |
michael@0 | 45 | |
michael@0 | 46 | UBool isFractionRuleSet() const { return fIsFractionRuleSet; } |
michael@0 | 47 | |
michael@0 | 48 | void getName(UnicodeString& result) const { result.setTo(name); } |
michael@0 | 49 | UBool isNamed(const UnicodeString& _name) const { return this->name == _name; } |
michael@0 | 50 | |
michael@0 | 51 | void format(int64_t number, UnicodeString& toAppendTo, int32_t pos) const; |
michael@0 | 52 | void format(double number, UnicodeString& toAppendTo, int32_t pos) const; |
michael@0 | 53 | |
michael@0 | 54 | UBool parse(const UnicodeString& text, ParsePosition& pos, double upperBound, Formattable& result) const; |
michael@0 | 55 | |
michael@0 | 56 | void appendRules(UnicodeString& result) const; // toString |
michael@0 | 57 | |
michael@0 | 58 | private: |
michael@0 | 59 | NFRule * findNormalRule(int64_t number) const; |
michael@0 | 60 | NFRule * findDoubleRule(double number) const; |
michael@0 | 61 | NFRule * findFractionRuleSetRule(double number) const; |
michael@0 | 62 | |
michael@0 | 63 | private: |
michael@0 | 64 | UnicodeString name; |
michael@0 | 65 | NFRuleList rules; |
michael@0 | 66 | NFRule *negativeNumberRule; |
michael@0 | 67 | NFRule *fractionRules[3]; |
michael@0 | 68 | UBool fIsFractionRuleSet; |
michael@0 | 69 | UBool fIsPublic; |
michael@0 | 70 | UBool fIsParseable; |
michael@0 | 71 | int32_t fRecursionCount; |
michael@0 | 72 | |
michael@0 | 73 | NFRuleSet(const NFRuleSet &other); // forbid copying of this class |
michael@0 | 74 | NFRuleSet &operator=(const NFRuleSet &other); // forbid copying of this class |
michael@0 | 75 | }; |
michael@0 | 76 | |
michael@0 | 77 | // utilities from old llong.h |
michael@0 | 78 | // convert mantissa portion of double to int64 |
michael@0 | 79 | int64_t util64_fromDouble(double d); |
michael@0 | 80 | |
michael@0 | 81 | // raise radix to the power exponent, only non-negative exponents |
michael@0 | 82 | int64_t util64_pow(int32_t radix, uint32_t exponent); |
michael@0 | 83 | |
michael@0 | 84 | // convert n to digit string in buffer, return length of string |
michael@0 | 85 | uint32_t util64_tou(int64_t n, UChar* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE); |
michael@0 | 86 | |
michael@0 | 87 | #ifdef RBNF_DEBUG |
michael@0 | 88 | int64_t util64_utoi(const UChar* str, uint32_t radix = 10); |
michael@0 | 89 | uint32_t util64_toa(int64_t n, char* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE); |
michael@0 | 90 | int64_t util64_atoi(const char* str, uint32_t radix); |
michael@0 | 91 | #endif |
michael@0 | 92 | |
michael@0 | 93 | |
michael@0 | 94 | U_NAMESPACE_END |
michael@0 | 95 | |
michael@0 | 96 | /* U_HAVE_RBNF */ |
michael@0 | 97 | #endif |
michael@0 | 98 | |
michael@0 | 99 | // NFRS_H |
michael@0 | 100 | #endif |
michael@0 | 101 |