ICU 64.2  64.2
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 
53 namespace number {
54 class FormattedNumber;
55 }
56 
199 public:
200 
208  PluralRules(UErrorCode& status);
209 
214  PluralRules(const PluralRules& other);
215 
220  virtual ~PluralRules();
221 
226  PluralRules* clone() const;
227 
232  PluralRules& operator=(const PluralRules&);
233 
244  static PluralRules* U_EXPORT2 createRules(const UnicodeString& description,
245  UErrorCode& status);
246 
255  static PluralRules* U_EXPORT2 createDefaultRules(UErrorCode& status);
256 
273  static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UErrorCode& status);
274 
291  static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UPluralType type, UErrorCode& status);
292 
293 #ifndef U_HIDE_INTERNAL_API
294 
299  static StringEnumeration* U_EXPORT2 getAvailableLocales(UErrorCode &status);
300 
307  static UBool hasOverride(const Locale &locale);
308 
314  static PluralRules* U_EXPORT2 internalForLocale(const Locale& locale, UPluralType type, UErrorCode& status);
315 
323  static const SharedPluralRules* U_EXPORT2 createSharedInstance(
324  const Locale& locale, UPluralType type, UErrorCode& status);
325 
326 
327 #endif /* U_HIDE_INTERNAL_API */
328 
338  UnicodeString select(int32_t number) const;
339 
349  UnicodeString select(double number) const;
350 
351 #ifndef U_HIDE_DRAFT_API
352 
367  UnicodeString select(const number::FormattedNumber& number, UErrorCode& status) const;
368 #endif /* U_HIDE_DRAFT_API */
369 
370 #ifndef U_HIDE_INTERNAL_API
371 
374  UnicodeString select(const IFixedDecimal &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 
527  UErrorCode mInternalStatus;
528 
529  friend class PluralRuleParser;
530 };
531 
533 
534 #endif /* #if !UCONFIG_NO_FORMATTING */
535 
536 #endif // _PLURRULE
537 //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:198
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:301
#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.
#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:495
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:401
UPluralType
Type of plurals and PluralRules.
Definition: upluralrules.h:53
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:289
The result of a number formatting operation.
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:225
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:192