intl/icu/source/i18n/nfrs.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial