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
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
#include "unicode/umisc.h"
|
|
|
|
|
|
|
|
#include "unicode/rbnf.h"
|
|
|
|
#include "nfrlist.h"
|
|
|
|
#include "llong.h"
|
|
|
|
|
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class NFRuleSet {
|
|
|
|
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
|
|
|
|
2001-10-10 21:43:11 +00:00
|
|
|
void format(llong number, UnicodeString& toAppendTo, int32_t pos) const;
|
|
|
|
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:
|
|
|
|
NFRule * findNormalRule(llong number) const;
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
U_NAMESPACE_END
|
|
|
|
|
|
|
|
// NFRS_H
|
|
|
|
#endif
|
|
|
|
|