1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/nfrs.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,101 @@ 1.4 +/* 1.5 +****************************************************************************** 1.6 +* Copyright (C) 1997-2012, International Business Machines 1.7 +* Corporation and others. All Rights Reserved. 1.8 +****************************************************************************** 1.9 +* file name: nfrs.h 1.10 +* encoding: US-ASCII 1.11 +* tab size: 8 (not used) 1.12 +* indentation:4 1.13 +* 1.14 +* Modification history 1.15 +* Date Name Comments 1.16 +* 10/11/2001 Doug Ported from ICU4J 1.17 +*/ 1.18 + 1.19 +#ifndef NFRS_H 1.20 +#define NFRS_H 1.21 + 1.22 +#include "unicode/uobject.h" 1.23 +#include "unicode/rbnf.h" 1.24 + 1.25 +#if U_HAVE_RBNF 1.26 + 1.27 +#include "unicode/utypes.h" 1.28 +#include "unicode/umisc.h" 1.29 + 1.30 +#include "nfrlist.h" 1.31 + 1.32 +U_NAMESPACE_BEGIN 1.33 + 1.34 +class NFRuleSet : public UMemory { 1.35 + public: 1.36 + NFRuleSet(UnicodeString* descriptions, int32_t index, UErrorCode& status); 1.37 + void parseRules(UnicodeString& rules, const RuleBasedNumberFormat* owner, UErrorCode& status); 1.38 + void makeIntoFractionRuleSet() { fIsFractionRuleSet = TRUE; } 1.39 + 1.40 + ~NFRuleSet(); 1.41 + 1.42 + UBool operator==(const NFRuleSet& rhs) const; 1.43 + UBool operator!=(const NFRuleSet& rhs) const { return !operator==(rhs); } 1.44 + 1.45 + UBool isPublic() const { return fIsPublic; } 1.46 + 1.47 + UBool isParseable() const { return fIsParseable; } 1.48 + 1.49 + UBool isFractionRuleSet() const { return fIsFractionRuleSet; } 1.50 + 1.51 + void getName(UnicodeString& result) const { result.setTo(name); } 1.52 + UBool isNamed(const UnicodeString& _name) const { return this->name == _name; } 1.53 + 1.54 + void format(int64_t number, UnicodeString& toAppendTo, int32_t pos) const; 1.55 + void format(double number, UnicodeString& toAppendTo, int32_t pos) const; 1.56 + 1.57 + UBool parse(const UnicodeString& text, ParsePosition& pos, double upperBound, Formattable& result) const; 1.58 + 1.59 + void appendRules(UnicodeString& result) const; // toString 1.60 + 1.61 + private: 1.62 + NFRule * findNormalRule(int64_t number) const; 1.63 + NFRule * findDoubleRule(double number) const; 1.64 + NFRule * findFractionRuleSetRule(double number) const; 1.65 + 1.66 + private: 1.67 + UnicodeString name; 1.68 + NFRuleList rules; 1.69 + NFRule *negativeNumberRule; 1.70 + NFRule *fractionRules[3]; 1.71 + UBool fIsFractionRuleSet; 1.72 + UBool fIsPublic; 1.73 + UBool fIsParseable; 1.74 + int32_t fRecursionCount; 1.75 + 1.76 + NFRuleSet(const NFRuleSet &other); // forbid copying of this class 1.77 + NFRuleSet &operator=(const NFRuleSet &other); // forbid copying of this class 1.78 +}; 1.79 + 1.80 +// utilities from old llong.h 1.81 +// convert mantissa portion of double to int64 1.82 +int64_t util64_fromDouble(double d); 1.83 + 1.84 +// raise radix to the power exponent, only non-negative exponents 1.85 +int64_t util64_pow(int32_t radix, uint32_t exponent); 1.86 + 1.87 +// convert n to digit string in buffer, return length of string 1.88 +uint32_t util64_tou(int64_t n, UChar* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE); 1.89 + 1.90 +#ifdef RBNF_DEBUG 1.91 +int64_t util64_utoi(const UChar* str, uint32_t radix = 10); 1.92 +uint32_t util64_toa(int64_t n, char* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE); 1.93 +int64_t util64_atoi(const char* str, uint32_t radix); 1.94 +#endif 1.95 + 1.96 + 1.97 +U_NAMESPACE_END 1.98 + 1.99 +/* U_HAVE_RBNF */ 1.100 +#endif 1.101 + 1.102 +// NFRS_H 1.103 +#endif 1.104 +