annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/unicode/plurrule.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 // © 2016 and later: Unicode, Inc. and others.
jpayne@69 2 // License & terms of use: http://www.unicode.org/copyright.html
jpayne@69 3 /*
jpayne@69 4 *******************************************************************************
jpayne@69 5 * Copyright (C) 2008-2015, International Business Machines Corporation and
jpayne@69 6 * others. All Rights Reserved.
jpayne@69 7 *******************************************************************************
jpayne@69 8 *
jpayne@69 9 *
jpayne@69 10 * File PLURRULE.H
jpayne@69 11 *
jpayne@69 12 * Modification History:*
jpayne@69 13 * Date Name Description
jpayne@69 14 *
jpayne@69 15 ********************************************************************************
jpayne@69 16 */
jpayne@69 17
jpayne@69 18 #ifndef PLURRULE
jpayne@69 19 #define PLURRULE
jpayne@69 20
jpayne@69 21 #include "unicode/utypes.h"
jpayne@69 22
jpayne@69 23 #if U_SHOW_CPLUSPLUS_API
jpayne@69 24
jpayne@69 25 /**
jpayne@69 26 * \file
jpayne@69 27 * \brief C++ API: PluralRules object
jpayne@69 28 */
jpayne@69 29
jpayne@69 30 #if !UCONFIG_NO_FORMATTING
jpayne@69 31
jpayne@69 32 #include "unicode/format.h"
jpayne@69 33 #include "unicode/upluralrules.h"
jpayne@69 34 #ifndef U_HIDE_INTERNAL_API
jpayne@69 35 #include "unicode/numfmt.h"
jpayne@69 36 #endif /* U_HIDE_INTERNAL_API */
jpayne@69 37
jpayne@69 38 /**
jpayne@69 39 * Value returned by PluralRules::getUniqueKeywordValue() when there is no
jpayne@69 40 * unique value to return.
jpayne@69 41 * @stable ICU 4.8
jpayne@69 42 */
jpayne@69 43 #define UPLRULES_NO_UNIQUE_VALUE ((double)-0.00123456777)
jpayne@69 44
jpayne@69 45 U_NAMESPACE_BEGIN
jpayne@69 46
jpayne@69 47 class Hashtable;
jpayne@69 48 class IFixedDecimal;
jpayne@69 49 class RuleChain;
jpayne@69 50 class PluralRuleParser;
jpayne@69 51 class PluralKeywordEnumeration;
jpayne@69 52 class AndConstraint;
jpayne@69 53 class SharedPluralRules;
jpayne@69 54
jpayne@69 55 namespace number {
jpayne@69 56 class FormattedNumber;
jpayne@69 57 }
jpayne@69 58
jpayne@69 59 /**
jpayne@69 60 * Defines rules for mapping non-negative numeric values onto a small set of
jpayne@69 61 * keywords. Rules are constructed from a text description, consisting
jpayne@69 62 * of a series of keywords and conditions. The {@link #select} method
jpayne@69 63 * examines each condition in order and returns the keyword for the
jpayne@69 64 * first condition that matches the number. If none match,
jpayne@69 65 * default rule(other) is returned.
jpayne@69 66 *
jpayne@69 67 * For more information, details, and tips for writing rules, see the
jpayne@69 68 * LDML spec, C.11 Language Plural Rules:
jpayne@69 69 * http://www.unicode.org/draft/reports/tr35/tr35.html#Language_Plural_Rules
jpayne@69 70 *
jpayne@69 71 * Examples:<pre>
jpayne@69 72 * "one: n is 1; few: n in 2..4"</pre>
jpayne@69 73 * This defines two rules, for 'one' and 'few'. The condition for
jpayne@69 74 * 'one' is "n is 1" which means that the number must be equal to
jpayne@69 75 * 1 for this condition to pass. The condition for 'few' is
jpayne@69 76 * "n in 2..4" which means that the number must be between 2 and
jpayne@69 77 * 4 inclusive for this condition to pass. All other numbers
jpayne@69 78 * are assigned the keyword "other" by the default rule.
jpayne@69 79 * </p><pre>
jpayne@69 80 * "zero: n is 0; one: n is 1; zero: n mod 100 in 1..19"</pre>
jpayne@69 81 * This illustrates that the same keyword can be defined multiple times.
jpayne@69 82 * Each rule is examined in order, and the first keyword whose condition
jpayne@69 83 * passes is the one returned. Also notes that a modulus is applied
jpayne@69 84 * to n in the last rule. Thus its condition holds for 119, 219, 319...
jpayne@69 85 * </p><pre>
jpayne@69 86 * "one: n is 1; few: n mod 10 in 2..4 and n mod 100 not in 12..14"</pre>
jpayne@69 87 * This illustrates conjunction and negation. The condition for 'few'
jpayne@69 88 * has two parts, both of which must be met: "n mod 10 in 2..4" and
jpayne@69 89 * "n mod 100 not in 12..14". The first part applies a modulus to n
jpayne@69 90 * before the test as in the previous example. The second part applies
jpayne@69 91 * a different modulus and also uses negation, thus it matches all
jpayne@69 92 * numbers _not_ in 12, 13, 14, 112, 113, 114, 212, 213, 214...
jpayne@69 93 * </p>
jpayne@69 94 * <p>
jpayne@69 95 * Syntax:<pre>
jpayne@69 96 * \code
jpayne@69 97 * rules = rule (';' rule)*
jpayne@69 98 * rule = keyword ':' condition
jpayne@69 99 * keyword = <identifier>
jpayne@69 100 * condition = and_condition ('or' and_condition)*
jpayne@69 101 * and_condition = relation ('and' relation)*
jpayne@69 102 * relation = is_relation | in_relation | within_relation | 'n' <EOL>
jpayne@69 103 * is_relation = expr 'is' ('not')? value
jpayne@69 104 * in_relation = expr ('not')? 'in' range_list
jpayne@69 105 * within_relation = expr ('not')? 'within' range
jpayne@69 106 * expr = ('n' | 'i' | 'f' | 'v' | 'j') ('mod' value)?
jpayne@69 107 * range_list = (range | value) (',' range_list)*
jpayne@69 108 * value = digit+ ('.' digit+)?
jpayne@69 109 * digit = 0|1|2|3|4|5|6|7|8|9
jpayne@69 110 * range = value'..'value
jpayne@69 111 * \endcode
jpayne@69 112 * </pre></p>
jpayne@69 113 * <p>
jpayne@69 114 * <p>
jpayne@69 115 * The i, f, and v values are defined as follows:
jpayne@69 116 * </p>
jpayne@69 117 * <ul>
jpayne@69 118 * <li>i to be the integer digits.</li>
jpayne@69 119 * <li>f to be the visible fractional digits, as an integer.</li>
jpayne@69 120 * <li>v to be the number of visible fraction digits.</li>
jpayne@69 121 * <li>j is defined to only match integers. That is j is 3 fails if v != 0 (eg for 3.1 or 3.0).</li>
jpayne@69 122 * </ul>
jpayne@69 123 * <p>
jpayne@69 124 * Examples are in the following table:
jpayne@69 125 * </p>
jpayne@69 126 * <table border='1' style="border-collapse:collapse">
jpayne@69 127 * <tr>
jpayne@69 128 * <th>n</th>
jpayne@69 129 * <th>i</th>
jpayne@69 130 * <th>f</th>
jpayne@69 131 * <th>v</th>
jpayne@69 132 * </tr>
jpayne@69 133 * <tr>
jpayne@69 134 * <td>1.0</td>
jpayne@69 135 * <td>1</td>
jpayne@69 136 * <td align="right">0</td>
jpayne@69 137 * <td>1</td>
jpayne@69 138 * </tr>
jpayne@69 139 * <tr>
jpayne@69 140 * <td>1.00</td>
jpayne@69 141 * <td>1</td>
jpayne@69 142 * <td align="right">0</td>
jpayne@69 143 * <td>2</td>
jpayne@69 144 * </tr>
jpayne@69 145 * <tr>
jpayne@69 146 * <td>1.3</td>
jpayne@69 147 * <td>1</td>
jpayne@69 148 * <td align="right">3</td>
jpayne@69 149 * <td>1</td>
jpayne@69 150 * </tr>
jpayne@69 151 * <tr>
jpayne@69 152 * <td>1.03</td>
jpayne@69 153 * <td>1</td>
jpayne@69 154 * <td align="right">3</td>
jpayne@69 155 * <td>2</td>
jpayne@69 156 * </tr>
jpayne@69 157 * <tr>
jpayne@69 158 * <td>1.23</td>
jpayne@69 159 * <td>1</td>
jpayne@69 160 * <td align="right">23</td>
jpayne@69 161 * <td>2</td>
jpayne@69 162 * </tr>
jpayne@69 163 * </table>
jpayne@69 164 * <p>
jpayne@69 165 * The difference between 'in' and 'within' is that 'in' only includes integers in the specified range, while 'within'
jpayne@69 166 * includes all values. Using 'within' with a range_list consisting entirely of values is the same as using 'in' (it's
jpayne@69 167 * not an error).
jpayne@69 168 * </p>
jpayne@69 169
jpayne@69 170 * An "identifier" is a sequence of characters that do not have the
jpayne@69 171 * Unicode Pattern_Syntax or Pattern_White_Space properties.
jpayne@69 172 * <p>
jpayne@69 173 * The difference between 'in' and 'within' is that 'in' only includes
jpayne@69 174 * integers in the specified range, while 'within' includes all values.
jpayne@69 175 * Using 'within' with a range_list consisting entirely of values is the
jpayne@69 176 * same as using 'in' (it's not an error).
jpayne@69 177 *</p>
jpayne@69 178 * <p>
jpayne@69 179 * Keywords
jpayne@69 180 * could be defined by users or from ICU locale data. There are 6
jpayne@69 181 * predefined values in ICU - 'zero', 'one', 'two', 'few', 'many' and
jpayne@69 182 * 'other'. Callers need to check the value of keyword returned by
jpayne@69 183 * {@link #select} method.
jpayne@69 184 * </p>
jpayne@69 185 *
jpayne@69 186 * Examples:<pre>
jpayne@69 187 * UnicodeString keyword = pl->select(number);
jpayne@69 188 * if (keyword== UnicodeString("one") {
jpayne@69 189 * ...
jpayne@69 190 * }
jpayne@69 191 * else if ( ... )
jpayne@69 192 * </pre>
jpayne@69 193 * <strong>Note:</strong><br>
jpayne@69 194 * <p>
jpayne@69 195 * ICU defines plural rules for many locales based on CLDR <i>Language Plural Rules</i>.
jpayne@69 196 * For these predefined rules, see CLDR page at
jpayne@69 197 * http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
jpayne@69 198 * </p>
jpayne@69 199 */
jpayne@69 200 class U_I18N_API PluralRules : public UObject {
jpayne@69 201 public:
jpayne@69 202
jpayne@69 203 /**
jpayne@69 204 * Constructor.
jpayne@69 205 * @param status Output param set to success/failure code on exit, which
jpayne@69 206 * must not indicate a failure before the function call.
jpayne@69 207 *
jpayne@69 208 * @stable ICU 4.0
jpayne@69 209 */
jpayne@69 210 PluralRules(UErrorCode& status);
jpayne@69 211
jpayne@69 212 /**
jpayne@69 213 * Copy constructor.
jpayne@69 214 * @stable ICU 4.0
jpayne@69 215 */
jpayne@69 216 PluralRules(const PluralRules& other);
jpayne@69 217
jpayne@69 218 /**
jpayne@69 219 * Destructor.
jpayne@69 220 * @stable ICU 4.0
jpayne@69 221 */
jpayne@69 222 virtual ~PluralRules();
jpayne@69 223
jpayne@69 224 /**
jpayne@69 225 * Clone
jpayne@69 226 * @stable ICU 4.0
jpayne@69 227 */
jpayne@69 228 PluralRules* clone() const;
jpayne@69 229
jpayne@69 230 /**
jpayne@69 231 * Assignment operator.
jpayne@69 232 * @stable ICU 4.0
jpayne@69 233 */
jpayne@69 234 PluralRules& operator=(const PluralRules&);
jpayne@69 235
jpayne@69 236 /**
jpayne@69 237 * Creates a PluralRules from a description if it is parsable, otherwise
jpayne@69 238 * returns NULL.
jpayne@69 239 *
jpayne@69 240 * @param description rule description
jpayne@69 241 * @param status Output param set to success/failure code on exit, which
jpayne@69 242 * must not indicate a failure before the function call.
jpayne@69 243 * @return new PluralRules pointer. NULL if there is an error.
jpayne@69 244 * @stable ICU 4.0
jpayne@69 245 */
jpayne@69 246 static PluralRules* U_EXPORT2 createRules(const UnicodeString& description,
jpayne@69 247 UErrorCode& status);
jpayne@69 248
jpayne@69 249 /**
jpayne@69 250 * The default rules that accept any number.
jpayne@69 251 *
jpayne@69 252 * @param status Output param set to success/failure code on exit, which
jpayne@69 253 * must not indicate a failure before the function call.
jpayne@69 254 * @return new PluralRules pointer. NULL if there is an error.
jpayne@69 255 * @stable ICU 4.0
jpayne@69 256 */
jpayne@69 257 static PluralRules* U_EXPORT2 createDefaultRules(UErrorCode& status);
jpayne@69 258
jpayne@69 259 /**
jpayne@69 260 * Provides access to the predefined cardinal-number <code>PluralRules</code> for a given
jpayne@69 261 * locale.
jpayne@69 262 * Same as forLocale(locale, UPLURAL_TYPE_CARDINAL, status).
jpayne@69 263 *
jpayne@69 264 * @param locale The locale for which a <code>PluralRules</code> object is
jpayne@69 265 * returned.
jpayne@69 266 * @param status Output param set to success/failure code on exit, which
jpayne@69 267 * must not indicate a failure before the function call.
jpayne@69 268 * @return The predefined <code>PluralRules</code> object pointer for
jpayne@69 269 * this locale. If there's no predefined rules for this locale,
jpayne@69 270 * the rules for the closest parent in the locale hierarchy
jpayne@69 271 * that has one will be returned. The final fallback always
jpayne@69 272 * returns the default 'other' rules.
jpayne@69 273 * @stable ICU 4.0
jpayne@69 274 */
jpayne@69 275 static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UErrorCode& status);
jpayne@69 276
jpayne@69 277 /**
jpayne@69 278 * Provides access to the predefined <code>PluralRules</code> for a given
jpayne@69 279 * locale and the plural type.
jpayne@69 280 *
jpayne@69 281 * @param locale The locale for which a <code>PluralRules</code> object is
jpayne@69 282 * returned.
jpayne@69 283 * @param type The plural type (e.g., cardinal or ordinal).
jpayne@69 284 * @param status Output param set to success/failure code on exit, which
jpayne@69 285 * must not indicate a failure before the function call.
jpayne@69 286 * @return The predefined <code>PluralRules</code> object pointer for
jpayne@69 287 * this locale. If there's no predefined rules for this locale,
jpayne@69 288 * the rules for the closest parent in the locale hierarchy
jpayne@69 289 * that has one will be returned. The final fallback always
jpayne@69 290 * returns the default 'other' rules.
jpayne@69 291 * @stable ICU 50
jpayne@69 292 */
jpayne@69 293 static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UPluralType type, UErrorCode& status);
jpayne@69 294
jpayne@69 295 #ifndef U_HIDE_INTERNAL_API
jpayne@69 296 /**
jpayne@69 297 * Return a StringEnumeration over the locales for which there is plurals data.
jpayne@69 298 * @return a StringEnumeration over the locales available.
jpayne@69 299 * @internal
jpayne@69 300 */
jpayne@69 301 static StringEnumeration* U_EXPORT2 getAvailableLocales(UErrorCode &status);
jpayne@69 302
jpayne@69 303 /**
jpayne@69 304 * Returns whether or not there are overrides.
jpayne@69 305 * @param locale the locale to check.
jpayne@69 306 * @return
jpayne@69 307 * @internal
jpayne@69 308 */
jpayne@69 309 static UBool hasOverride(const Locale &locale);
jpayne@69 310
jpayne@69 311 /**
jpayne@69 312 * For ICU use only.
jpayne@69 313 * creates a SharedPluralRules object
jpayne@69 314 * @internal
jpayne@69 315 */
jpayne@69 316 static PluralRules* U_EXPORT2 internalForLocale(const Locale& locale, UPluralType type, UErrorCode& status);
jpayne@69 317
jpayne@69 318 /**
jpayne@69 319 * For ICU use only.
jpayne@69 320 * Returns handle to the shared, cached PluralRules instance.
jpayne@69 321 * Caller must call removeRef() on returned value once it is done with
jpayne@69 322 * the shared instance.
jpayne@69 323 * @internal
jpayne@69 324 */
jpayne@69 325 static const SharedPluralRules* U_EXPORT2 createSharedInstance(
jpayne@69 326 const Locale& locale, UPluralType type, UErrorCode& status);
jpayne@69 327
jpayne@69 328
jpayne@69 329 #endif /* U_HIDE_INTERNAL_API */
jpayne@69 330
jpayne@69 331 /**
jpayne@69 332 * Given an integer, returns the keyword of the first rule
jpayne@69 333 * that applies to the number. This function can be used with
jpayne@69 334 * isKeyword* functions to determine the keyword for default plural rules.
jpayne@69 335 *
jpayne@69 336 * @param number The number for which the rule has to be determined.
jpayne@69 337 * @return The keyword of the selected rule.
jpayne@69 338 * @stable ICU 4.0
jpayne@69 339 */
jpayne@69 340 UnicodeString select(int32_t number) const;
jpayne@69 341
jpayne@69 342 /**
jpayne@69 343 * Given a floating-point number, returns the keyword of the first rule
jpayne@69 344 * that applies to the number. This function can be used with
jpayne@69 345 * isKeyword* functions to determine the keyword for default plural rules.
jpayne@69 346 *
jpayne@69 347 * @param number The number for which the rule has to be determined.
jpayne@69 348 * @return The keyword of the selected rule.
jpayne@69 349 * @stable ICU 4.0
jpayne@69 350 */
jpayne@69 351 UnicodeString select(double number) const;
jpayne@69 352
jpayne@69 353 /**
jpayne@69 354 * Given a formatted number, returns the keyword of the first rule
jpayne@69 355 * that applies to the number. This function can be used with
jpayne@69 356 * isKeyword* functions to determine the keyword for default plural rules.
jpayne@69 357 *
jpayne@69 358 * A FormattedNumber allows you to specify an exponent or trailing zeros,
jpayne@69 359 * which can affect the plural category. To get a FormattedNumber, see
jpayne@69 360 * NumberFormatter.
jpayne@69 361 *
jpayne@69 362 * @param number The number for which the rule has to be determined.
jpayne@69 363 * @param status Set if an error occurs while selecting plural keyword.
jpayne@69 364 * This could happen if the FormattedNumber is invalid.
jpayne@69 365 * @return The keyword of the selected rule.
jpayne@69 366 * @stable ICU 64
jpayne@69 367 */
jpayne@69 368 UnicodeString select(const number::FormattedNumber& number, UErrorCode& status) const;
jpayne@69 369
jpayne@69 370 #ifndef U_HIDE_INTERNAL_API
jpayne@69 371 /**
jpayne@69 372 * @internal
jpayne@69 373 */
jpayne@69 374 UnicodeString select(const IFixedDecimal &number) const;
jpayne@69 375 #endif /* U_HIDE_INTERNAL_API */
jpayne@69 376
jpayne@69 377 /**
jpayne@69 378 * Returns a list of all rule keywords used in this <code>PluralRules</code>
jpayne@69 379 * object. The rule 'other' is always present by default.
jpayne@69 380 *
jpayne@69 381 * @param status Output param set to success/failure code on exit, which
jpayne@69 382 * must not indicate a failure before the function call.
jpayne@69 383 * @return StringEnumeration with the keywords.
jpayne@69 384 * The caller must delete the object.
jpayne@69 385 * @stable ICU 4.0
jpayne@69 386 */
jpayne@69 387 StringEnumeration* getKeywords(UErrorCode& status) const;
jpayne@69 388
jpayne@69 389 #ifndef U_HIDE_DEPRECATED_API
jpayne@69 390 /**
jpayne@69 391 * Deprecated Function, does not return useful results.
jpayne@69 392 *
jpayne@69 393 * Originally intended to return a unique value for this keyword if it exists,
jpayne@69 394 * else the constant UPLRULES_NO_UNIQUE_VALUE.
jpayne@69 395 *
jpayne@69 396 * @param keyword The keyword.
jpayne@69 397 * @return Stub deprecated function returns UPLRULES_NO_UNIQUE_VALUE always.
jpayne@69 398 * @deprecated ICU 55
jpayne@69 399 */
jpayne@69 400 double getUniqueKeywordValue(const UnicodeString& keyword);
jpayne@69 401
jpayne@69 402 /**
jpayne@69 403 * Deprecated Function, does not produce useful results.
jpayne@69 404 *
jpayne@69 405 * Originally intended to return all the values for which select() would return the keyword.
jpayne@69 406 * If the keyword is unknown, returns no values, but this is not an error. If
jpayne@69 407 * the number of values is unlimited, returns no values and -1 as the
jpayne@69 408 * count.
jpayne@69 409 *
jpayne@69 410 * The number of returned values is typically small.
jpayne@69 411 *
jpayne@69 412 * @param keyword The keyword.
jpayne@69 413 * @param dest Array into which to put the returned values. May
jpayne@69 414 * be NULL if destCapacity is 0.
jpayne@69 415 * @param destCapacity The capacity of the array, must be at least 0.
jpayne@69 416 * @param status The error code. Deprecated function, always sets U_UNSUPPORTED_ERROR.
jpayne@69 417 * @return The count of values available, or -1. This count
jpayne@69 418 * can be larger than destCapacity, but no more than
jpayne@69 419 * destCapacity values will be written.
jpayne@69 420 * @deprecated ICU 55
jpayne@69 421 */
jpayne@69 422 int32_t getAllKeywordValues(const UnicodeString &keyword,
jpayne@69 423 double *dest, int32_t destCapacity,
jpayne@69 424 UErrorCode& status);
jpayne@69 425 #endif /* U_HIDE_DEPRECATED_API */
jpayne@69 426
jpayne@69 427 /**
jpayne@69 428 * Returns sample values for which select() would return the keyword. If
jpayne@69 429 * the keyword is unknown, returns no values, but this is not an error.
jpayne@69 430 *
jpayne@69 431 * The number of returned values is typically small.
jpayne@69 432 *
jpayne@69 433 * @param keyword The keyword.
jpayne@69 434 * @param dest Array into which to put the returned values. May
jpayne@69 435 * be NULL if destCapacity is 0.
jpayne@69 436 * @param destCapacity The capacity of the array, must be at least 0.
jpayne@69 437 * @param status The error code.
jpayne@69 438 * @return The count of values written.
jpayne@69 439 * If more than destCapacity samples are available, then
jpayne@69 440 * only destCapacity are written, and destCapacity is returned as the count,
jpayne@69 441 * rather than setting a U_BUFFER_OVERFLOW_ERROR.
jpayne@69 442 * (The actual number of keyword values could be unlimited.)
jpayne@69 443 * @stable ICU 4.8
jpayne@69 444 */
jpayne@69 445 int32_t getSamples(const UnicodeString &keyword,
jpayne@69 446 double *dest, int32_t destCapacity,
jpayne@69 447 UErrorCode& status);
jpayne@69 448
jpayne@69 449 /**
jpayne@69 450 * Returns TRUE if the given keyword is defined in this
jpayne@69 451 * <code>PluralRules</code> object.
jpayne@69 452 *
jpayne@69 453 * @param keyword the input keyword.
jpayne@69 454 * @return TRUE if the input keyword is defined.
jpayne@69 455 * Otherwise, return FALSE.
jpayne@69 456 * @stable ICU 4.0
jpayne@69 457 */
jpayne@69 458 UBool isKeyword(const UnicodeString& keyword) const;
jpayne@69 459
jpayne@69 460
jpayne@69 461 /**
jpayne@69 462 * Returns keyword for default plural form.
jpayne@69 463 *
jpayne@69 464 * @return keyword for default plural form.
jpayne@69 465 * @stable ICU 4.0
jpayne@69 466 */
jpayne@69 467 UnicodeString getKeywordOther() const;
jpayne@69 468
jpayne@69 469 #ifndef U_HIDE_INTERNAL_API
jpayne@69 470 /**
jpayne@69 471 *
jpayne@69 472 * @internal
jpayne@69 473 */
jpayne@69 474 UnicodeString getRules() const;
jpayne@69 475 #endif /* U_HIDE_INTERNAL_API */
jpayne@69 476
jpayne@69 477 /**
jpayne@69 478 * Compares the equality of two PluralRules objects.
jpayne@69 479 *
jpayne@69 480 * @param other The other PluralRules object to be compared with.
jpayne@69 481 * @return True if the given PluralRules is the same as this
jpayne@69 482 * PluralRules; false otherwise.
jpayne@69 483 * @stable ICU 4.0
jpayne@69 484 */
jpayne@69 485 virtual UBool operator==(const PluralRules& other) const;
jpayne@69 486
jpayne@69 487 /**
jpayne@69 488 * Compares the inequality of two PluralRules objects.
jpayne@69 489 *
jpayne@69 490 * @param other The PluralRules object to be compared with.
jpayne@69 491 * @return True if the given PluralRules is not the same as this
jpayne@69 492 * PluralRules; false otherwise.
jpayne@69 493 * @stable ICU 4.0
jpayne@69 494 */
jpayne@69 495 UBool operator!=(const PluralRules& other) const {return !operator==(other);}
jpayne@69 496
jpayne@69 497
jpayne@69 498 /**
jpayne@69 499 * ICU "poor man's RTTI", returns a UClassID for this class.
jpayne@69 500 *
jpayne@69 501 * @stable ICU 4.0
jpayne@69 502 *
jpayne@69 503 */
jpayne@69 504 static UClassID U_EXPORT2 getStaticClassID(void);
jpayne@69 505
jpayne@69 506 /**
jpayne@69 507 * ICU "poor man's RTTI", returns a UClassID for the actual class.
jpayne@69 508 *
jpayne@69 509 * @stable ICU 4.0
jpayne@69 510 */
jpayne@69 511 virtual UClassID getDynamicClassID() const;
jpayne@69 512
jpayne@69 513
jpayne@69 514 private:
jpayne@69 515 RuleChain *mRules;
jpayne@69 516
jpayne@69 517 PluralRules(); // default constructor not implemented
jpayne@69 518 void parseDescription(const UnicodeString& ruleData, UErrorCode &status);
jpayne@69 519 int32_t getNumberValue(const UnicodeString& token) const;
jpayne@69 520 UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status);
jpayne@69 521 RuleChain *rulesForKeyword(const UnicodeString &keyword) const;
jpayne@69 522
jpayne@69 523 /**
jpayne@69 524 * An internal status variable used to indicate that the object is in an 'invalid' state.
jpayne@69 525 * Used by copy constructor, the assignment operator and the clone method.
jpayne@69 526 */
jpayne@69 527 UErrorCode mInternalStatus;
jpayne@69 528
jpayne@69 529 friend class PluralRuleParser;
jpayne@69 530 };
jpayne@69 531
jpayne@69 532 U_NAMESPACE_END
jpayne@69 533
jpayne@69 534 #endif /* #if !UCONFIG_NO_FORMATTING */
jpayne@69 535
jpayne@69 536 #endif /* U_SHOW_CPLUSPLUS_API */
jpayne@69 537
jpayne@69 538 #endif // _PLURRULE
jpayne@69 539 //eof