+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 1997-2015, International Business Machines Corporation and others.
#include "unicode/brkiter.h"
#include "unicode/upluralrules.h"
+#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
+class NFRule;
class NFRuleSet;
class LocalizationInfo;
class PluralFormat;
URBNF_ORDINAL,
URBNF_DURATION,
URBNF_NUMBERING_SYSTEM,
+#ifndef U_HIDE_DEPRECATED_API
+ /**
+ * One more than the highest normal URBNFRuleSetTag value.
+ * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
+ */
URBNF_COUNT
+#endif // U_HIDE_DEPRECATED_API
};
/**
* </tr>
* <tr>
* <td>x.x:</td>
- * <td>The rule is an <em>improper fraction rule.</em></td>
+ * <td>The rule is an <em>improper fraction rule</em>. If the full stop in
+ * the middle of the rule name is replaced with the decimal point
+ * that is used in the language or DecimalFormatSymbols, then that rule will
+ * have precedence when formatting and parsing this rule. For example, some
+ * languages use the comma, and can thus be written as x,x instead. For example,
+ * you can use "x.x: << point >>;x,x: << comma >>;" to
+ * handle the decimal point that matches the language's natural spelling of
+ * the punctuation of either the full stop or comma.</td>
* </tr>
* <tr>
* <td>0.x:</td>
- * <td>The rule is a <em>proper fraction rule.</em></td>
+ * <td>The rule is a <em>proper fraction rule</em>. If the full stop in
+ * the middle of the rule name is replaced with the decimal point
+ * that is used in the language or DecimalFormatSymbols, then that rule will
+ * have precedence when formatting and parsing this rule. For example, some
+ * languages use the comma, and can thus be written as 0,x instead. For example,
+ * you can use "0.x: point >>;0,x: comma >>;" to
+ * handle the decimal point that matches the language's natural spelling of
+ * the punctuation of either the full stop or comma.</td>
* </tr>
* <tr>
* <td>x.0:</td>
- * <td>The rule is a <em>master rule.</em></td>
+ * <td>The rule is a <em>master rule</em>. If the full stop in
+ * the middle of the rule name is replaced with the decimal point
+ * that is used in the language or DecimalFormatSymbols, then that rule will
+ * have precedence when formatting and parsing this rule. For example, some
+ * languages use the comma, and can thus be written as x,0 instead. For example,
+ * you can use "x.0: << point;x,0: << comma;" to
+ * handle the decimal point that matches the language's natural spelling of
+ * the punctuation of either the full stop or comma.</td>
+ * </tr>
+ * <tr>
+ * <td>Inf:</td>
+ * <td>The rule for infinity.</td>
* </tr>
* <tr>
+ * <td>NaN:</td>
+ * <td>The rule for an IEEE 754 NaN (not a number).</td>
+ * </tr>
+ * <tr>
+ * <tr>
* <td><em>nothing</em></td>
* <td>If the rule's rule descriptor is left out, the base value is one plus the
* preceding rule's base value (or zero if this is the first rule in the list) in a normal
FieldPosition& pos,
UErrorCode& status) const;
+protected:
+ /**
+ * Format a decimal number.
+ * The number is a DigitList wrapper onto a floating point decimal number.
+ * The default implementation in NumberFormat converts the decimal number
+ * to a double and formats that. Subclasses of NumberFormat that want
+ * to specifically handle big decimal numbers must override this method.
+ * class DecimalFormat does so.
+ *
+ * @param number The number, a DigitList format Decimal Floating Point.
+ * @param appendTo Output parameter to receive result.
+ * Result is appended to existing contents.
+ * @param posIter On return, can be used to iterate over positions
+ * of fields generated by this format call.
+ * @param status Output param filled with success/failure status.
+ * @return Reference to 'appendTo' parameter.
+ * @internal
+ */
+ virtual UnicodeString& format(const DigitList &number,
+ UnicodeString& appendTo,
+ FieldPositionIterator* posIter,
+ UErrorCode& status) const;
+
+ /**
+ * Format a decimal number.
+ * The number is a DigitList wrapper onto a floating point decimal number.
+ * The default implementation in NumberFormat converts the decimal number
+ * to a double and formats that. Subclasses of NumberFormat that want
+ * to specifically handle big decimal numbers must override this method.
+ * class DecimalFormat does so.
+ *
+ * @param number The number, a DigitList format Decimal Floating Point.
+ * @param appendTo Output parameter to receive result.
+ * Result is appended to existing contents.
+ * @param pos On input: an alignment field, if desired.
+ * On output: the offsets of the alignment field.
+ * @param status Output param filled with success/failure status.
+ * @return Reference to 'appendTo' parameter.
+ * @internal
+ */
+ virtual UnicodeString& format(const DigitList &number,
+ UnicodeString& appendTo,
+ FieldPosition& pos,
+ UErrorCode& status) const;
+public:
+
using NumberFormat::parse;
/**
/* friend access */
friend class NFSubstitution;
friend class NFRule;
+ friend class NFRuleSet;
friend class FractionalPartSubstitution;
inline NFRuleSet * getDefaultRuleSet() const;
const RuleBasedCollator * getCollator() const;
- DecimalFormatSymbols * getDecimalFormatSymbols() const;
+ DecimalFormatSymbols * initializeDecimalFormatSymbols(UErrorCode &status);
+ const DecimalFormatSymbols * getDecimalFormatSymbols() const;
+ NFRule * initializeDefaultInfinityRule(UErrorCode &status);
+ const NFRule * getDefaultInfinityRule() const;
+ NFRule * initializeDefaultNaNRule(UErrorCode &status);
+ const NFRule * getDefaultNaNRule() const;
PluralFormat *createPluralFormat(UPluralType pluralType, const UnicodeString &pattern, UErrorCode& status) const;
- UnicodeString& adjustForCapitalizationContext(int32_t startPos, UnicodeString& currentResult) const;
+ UnicodeString& adjustForCapitalizationContext(int32_t startPos, UnicodeString& currentResult, UErrorCode& status) const;
+ UnicodeString& format(int64_t number, NFRuleSet *ruleSet, UnicodeString& toAppendTo, UErrorCode& status) const;
private:
NFRuleSet **ruleSets;
Locale locale;
RuleBasedCollator* collator;
DecimalFormatSymbols* decimalFormatSymbols;
+ NFRule *defaultInfinityRule;
+ NFRule *defaultNaNRule;
UBool lenient;
UnicodeString* lenientParseRules;
LocalizationInfo* localizations;
}
U_NAMESPACE_END
+#endif // U_SHOW_CPLUSPLUS_API
/* U_HAVE_RBNF */
#endif