ICU 60.2 60.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

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
28 #if !UCONFIG_NO_FORMATTING
29
30 #include "unicode/format.h"
31 #include "unicode/upluralrules.h"
32 #ifndef U_HIDE_INTERNAL_API
33 #include "unicode/numfmt.h"
34 #endif /* U_HIDE_INTERNAL_API */
35
41 #define UPLRULES_NO_UNIQUE_VALUE ((double)-0.00123456777)
42
43 U_NAMESPACE_BEGIN
44
45 class Hashtable;
46 class IFixedDecimal;
47 class VisibleDigitsWithExponent;
48 class RuleChain;
49 class PluralRuleParser;
50 class PluralKeywordEnumeration;
51 class AndConstraint;
52 class SharedPluralRules;
53
197 class U_I18N_API PluralRules : public UObject {
198 public:
199
207 PluralRules(UErrorCode& status);
208
213 PluralRules(const PluralRules& other);
214
219 virtual ~PluralRules();
220
225 PluralRules* clone() const;
226
231 PluralRules& operator=(const PluralRules&);
232
243 static PluralRules* U_EXPORT2 createRules(const UnicodeString& description,
244 UErrorCode& status);
245
254 static PluralRules* U_EXPORT2 createDefaultRules(UErrorCode& status);
255
272 static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UErrorCode& status);
273
290 static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UPluralType type, UErrorCode& status);
291
292 #ifndef U_HIDE_INTERNAL_API
293
298 static StringEnumeration* U_EXPORT2 getAvailableLocales(UErrorCode &status);
299
306 static UBool hasOverride(const Locale &locale);
307
313 static PluralRules* U_EXPORT2 internalForLocale(const Locale& locale, UPluralType type, UErrorCode& status);
314
322 static const SharedPluralRules* U_EXPORT2 createSharedInstance(
323 const Locale& locale, UPluralType type, UErrorCode& status);
324
325
326 #endif /* U_HIDE_INTERNAL_API */
327
337 UnicodeString select(int32_t number) const;
338
348 UnicodeString select(double number) const;
349
350 #ifndef U_HIDE_INTERNAL_API
351
365 UnicodeString select(const Formattable& obj, const NumberFormat& fmt, UErrorCode& status) const;
366
370 UnicodeString select(const IFixedDecimal &number) const;
374 UnicodeString select(const VisibleDigitsWithExponent &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
523 friend class PluralRuleParser;
524 };
525
526 U_NAMESPACE_END
527
528 #endif /* #if !UCONFIG_NO_FORMATTING */
529
530 #endif // _PLURRULE
531 //eof
icu::NumberFormat
Abstract base class for all number formats.
Definition: numfmt.h:174
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man&#39;s RTTI", returns a UClassID for the actual ICU class.
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:93
icu::StringEnumeration
Base class for &#39;pure&#39; C++ implementations of uenum api.
Definition: strenum.h:57
icu::PluralRules
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:197
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:360
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
upluralrules.h
C API: Plural rules, select plural keywords for numeric values.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
icu::PluralRules::operator!=
UBool operator!=(const PluralRules &other) const
Compares the inequality of two PluralRules objects.
Definition: plurrule.h:495
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
UPluralType
UPluralType
Type of plurals and PluralRules.
Definition: upluralrules.h:50
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:286
icu::Formattable
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:68
numfmt.h
C++ API: Abstract base class for all number formats.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:188