+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2008-2015, International Business Machines Corporation and
#include "unicode/format.h"
#include "unicode/upluralrules.h"
+#ifndef U_HIDE_INTERNAL_API
+#include "unicode/numfmt.h"
+#endif /* U_HIDE_INTERNAL_API */
/**
* Value returned by PluralRules::getUniqueKeywordValue() when there is no
*/
#define UPLRULES_NO_UNIQUE_VALUE ((double)-0.00123456777)
+#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
class Hashtable;
-class FixedDecimal;
+class IFixedDecimal;
class RuleChain;
class PluralRuleParser;
class PluralKeywordEnumeration;
class AndConstraint;
class SharedPluralRules;
+namespace number {
+class FormattedNumber;
+}
+
/**
* Defines rules for mapping non-negative numeric values onto a small set of
* keywords. Rules are constructed from a text description, consisting
* Examples are in the following table:
* </p>
* <table border='1' style="border-collapse:collapse">
- * <tbody>
* <tr>
* <th>n</th>
* <th>i</th>
* <td align="right">23</td>
* <td>2</td>
* </tr>
- * </tbody>
* </table>
* <p>
* The difference between 'in' and 'within' is that 'in' only includes integers in the specified range, while 'within'
#endif /* U_HIDE_INTERNAL_API */
/**
- * Given a number, returns the keyword of the first rule that applies to
- * the number. This function can be used with isKeyword* functions to
- * determine the keyword for default plural rules.
+ * Given an integer, returns the keyword of the first rule
+ * that applies to the number. This function can be used with
+ * isKeyword* functions to determine the keyword for default plural rules.
*
* @param number The number for which the rule has to be determined.
* @return The keyword of the selected rule.
UnicodeString select(int32_t number) const;
/**
- * Given a number, returns the keyword of the first rule that applies to
- * the number. This function can be used with isKeyword* functions to
- * determine the keyword for default plural rules.
+ * Given a floating-point number, returns the keyword of the first rule
+ * that applies to the number. This function can be used with
+ * isKeyword* functions to determine the keyword for default plural rules.
*
* @param number The number for which the rule has to be determined.
* @return The keyword of the selected rule.
*/
UnicodeString select(double number) const;
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Given a formatted number, returns the keyword of the first rule
+ * that applies to the number. This function can be used with
+ * isKeyword* functions to determine the keyword for default plural rules.
+ *
+ * A FormattedNumber allows you to specify an exponent or trailing zeros,
+ * which can affect the plural category. To get a FormattedNumber, see
+ * NumberFormatter.
+ *
+ * @param number The number for which the rule has to be determined.
+ * @param status Set if an error occurs while selecting plural keyword.
+ * This could happen if the FormattedNumber is invalid.
+ * @return The keyword of the selected rule.
+ * @draft ICU 64
+ */
+ UnicodeString select(const number::FormattedNumber& number, UErrorCode& status) const;
+#endif /* U_HIDE_DRAFT_API */
+
#ifndef U_HIDE_INTERNAL_API
/**
* @internal
*/
- UnicodeString select(const FixedDecimal &number) const;
+ UnicodeString select(const IFixedDecimal &number) const;
#endif /* U_HIDE_INTERNAL_API */
/**
/**
* Deprecated Function, does not produce useful results.
*
- * Orginally intended to return all the values for which select() would return the keyword.
+ * Originally intended to return all the values for which select() would return the keyword.
* If the keyword is unknown, returns no values, but this is not an error. If
* the number of values is unlimited, returns no values and -1 as the
* count.
UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status);
RuleChain *rulesForKeyword(const UnicodeString &keyword) const;
+ /**
+ * An internal status variable used to indicate that the object is in an 'invalid' state.
+ * Used by copy constructor, the assignment operator and the clone method.
+ */
+ UErrorCode mInternalStatus;
+
friend class PluralRuleParser;
};
U_NAMESPACE_END
+#endif // U_SHOW_CPLUSPLUS_API
#endif /* #if !UCONFIG_NO_FORMATTING */