ICU 67.1 67.1

plurrule.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 * Copyright (C) 2008-2015, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 *******************************************************************************
8 *
9 *
10 * File PLURRULE.H
11 *
12 * Modification History:*
13 * Date Name Description
14 *
15 ********************************************************************************
16 */
17
18 #ifndef PLURRULE
19 #define PLURRULE
20
21 #include "unicode/utypes.h"
22
23 #if U_SHOW_CPLUSPLUS_API
24
30 #if !UCONFIG_NO_FORMATTING
31
32 #include "unicode/format.h"
33 #include "unicode/upluralrules.h"
34 #ifndef U_HIDE_INTERNAL_API
35 #include "unicode/numfmt.h"
36 #endif /* U_HIDE_INTERNAL_API */
37
43 #define UPLRULES_NO_UNIQUE_VALUE ((double)-0.00123456777)
44
45 U_NAMESPACE_BEGIN
46
47 class Hashtable;
48 class IFixedDecimal;
49 class RuleChain;
50 class PluralRuleParser;
51 class PluralKeywordEnumeration;
52 class AndConstraint;
53 class SharedPluralRules;
54
55 namespace number {
56 class FormattedNumber;
57 }
58
200 class U_I18N_API PluralRules : public UObject {
201 public:
202
210 PluralRules(UErrorCode& status);
211
216 PluralRules(const PluralRules& other);
217
222 virtual ~PluralRules();
223
228 PluralRules* clone() const;
229
234 PluralRules& operator=(const PluralRules&);
235
246 static PluralRules* U_EXPORT2 createRules(const UnicodeString& description,
247 UErrorCode& status);
248
257 static PluralRules* U_EXPORT2 createDefaultRules(UErrorCode& status);
258
275 static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UErrorCode& status);
276
293 static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UPluralType type, UErrorCode& status);
294
295 #ifndef U_HIDE_INTERNAL_API
296
301 static StringEnumeration* U_EXPORT2 getAvailableLocales(UErrorCode &status);
302
309 static UBool hasOverride(const Locale &locale);
310
316 static PluralRules* U_EXPORT2 internalForLocale(const Locale& locale, UPluralType type, UErrorCode& status);
317
325 static const SharedPluralRules* U_EXPORT2 createSharedInstance(
326 const Locale& locale, UPluralType type, UErrorCode& status);
327
328
329 #endif /* U_HIDE_INTERNAL_API */
330
340 UnicodeString select(int32_t number) const;
341
351 UnicodeString select(double number) const;
352
368 UnicodeString select(const number::FormattedNumber& number, UErrorCode& status) const;
369
370 #ifndef U_HIDE_INTERNAL_API
371
374 UnicodeString select(const IFixedDecimal &number) const;
375 #endif /* U_HIDE_INTERNAL_API */
376
387 StringEnumeration* getKeywords(UErrorCode& status) const;
388
389 #ifndef U_HIDE_DEPRECATED_API
390
400 double getUniqueKeywordValue(const UnicodeString& keyword);
401
422 int32_t getAllKeywordValues(const UnicodeString &keyword,
423 double *dest, int32_t destCapacity,
424 UErrorCode& status);
425 #endif /* U_HIDE_DEPRECATED_API */
426
445 int32_t getSamples(const UnicodeString &keyword,
446 double *dest, int32_t destCapacity,
447 UErrorCode& status);
448
458 UBool isKeyword(const UnicodeString& keyword) const;
459
460
467 UnicodeString getKeywordOther() const;
468
469 #ifndef U_HIDE_INTERNAL_API
470
474 UnicodeString getRules() const;
475 #endif /* U_HIDE_INTERNAL_API */
476
485 virtual UBool operator==(const PluralRules& other) const;
486
495 UBool operator!=(const PluralRules& other) const {return !operator==(other);}
496
497
504 static UClassID U_EXPORT2 getStaticClassID(void);
505
511 virtual UClassID getDynamicClassID() const;
512
513
514 private:
515 RuleChain *mRules;
516
517 PluralRules(); // default constructor not implemented
518 void parseDescription(const UnicodeString& ruleData, UErrorCode &status);
519 int32_t getNumberValue(const UnicodeString& token) const;
520 UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status);
521 RuleChain *rulesForKeyword(const UnicodeString &keyword) const;
522
527 UErrorCode mInternalStatus;
528
529 friend class PluralRuleParser;
530 };
531
532 U_NAMESPACE_END
533
534 #endif /* #if !UCONFIG_NO_FORMATTING */
535
536 #endif /* U_SHOW_CPLUSPLUS_API */
537
538 #endif // _PLURRULE
539 //eof
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:96
icu::StringEnumeration
Base class for &#39;pure&#39; C++ implementations of uenum api.
Definition: strenum.h:61
icu::PluralRules
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:200
format.h
C++ API: Base class for all formats.
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:301
upluralrules.h
C API: Plural rules, select plural keywords for numeric values.
icu::PluralRules::operator!=
UBool operator!=(const PluralRules &other) const
Compares the inequality of two PluralRules objects.
Definition: plurrule.h:495
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
UPluralType
UPluralType
Type of plurals and PluralRules.
Definition: upluralrules.h:53
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
icu::number::FormattedNumber
The result of a number formatting operation.
Definition: numberformatter.h:2426
numfmt.h
C++ API: Compatibility APIs for number formatting.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195