X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/57a6839dcb3bba09e8228b822b290604668416fe..38fbf2fd31f5cd99b500914d6037b1d06b608645:/icuSources/i18n/unicode/rbnf.h diff --git a/icuSources/i18n/unicode/rbnf.h b/icuSources/i18n/unicode/rbnf.h index 5e4f3b33..5f9510f3 100644 --- a/icuSources/i18n/unicode/rbnf.h +++ b/icuSources/i18n/unicode/rbnf.h @@ -1,6 +1,8 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* -* Copyright (C) 1997-2014, International Business Machines Corporation and others. +* Copyright (C) 1997-2015, International Business Machines Corporation and others. * All Rights Reserved. ******************************************************************************* */ @@ -34,11 +36,15 @@ #include "unicode/unistr.h" #include "unicode/strenum.h" #include "unicode/brkiter.h" +#include "unicode/upluralrules.h" +#if U_SHOW_CPLUSPLUS_API U_NAMESPACE_BEGIN +class NFRule; class NFRuleSet; class LocalizationInfo; +class PluralFormat; class RuleBasedCollator; /** @@ -51,7 +57,13 @@ enum URBNFRuleSetTag { 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 }; /** @@ -262,17 +274,47 @@ enum URBNFRuleSetTag { * *
The substitution descriptor (i.e., the text between the token characters) may take one @@ -495,6 +555,8 @@ enum URBNFRuleSetTag { * @author Richard Gillam * @see NumberFormat * @see DecimalFormat + * @see PluralFormat + * @see PluralRules * @stable ICU 2.0 */ class U_I18N_API RuleBasedNumberFormat : public NumberFormat { @@ -597,7 +659,7 @@ public: * locale. There are four legal values: URBNF_SPELLOUT, which creates a formatter that * spells out a value in words in the desired language, URBNF_ORDINAL, which attaches * an ordinal suffix from the desired language to the end of a number (e.g. "123rd"), - * URBNF_DURATION, which formats a duration in seconds as hours, minutes, and seconds, + * URBNF_DURATION, which formats a duration in seconds as hours, minutes, and seconds always rounding down, * and URBNF_NUMBERING_SYSTEM, which is used to invoke rules for alternate numbering * systems such as the Hebrew numbering system, or for Roman Numerals, etc. * @param locale The locale for the formatter. @@ -805,6 +867,52 @@ public: 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; /** @@ -891,7 +999,6 @@ public: */ virtual UnicodeString getDefaultRuleSetName() const; - /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */ /** * Set a particular UDisplayContext value in the formatter, such as * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. Note: For getContext, see @@ -900,7 +1007,7 @@ public: * @param status Input/output status. If at entry this indicates a failure * status, the function will do nothing; otherwise this will be * updated with any new status from the function. - * @draft ICU 53 + * @stable ICU 53 */ virtual void setContext(UDisplayContext value, UErrorCode& status); @@ -959,12 +1066,20 @@ private: /* 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; - UnicodeString& adjustForCapitalizationContext(int32_t startPos, UnicodeString& currentResult) 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, UErrorCode& status) const; + UnicodeString& format(int64_t number, NFRuleSet *ruleSet, UnicodeString& toAppendTo, UErrorCode& status) const; private: NFRuleSet **ruleSets; @@ -974,6 +1089,8 @@ private: Locale locale; RuleBasedCollator* collator; DecimalFormatSymbols* decimalFormatSymbols; + NFRule *defaultInfinityRule; + NFRule *defaultNaNRule; UBool lenient; UnicodeString* lenientParseRules; LocalizationInfo* localizations; @@ -1001,6 +1118,7 @@ RuleBasedNumberFormat::getDefaultRuleSet() const { } U_NAMESPACE_END +#endif // U_SHOW_CPLUSPLUS_API /* U_HAVE_RBNF */ #endif