ICU 62.1  62.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 
44 
45 class Hashtable;
46 class IFixedDecimal;
47 class RuleChain;
48 class PluralRuleParser;
49 class PluralKeywordEnumeration;
50 class AndConstraint;
51 class SharedPluralRules;
52 
197 public:
198 
206  PluralRules(UErrorCode& status);
207 
212  PluralRules(const PluralRules& other);
213 
218  virtual ~PluralRules();
219 
224  PluralRules* clone() const;
225 
230  PluralRules& operator=(const PluralRules&);
231 
242  static PluralRules* U_EXPORT2 createRules(const UnicodeString& description,
243  UErrorCode& status);
244 
253  static PluralRules* U_EXPORT2 createDefaultRules(UErrorCode& status);
254 
271  static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UErrorCode& status);
272 
289  static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UPluralType type, UErrorCode& status);
290 
291 #ifndef U_HIDE_INTERNAL_API
292 
297  static StringEnumeration* U_EXPORT2 getAvailableLocales(UErrorCode &status);
298 
305  static UBool hasOverride(const Locale &locale);
306 
312  static PluralRules* U_EXPORT2 internalForLocale(const Locale& locale, UPluralType type, UErrorCode& status);
313 
321  static const SharedPluralRules* U_EXPORT2 createSharedInstance(
322  const Locale& locale, UPluralType type, UErrorCode& status);
323 
324 
325 #endif /* U_HIDE_INTERNAL_API */
326 
336  UnicodeString select(int32_t number) const;
337 
347  UnicodeString select(double number) const;
348 
349 #ifndef U_HIDE_INTERNAL_API
350 
353  UnicodeString select(const IFixedDecimal &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 
506 
507 #endif /* #if !UCONFIG_NO_FORMATTING */
508 
509 #endif // _PLURRULE
510 //eof
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:93
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:57
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:196
C++ API: Base class for all formats.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:360
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
C API: Plural rules, select plural keywords for numeric values.
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
UBool operator!=(const PluralRules &other) const
Compares the inequality of two PluralRules objects.
Definition: plurrule.h:474
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
UPluralType
Type of plurals and PluralRules.
Definition: upluralrules.h:50
Basic definitions for ICU, for both C and C++ APIs.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:286
C++ API: Compatibility APIs for number formatting.
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:188