ICU 58.2 58.2

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

- File List
- Globals

plurrule.h
Go to the documentation of this file.
1 // Copyright (C) 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
38 #define UPLRULES_NO_UNIQUE_VALUE ((double)-0.00123456777)
39
40 U_NAMESPACE_BEGIN
41
42 class Hashtable;
43 class FixedDecimal;
44 class VisibleDigitsWithExponent;
45 class RuleChain;
46 class PluralRuleParser;
47 class PluralKeywordEnumeration;
48 class AndConstraint;
49 class SharedPluralRules;
50
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 FixedDecimal &number) const;
355 UnicodeString select(const VisibleDigitsWithExponent &number) const;
356 #endif /* U_HIDE_INTERNAL_API */
357
368 StringEnumeration* getKeywords(UErrorCode& status) const;
369
370 #ifndef U_HIDE_DEPRECATED_API
371
381 double getUniqueKeywordValue(const UnicodeString& keyword);
382
403 int32_t getAllKeywordValues(const UnicodeString &keyword,
404 double *dest, int32_t destCapacity,
405 UErrorCode& status);
406 #endif /* U_HIDE_DEPRECATED_API */
407
426 int32_t getSamples(const UnicodeString &keyword,
427 double *dest, int32_t destCapacity,
428 UErrorCode& status);
429
439 UBool isKeyword(const UnicodeString& keyword) const;
440
441
448 UnicodeString getKeywordOther() const;
449
450 #ifndef U_HIDE_INTERNAL_API
451
455 UnicodeString getRules() const;
456 #endif /* U_HIDE_INTERNAL_API */
457
466 virtual UBool operator==(const PluralRules& other) const;
467
476 UBool operator!=(const PluralRules& other) const {return !operator==(other);}
477
478
485 static UClassID U_EXPORT2 getStaticClassID(void);
486
492 virtual UClassID getDynamicClassID() const;
493
494
495 private:
496 RuleChain *mRules;
497
498 PluralRules(); // default constructor not implemented
499 void parseDescription(const UnicodeString& ruleData, UErrorCode &status);
500 int32_t getNumberValue(const UnicodeString& token) const;
501 UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status);
502 RuleChain *rulesForKeyword(const UnicodeString &keyword) const;
503
504 friend class PluralRuleParser;
505 };
506
507 U_NAMESPACE_END
508
509 #endif /* #if !UCONFIG_NO_FORMATTING */
510
511 #endif // _PLURRULE
512 //eof
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: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: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:476
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:46
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:295
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:259
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:187