]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/nfrule.h
2 *******************************************************************************
3 * Copyright (C) 1997-2004, International Business Machines Corporation and others. All Rights Reserved.
4 *******************************************************************************
10 #include "unicode/rbnf.h"
14 #include "unicode/utypes.h"
15 #include "unicode/uobject.h"
16 #include "unicode/unistr.h"
27 class RuleBasedNumberFormat
;
30 class NFRule
: public UMemory
{
35 kNegativeNumberRule
= -1,
36 kImproperFractionRule
= -2,
37 kProperFractionRule
= -3,
42 static void makeRules(UnicodeString
& definition
,
43 const NFRuleSet
* ruleSet
,
44 const NFRule
* predecessor
,
45 const RuleBasedNumberFormat
* rbnf
,
49 NFRule(const RuleBasedNumberFormat
* rbnf
);
52 UBool
operator==(const NFRule
& rhs
) const;
53 UBool
operator!=(const NFRule
& rhs
) const { return !operator==(rhs
); }
55 ERuleType
getType() const { return (ERuleType
)(baseValue
<= kNoBase
? (ERuleType
)baseValue
: kOtherRule
); }
56 void setType(ERuleType ruleType
) { baseValue
= (int32_t)ruleType
; }
58 int64_t getBaseValue() const { return baseValue
; }
59 void setBaseValue(int64_t value
, UErrorCode
& status
);
61 double getDivisor() const { return uprv_pow(radix
, exponent
); }
63 void doFormat(int64_t number
, UnicodeString
& toAppendTo
, int32_t pos
) const;
64 void doFormat(double number
, UnicodeString
& toAppendTo
, int32_t pos
) const;
66 UBool
doParse(const UnicodeString
& text
,
70 Formattable
& result
) const;
72 UBool
shouldRollBack(double number
) const;
74 void appendRuleText(UnicodeString
& result
) const;
77 void parseRuleDescriptor(UnicodeString
& descriptor
, UErrorCode
& status
);
78 void extractSubstitutions(const NFRuleSet
* ruleSet
, const NFRule
* predecessor
, const RuleBasedNumberFormat
* rbnf
, UErrorCode
& status
);
79 NFSubstitution
* extractSubstitution(const NFRuleSet
* ruleSet
, const NFRule
* predecessor
, const RuleBasedNumberFormat
* rbnf
, UErrorCode
& status
);
81 int16_t expectedExponent() const;
82 int32_t indexOfAny(const UChar
* const strings
[]) const;
83 double matchToDelimiter(const UnicodeString
& text
, int32_t startPos
, double baseValue
,
84 const UnicodeString
& delimiter
, ParsePosition
& pp
, const NFSubstitution
* sub
,
85 double upperBound
) const;
86 void stripPrefix(UnicodeString
& text
, const UnicodeString
& prefix
, ParsePosition
& pp
) const;
88 int32_t prefixLength(const UnicodeString
& str
, const UnicodeString
& prefix
) const;
89 UBool
allIgnorable(const UnicodeString
& str
) const;
90 int32_t findText(const UnicodeString
& str
, const UnicodeString
& key
,
91 int32_t startingAt
, int32_t* resultCount
) const;
97 UnicodeString ruleText
;
100 const RuleBasedNumberFormat
* formatter
;
102 NFRule(const NFRule
&other
); // forbid copying of this class
103 NFRule
&operator=(const NFRule
&other
); // forbid copying of this class