2001-10-10 21:43:11 +00:00
|
|
|
/*
|
2001-10-11 16:56:24 +00:00
|
|
|
******************************************************************************
|
|
|
|
* Copyright (C) 1997-2001, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
******************************************************************************
|
|
|
|
* file name: nfrs.h
|
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* Modification history
|
|
|
|
* Date Name Comments
|
|
|
|
* 10/11/2001 Doug Ported from ICU4J
|
2001-10-10 21:43:11 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NFRS_H
|
|
|
|
#define NFRS_H
|
|
|
|
|
2002-06-27 01:19:20 +00:00
|
|
|
#include "unicode/uobject.h"
|
2002-03-14 00:28:22 +00:00
|
|
|
#include "unicode/rbnf.h"
|
|
|
|
|
|
|
|
#if U_HAVE_RBNF
|
|
|
|
|
2001-10-10 21:43:11 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
#include "unicode/umisc.h"
|
|
|
|
|
|
|
|
#include "nfrlist.h"
|
|
|
|
|
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2002-10-04 17:46:52 +00:00
|
|
|
class NFRuleSet : public UMemory {
|
2001-10-10 21:43:11 +00:00
|
|
|
public:
|
|
|
|
NFRuleSet(UnicodeString* descriptions, int32_t index, UErrorCode& status);
|
|
|
|
void parseRules(UnicodeString& rules, const RuleBasedNumberFormat* owner, UErrorCode& status);
|
|
|
|
void makeIntoFractionRuleSet() { fIsFractionRuleSet = TRUE; }
|
2001-10-11 16:56:24 +00:00
|
|
|
|
2001-10-10 21:43:11 +00:00
|
|
|
~NFRuleSet();
|
2001-10-11 16:56:24 +00:00
|
|
|
|
2001-10-10 21:43:11 +00:00
|
|
|
UBool operator==(const NFRuleSet& rhs) const;
|
|
|
|
UBool operator!=(const NFRuleSet& rhs) const { return !operator==(rhs); }
|
2001-10-11 16:56:24 +00:00
|
|
|
|
2001-10-10 21:43:11 +00:00
|
|
|
UBool isPublic() const { return fIsPublic; }
|
|
|
|
UBool isFractionRuleSet() const { return fIsFractionRuleSet; }
|
2001-10-11 16:56:24 +00:00
|
|
|
|
2001-10-10 21:43:11 +00:00
|
|
|
void getName(UnicodeString& result) const { result.setTo(name); }
|
|
|
|
UBool isNamed(const UnicodeString& _name) const { return this->name == _name; }
|
2001-10-11 16:56:24 +00:00
|
|
|
|
2002-03-14 00:28:22 +00:00
|
|
|
void format(int64_t number, UnicodeString& toAppendTo, int32_t pos) const;
|
2001-10-10 21:43:11 +00:00
|
|
|
void format(double number, UnicodeString& toAppendTo, int32_t pos) const;
|
2001-10-11 16:56:24 +00:00
|
|
|
|
2001-10-10 21:43:11 +00:00
|
|
|
UBool parse(const UnicodeString& text, ParsePosition& pos, double upperBound, Formattable& result) const;
|
2001-10-11 16:56:24 +00:00
|
|
|
|
2001-10-10 21:43:11 +00:00
|
|
|
void appendRules(UnicodeString& result) const; // toString
|
2001-10-11 16:56:24 +00:00
|
|
|
|
2001-10-10 21:43:11 +00:00
|
|
|
private:
|
2002-03-14 00:28:22 +00:00
|
|
|
NFRule * findNormalRule(int64_t number) const;
|
2001-10-10 21:43:11 +00:00
|
|
|
NFRule * findDoubleRule(double number) const;
|
|
|
|
NFRule * findFractionRuleSetRule(double number) const;
|
2001-10-11 16:56:24 +00:00
|
|
|
|
2001-10-10 21:43:11 +00:00
|
|
|
private:
|
|
|
|
UnicodeString name;
|
|
|
|
NFRuleList rules;
|
|
|
|
NFRule *negativeNumberRule;
|
|
|
|
NFRule *fractionRules[3];
|
|
|
|
UBool fIsFractionRuleSet;
|
|
|
|
UBool fIsPublic;
|
2002-06-29 00:04:16 +00:00
|
|
|
|
2002-10-04 17:46:52 +00:00
|
|
|
NFRuleSet(const NFRuleSet &other); // forbid copying of this class
|
|
|
|
NFRuleSet &operator=(const NFRuleSet &other); // forbid copying of this class
|
2001-10-10 21:43:11 +00:00
|
|
|
};
|
|
|
|
|
2002-03-14 00:28:22 +00:00
|
|
|
// utilities from old llong.h
|
|
|
|
// convert mantissa portion of double to int64
|
|
|
|
int64_t util64_fromDouble(double d);
|
|
|
|
|
|
|
|
// raise radix to the power exponent, only non-negative exponents
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2001-10-10 21:43:11 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2002-03-14 00:28:22 +00:00
|
|
|
/* U_HAVE_RBNF */
|
|
|
|
#endif
|
|
|
|
|
2001-10-10 21:43:11 +00:00
|
|
|
// NFRS_H
|
|
|
|
#endif
|
|
|
|
|