ICU 63.1 63.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
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 RuleChain;
48 class PluralRuleParser;
49 class PluralKeywordEnumeration;
50 class AndConstraint;
51 class SharedPluralRules;
52
194 class U_I18N_API PluralRules : public UObject {
195 public:
196
204 PluralRules(UErrorCode& status);
205
210 PluralRules(const PluralRules& other);
211
216 virtual ~PluralRules();
217
222 PluralRules* clone() const;
223
228 PluralRules& operator=(const PluralRules&);
229
240 static PluralRules* U_EXPORT2 createRules(const UnicodeString& description,
241 UErrorCode& status);
242
251 static PluralRules* U_EXPORT2 createDefaultRules(UErrorCode& status);
252
269 static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UErrorCode& status);
270
287 static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UPluralType type, UErrorCode& status);
288
289 #ifndef U_HIDE_INTERNAL_API
290
295 static StringEnumeration* U_EXPORT2 getAvailableLocales(UErrorCode &status);
296
303 static UBool hasOverride(const Locale &locale);
304
310 static PluralRules* U_EXPORT2 internalForLocale(const Locale& locale, UPluralType type, UErrorCode& status);
311
319 static const SharedPluralRules* U_EXPORT2 createSharedInstance(
320 const Locale& locale, UPluralType type, UErrorCode& status);
321
322
323 #endif /* U_HIDE_INTERNAL_API */
324
334 UnicodeString select(int32_t number) const;
335
345 UnicodeString select(double number) const;
346
347 #ifndef U_HIDE_INTERNAL_API
348
351 UnicodeString select(const IFixedDecimal &number) const;
352 #endif /* U_HIDE_INTERNAL_API */
353
364 StringEnumeration* getKeywords(UErrorCode& status) const;
365
366 #ifndef U_HIDE_DEPRECATED_API
367
377 double getUniqueKeywordValue(const UnicodeString& keyword);
378
399 int32_t getAllKeywordValues(const UnicodeString &keyword,
400 double *dest, int32_t destCapacity,
401 UErrorCode& status);
402 #endif /* U_HIDE_DEPRECATED_API */
403
422 int32_t getSamples(const UnicodeString &keyword,
423 double *dest, int32_t destCapacity,
424 UErrorCode& status);
425
435 UBool isKeyword(const UnicodeString& keyword) const;
436
437
444 UnicodeString getKeywordOther() const;
445
446 #ifndef U_HIDE_INTERNAL_API
447
451 UnicodeString getRules() const;
452 #endif /* U_HIDE_INTERNAL_API */
453
462 virtual UBool operator==(const PluralRules& other) const;
463
472 UBool operator!=(const PluralRules& other) const {return !operator==(other);}
473
474
481 static UClassID U_EXPORT2 getStaticClassID(void);
482
488 virtual UClassID getDynamicClassID() const;
489
490
491 private:
492 RuleChain *mRules;
493
494 PluralRules(); // default constructor not implemented
495 void parseDescription(const UnicodeString& ruleData, UErrorCode &status);
496 int32_t getNumberValue(const UnicodeString& token) const;
497 UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status);
498 RuleChain *rulesForKeyword(const UnicodeString &keyword) const;
499
504 UErrorCode mInternalStatus;
505
506 friend class PluralRuleParser;
507 };
508
509 U_NAMESPACE_END
510
511 #endif /* #if !UCONFIG_NO_FORMATTING */
512
513 #endif // _PLURRULE
514 //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:90
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:194
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
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
upluralrules.h
C API: Plural rules, select plural keywords for numeric values.
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man&#39;s RTTI", returns a UClassID for the actual ICU class.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
icu::PluralRules::operator!=
UBool operator!=(const PluralRules &other) const
Compares the inequality of two PluralRules objects.
Definition: plurrule.h:472
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:401
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:289
numfmt.h
C++ API: Compatibility APIs for number formatting.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:220
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:192