ICU 56.1: plurrule.h Source File

ICU 56.1 56.1

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

- File List
- Globals

plurrule.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 * Copyright (C) 2008-2015, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 *******************************************************************************
6 *
7 *
8 * File PLURRULE.H
9 *
10 * Modification History:*
11 * Date Name Description
12 *
13 ********************************************************************************
14 */
15
16 #ifndef PLURRULE
17 #define PLURRULE
18
19 #include "unicode/utypes.h"
20
26 #if !UCONFIG_NO_FORMATTING
27
28 #include "unicode/format.h"
29 #include "unicode/upluralrules.h"
30
36 #define UPLRULES_NO_UNIQUE_VALUE ((double)-0.00123456777)
37
38 U_NAMESPACE_BEGIN
39
40 class Hashtable;
41 class FixedDecimal;
42 class VisibleDigitsWithExponent;
43 class RuleChain;
44 class PluralRuleParser;
45 class PluralKeywordEnumeration;
46 class AndConstraint;
47 class SharedPluralRules;
48
192 class U_I18N_API PluralRules : public UObject {
193 public:
194
202 PluralRules(UErrorCode& status);
203
208 PluralRules(const PluralRules& other);
209
214 virtual ~PluralRules();
215
220 PluralRules* clone() const;
221
226 PluralRules& operator=(const PluralRules&);
227
238 static PluralRules* U_EXPORT2 createRules(const UnicodeString& description,
239 UErrorCode& status);
240
249 static PluralRules* U_EXPORT2 createDefaultRules(UErrorCode& status);
250
267 static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UErrorCode& status);
268
285 static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UPluralType type, UErrorCode& status);
286
287 #ifndef U_HIDE_INTERNAL_API
288
293 static StringEnumeration* U_EXPORT2 getAvailableLocales(UErrorCode &status);
294
301 static UBool hasOverride(const Locale &locale);
302
308 static PluralRules* U_EXPORT2 internalForLocale(const Locale& locale, UPluralType type, UErrorCode& status);
309
317 static const SharedPluralRules* U_EXPORT2 createSharedInstance(
318 const Locale& locale, UPluralType type, UErrorCode& status);
319
320
321 #endif /* U_HIDE_INTERNAL_API */
322
332 UnicodeString select(int32_t number) const;
333
343 UnicodeString select(double number) const;
344
345 #ifndef U_HIDE_INTERNAL_API
346
349 UnicodeString select(const FixedDecimal &number) const;
353 UnicodeString select(const VisibleDigitsWithExponent &number) const;
354 #endif /* U_HIDE_INTERNAL_API */
355
366 StringEnumeration* getKeywords(UErrorCode& status) const;
367
368 #ifndef U_HIDE_DEPRECATED_API
369
379 double getUniqueKeywordValue(const UnicodeString& keyword);
380
401 int32_t getAllKeywordValues(const UnicodeString &keyword,
402 double *dest, int32_t destCapacity,
403 UErrorCode& status);
404 #endif /* U_HIDE_DEPRECATED_API */
405
424 int32_t getSamples(const UnicodeString &keyword,
425 double *dest, int32_t destCapacity,
426 UErrorCode& status);
427
437 UBool isKeyword(const UnicodeString& keyword) const;
438
439
446 UnicodeString getKeywordOther() const;
447
448 #ifndef U_HIDE_INTERNAL_API
449
453 UnicodeString getRules() const;
454 #endif /* U_HIDE_INTERNAL_API */
455
464 virtual UBool operator==(const PluralRules& other) const;
465
474 UBool operator!=(const PluralRules& other) const {return !operator==(other);}
475
476
483 static UClassID U_EXPORT2 getStaticClassID(void);
484
490 virtual UClassID getDynamicClassID() const;
491
492
493 private:
494 RuleChain *mRules;
495
496 PluralRules(); // default constructor not implemented
497 void parseDescription(const UnicodeString& ruleData, UErrorCode &status);
498 int32_t getNumberValue(const UnicodeString& token) const;
499 UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status);
500 RuleChain *rulesForKeyword(const UnicodeString &keyword) const;
501
502 friend class PluralRuleParser;
503 };
504
505 U_NAMESPACE_END
506
507 #endif /* #if !UCONFIG_NO_FORMATTING */
508
509 #endif // _PLURRULE
510 //eof
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man'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's RTTI.
Definition: uobject.h:91
icu::StringEnumeration
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:55
icu::PluralRules
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:192
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:358
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
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:130
icu::PluralRules::operator!=
UBool operator!=(const PluralRules &other) const
Compares the inequality of two PluralRules objects.
Definition: plurrule.h:474
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
UPluralType
UPluralType
Type of plurals and PluralRules.
Definition: upluralrules.h:44
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:293
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185