| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * Copyright (C) 1997-2014, International Business Machines Corporation and other
s. | 3 * Copyright (C) 1997-2015, International Business Machines Corporation and other
s. |
| 4 * All Rights Reserved. | 4 * All Rights Reserved. |
| 5 ******************************************************************************* | 5 ******************************************************************************* |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef RBNF_H | 8 #ifndef RBNF_H |
| 9 #define RBNF_H | 9 #define RBNF_H |
| 10 | 10 |
| 11 #include "unicode/utypes.h" | 11 #include "unicode/utypes.h" |
| 12 | 12 |
| 13 /** | 13 /** |
| (...skipping 17 matching lines...) Expand all Loading... |
| 31 #include "unicode/fmtable.h" | 31 #include "unicode/fmtable.h" |
| 32 #include "unicode/locid.h" | 32 #include "unicode/locid.h" |
| 33 #include "unicode/numfmt.h" | 33 #include "unicode/numfmt.h" |
| 34 #include "unicode/unistr.h" | 34 #include "unicode/unistr.h" |
| 35 #include "unicode/strenum.h" | 35 #include "unicode/strenum.h" |
| 36 #include "unicode/brkiter.h" | 36 #include "unicode/brkiter.h" |
| 37 #include "unicode/upluralrules.h" | 37 #include "unicode/upluralrules.h" |
| 38 | 38 |
| 39 U_NAMESPACE_BEGIN | 39 U_NAMESPACE_BEGIN |
| 40 | 40 |
| 41 class NFRule; |
| 41 class NFRuleSet; | 42 class NFRuleSet; |
| 42 class LocalizationInfo; | 43 class LocalizationInfo; |
| 43 class PluralFormat; | 44 class PluralFormat; |
| 44 class RuleBasedCollator; | 45 class RuleBasedCollator; |
| 45 | 46 |
| 46 /** | 47 /** |
| 47 * Tags for the predefined rulesets. | 48 * Tags for the predefined rulesets. |
| 48 * | 49 * |
| 49 * @stable ICU 2.2 | 50 * @stable ICU 2.2 |
| 50 */ | 51 */ |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 * yields a result less than or equal to the base value. Every > characte
r after the radix | 258 * yields a result less than or equal to the base value. Every > characte
r after the radix |
| 258 * decreases the exponent by 1. If the exponent is positive or 0, the diviso
r is the radix | 259 * decreases the exponent by 1. If the exponent is positive or 0, the diviso
r is the radix |
| 259 * raised to the power of the exponent; otherwise, the divisor is 1.</td> | 260 * raised to the power of the exponent; otherwise, the divisor is 1.</td> |
| 260 * </tr> | 261 * </tr> |
| 261 * <tr> | 262 * <tr> |
| 262 * <td>-x:</td> | 263 * <td>-x:</td> |
| 263 * <td>The rule is a negative-number rule.</td> | 264 * <td>The rule is a negative-number rule.</td> |
| 264 * </tr> | 265 * </tr> |
| 265 * <tr> | 266 * <tr> |
| 266 * <td>x.x:</td> | 267 * <td>x.x:</td> |
| 267 * <td>The rule is an <em>improper fraction rule.</em></td> | 268 * <td>The rule is an <em>improper fraction rule</em>. If the full stop in |
| 269 * the middle of the rule name is replaced with the decimal point |
| 270 * that is used in the language or DecimalFormatSymbols, then that rule will |
| 271 * have precedence when formatting and parsing this rule. For example, some |
| 272 * languages use the comma, and can thus be written as x,x instead. For exam
ple, |
| 273 * you can use "x.x: << point >>;x,x: << comma >>;"
to |
| 274 * handle the decimal point that matches the language's natural spelling of |
| 275 * the punctuation of either the full stop or comma.</td> |
| 268 * </tr> | 276 * </tr> |
| 269 * <tr> | 277 * <tr> |
| 270 * <td>0.x:</td> | 278 * <td>0.x:</td> |
| 271 * <td>The rule is a <em>proper fraction rule.</em></td> | 279 * <td>The rule is a <em>proper fraction rule</em>. If the full stop in |
| 280 * the middle of the rule name is replaced with the decimal point |
| 281 * that is used in the language or DecimalFormatSymbols, then that rule will |
| 282 * have precedence when formatting and parsing this rule. For example, some |
| 283 * languages use the comma, and can thus be written as 0,x instead. For exam
ple, |
| 284 * you can use "0.x: point >>;0,x: comma >>;" to |
| 285 * handle the decimal point that matches the language's natural spelling of |
| 286 * the punctuation of either the full stop or comma.</td> |
| 272 * </tr> | 287 * </tr> |
| 273 * <tr> | 288 * <tr> |
| 274 * <td>x.0:</td> | 289 * <td>x.0:</td> |
| 275 * <td>The rule is a <em>master rule.</em></td> | 290 * <td>The rule is a <em>master rule</em>. If the full stop in |
| 291 * the middle of the rule name is replaced with the decimal point |
| 292 * that is used in the language or DecimalFormatSymbols, then that rule will |
| 293 * have precedence when formatting and parsing this rule. For example, some |
| 294 * languages use the comma, and can thus be written as x,0 instead. For exam
ple, |
| 295 * you can use "x.0: << point;x,0: << comma;" to |
| 296 * handle the decimal point that matches the language's natural spelling of |
| 297 * the punctuation of either the full stop or comma.</td> |
| 276 * </tr> | 298 * </tr> |
| 277 * <tr> | 299 * <tr> |
| 300 * <td>Inf:</td> |
| 301 * <td>The rule for infinity.</td> |
| 302 * </tr> |
| 303 * <tr> |
| 304 * <td>NaN:</td> |
| 305 * <td>The rule for an IEEE 754 NaN (not a number).</td> |
| 306 * </tr> |
| 307 * <tr> |
| 308 * <tr> |
| 278 * <td><em>nothing</em></td> | 309 * <td><em>nothing</em></td> |
| 279 * <td>If the rule's rule descriptor is left out, the base value is one plus
the | 310 * <td>If the rule's rule descriptor is left out, the base value is one plus
the |
| 280 * preceding rule's base value (or zero if this is the first rule in the lis
t) in a normal | 311 * preceding rule's base value (or zero if this is the first rule in the lis
t) in a normal |
| 281 * rule set. In a fraction rule set, the base value is the same as the
preceding rule's | 312 * rule set. In a fraction rule set, the base value is the same as the
preceding rule's |
| 282 * base value.</td> | 313 * base value.</td> |
| 283 * </tr> | 314 * </tr> |
| 284 * </table> | 315 * </table> |
| 285 * | 316 * |
| 286 * <p>A rule set may be either a regular rule set or a <em>fraction rule set,</e
m> depending | 317 * <p>A rule set may be either a regular rule set or a <em>fraction rule set,</e
m> depending |
| 287 * on whether it is used to format a number's integral part (or the whole number
) or a | 318 * on whether it is used to format a number's integral part (or the whole number
) or a |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 const Locale& locale, UParseError& perror, UErrorCode& s
tatus); | 643 const Locale& locale, UParseError& perror, UErrorCode& s
tatus); |
| 613 | 644 |
| 614 /** | 645 /** |
| 615 * Creates a RuleBasedNumberFormat from a predefined ruleset. The selector | 646 * Creates a RuleBasedNumberFormat from a predefined ruleset. The selector |
| 616 * code choosed among three possible predefined formats: spellout, ordinal, | 647 * code choosed among three possible predefined formats: spellout, ordinal, |
| 617 * and duration. | 648 * and duration. |
| 618 * @param tag A selector code specifying which kind of formatter to create for
that | 649 * @param tag A selector code specifying which kind of formatter to create for
that |
| 619 * locale. There are four legal values: URBNF_SPELLOUT, which creates a forma
tter that | 650 * locale. There are four legal values: URBNF_SPELLOUT, which creates a forma
tter that |
| 620 * spells out a value in words in the desired language, URBNF_ORDINAL, which a
ttaches | 651 * spells out a value in words in the desired language, URBNF_ORDINAL, which a
ttaches |
| 621 * an ordinal suffix from the desired language to the end of a number (e.g. "1
23rd"), | 652 * an ordinal suffix from the desired language to the end of a number (e.g. "1
23rd"), |
| 622 * URBNF_DURATION, which formats a duration in seconds as hours, minutes, and
seconds, | 653 * URBNF_DURATION, which formats a duration in seconds as hours, minutes, and
seconds always rounding down, |
| 623 * and URBNF_NUMBERING_SYSTEM, which is used to invoke rules for alternate num
bering | 654 * and URBNF_NUMBERING_SYSTEM, which is used to invoke rules for alternate num
bering |
| 624 * systems such as the Hebrew numbering system, or for Roman Numerals, etc. | 655 * systems such as the Hebrew numbering system, or for Roman Numerals, etc. |
| 625 * @param locale The locale for the formatter. | 656 * @param locale The locale for the formatter. |
| 626 * @param status The status indicating whether the constructor succeeded. | 657 * @param status The status indicating whether the constructor succeeded. |
| 627 * @stable ICU 2.0 | 658 * @stable ICU 2.0 |
| 628 */ | 659 */ |
| 629 RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale& locale, UErrorCode& s
tatus); | 660 RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale& locale, UErrorCode& s
tatus); |
| 630 | 661 |
| 631 //----------------------------------------------------------------------- | 662 //----------------------------------------------------------------------- |
| 632 // boilerplate | 663 // boilerplate |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 virtual void setDefaultRuleSet(const UnicodeString& ruleSetName, UErrorCode& s
tatus); | 937 virtual void setDefaultRuleSet(const UnicodeString& ruleSetName, UErrorCode& s
tatus); |
| 907 | 938 |
| 908 /** | 939 /** |
| 909 * Return the name of the current default rule set. If the current rule set i
s | 940 * Return the name of the current default rule set. If the current rule set i
s |
| 910 * not public, returns a bogus (and empty) UnicodeString. | 941 * not public, returns a bogus (and empty) UnicodeString. |
| 911 * @return the name of the current default rule set | 942 * @return the name of the current default rule set |
| 912 * @stable ICU 3.0 | 943 * @stable ICU 3.0 |
| 913 */ | 944 */ |
| 914 virtual UnicodeString getDefaultRuleSetName() const; | 945 virtual UnicodeString getDefaultRuleSetName() const; |
| 915 | 946 |
| 916 /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it
is virtual */ | |
| 917 /** | 947 /** |
| 918 * Set a particular UDisplayContext value in the formatter, such as | 948 * Set a particular UDisplayContext value in the formatter, such as |
| 919 * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. Note: For getContext, see | 949 * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. Note: For getContext, see |
| 920 * NumberFormat. | 950 * NumberFormat. |
| 921 * @param value The UDisplayContext value to set. | 951 * @param value The UDisplayContext value to set. |
| 922 * @param status Input/output status. If at entry this indicates a failure | 952 * @param status Input/output status. If at entry this indicates a failure |
| 923 * status, the function will do nothing; otherwise this will be | 953 * status, the function will do nothing; otherwise this will be |
| 924 * updated with any new status from the function. | 954 * updated with any new status from the function. |
| 925 * @draft ICU 53 | 955 * @stable ICU 53 |
| 926 */ | 956 */ |
| 927 virtual void setContext(UDisplayContext value, UErrorCode& status); | 957 virtual void setContext(UDisplayContext value, UErrorCode& status); |
| 928 | 958 |
| 929 public: | 959 public: |
| 930 /** | 960 /** |
| 931 * ICU "poor man's RTTI", returns a UClassID for this class. | 961 * ICU "poor man's RTTI", returns a UClassID for this class. |
| 932 * | 962 * |
| 933 * @stable ICU 2.8 | 963 * @stable ICU 2.8 |
| 934 */ | 964 */ |
| 935 static UClassID U_EXPORT2 getStaticClassID(void); | 965 static UClassID U_EXPORT2 getStaticClassID(void); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 void initCapitalizationContextInfo(const Locale& thelocale); | 1004 void initCapitalizationContextInfo(const Locale& thelocale); |
| 975 void dispose(); | 1005 void dispose(); |
| 976 void stripWhitespace(UnicodeString& src); | 1006 void stripWhitespace(UnicodeString& src); |
| 977 void initDefaultRuleSet(); | 1007 void initDefaultRuleSet(); |
| 978 void format(double number, NFRuleSet& ruleSet); | 1008 void format(double number, NFRuleSet& ruleSet); |
| 979 NFRuleSet* findRuleSet(const UnicodeString& name, UErrorCode& status) const; | 1009 NFRuleSet* findRuleSet(const UnicodeString& name, UErrorCode& status) const; |
| 980 | 1010 |
| 981 /* friend access */ | 1011 /* friend access */ |
| 982 friend class NFSubstitution; | 1012 friend class NFSubstitution; |
| 983 friend class NFRule; | 1013 friend class NFRule; |
| 1014 friend class NFRuleSet; |
| 984 friend class FractionalPartSubstitution; | 1015 friend class FractionalPartSubstitution; |
| 985 | 1016 |
| 986 inline NFRuleSet * getDefaultRuleSet() const; | 1017 inline NFRuleSet * getDefaultRuleSet() const; |
| 987 const RuleBasedCollator * getCollator() const; | 1018 const RuleBasedCollator * getCollator() const; |
| 988 DecimalFormatSymbols * getDecimalFormatSymbols() const; | 1019 DecimalFormatSymbols * initializeDecimalFormatSymbols(UErrorCode &status); |
| 1020 const DecimalFormatSymbols * getDecimalFormatSymbols() const; |
| 1021 NFRule * initializeDefaultInfinityRule(UErrorCode &status); |
| 1022 const NFRule * getDefaultInfinityRule() const; |
| 1023 NFRule * initializeDefaultNaNRule(UErrorCode &status); |
| 1024 const NFRule * getDefaultNaNRule() const; |
| 989 PluralFormat *createPluralFormat(UPluralType pluralType, const UnicodeString
&pattern, UErrorCode& status) const; | 1025 PluralFormat *createPluralFormat(UPluralType pluralType, const UnicodeString
&pattern, UErrorCode& status) const; |
| 990 UnicodeString& adjustForCapitalizationContext(int32_t startPos, UnicodeStrin
g& currentResult) const; | 1026 UnicodeString& adjustForCapitalizationContext(int32_t startPos, UnicodeStrin
g& currentResult) const; |
| 991 | 1027 |
| 992 private: | 1028 private: |
| 993 NFRuleSet **ruleSets; | 1029 NFRuleSet **ruleSets; |
| 994 UnicodeString* ruleSetDescriptions; | 1030 UnicodeString* ruleSetDescriptions; |
| 995 int32_t numRuleSets; | 1031 int32_t numRuleSets; |
| 996 NFRuleSet *defaultRuleSet; | 1032 NFRuleSet *defaultRuleSet; |
| 997 Locale locale; | 1033 Locale locale; |
| 998 RuleBasedCollator* collator; | 1034 RuleBasedCollator* collator; |
| 999 DecimalFormatSymbols* decimalFormatSymbols; | 1035 DecimalFormatSymbols* decimalFormatSymbols; |
| 1036 NFRule *defaultInfinityRule; |
| 1037 NFRule *defaultNaNRule; |
| 1000 UBool lenient; | 1038 UBool lenient; |
| 1001 UnicodeString* lenientParseRules; | 1039 UnicodeString* lenientParseRules; |
| 1002 LocalizationInfo* localizations; | 1040 LocalizationInfo* localizations; |
| 1003 UnicodeString originalDescription; | 1041 UnicodeString originalDescription; |
| 1004 UBool capitalizationInfoSet; | 1042 UBool capitalizationInfoSet; |
| 1005 UBool capitalizationForUIListMenu; | 1043 UBool capitalizationForUIListMenu; |
| 1006 UBool capitalizationForStandAlone; | 1044 UBool capitalizationForStandAlone; |
| 1007 BreakIterator* capitalizationBrkIter; | 1045 BreakIterator* capitalizationBrkIter; |
| 1008 }; | 1046 }; |
| 1009 | 1047 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1023 return defaultRuleSet; | 1061 return defaultRuleSet; |
| 1024 } | 1062 } |
| 1025 | 1063 |
| 1026 U_NAMESPACE_END | 1064 U_NAMESPACE_END |
| 1027 | 1065 |
| 1028 /* U_HAVE_RBNF */ | 1066 /* U_HAVE_RBNF */ |
| 1029 #endif | 1067 #endif |
| 1030 | 1068 |
| 1031 /* RBNF_H */ | 1069 /* RBNF_H */ |
| 1032 #endif | 1070 #endif |
| OLD | NEW |