ICU 76.1 76.1
Loading...
Searching...
No Matches
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
23#if U_SHOW_CPLUSPLUS_API
24
30#if !UCONFIG_NO_FORMATTING
31
32#include "unicode/format.h"
34#ifndef U_HIDE_INTERNAL_API
35#include "unicode/numfmt.h"
36#endif /* U_HIDE_INTERNAL_API */
37
43#define UPLRULES_NO_UNIQUE_VALUE ((double)-0.00123456777)
44
45U_NAMESPACE_BEGIN
46
47class Hashtable;
48class IFixedDecimal;
49class FixedDecimal;
50class RuleChain;
51class PluralRuleParser;
52class PluralKeywordEnumeration;
53class AndConstraint;
54class SharedPluralRules;
55class StandardPluralRanges;
56
57namespace number {
58class FormattedNumber;
59class FormattedNumberRange;
60namespace impl {
61class UFormattedNumberRangeData;
62class DecimalQuantity;
63class DecNum;
64}
65}
66
67#ifndef U_HIDE_INTERNAL_API
68using icu::number::impl::DecimalQuantity;
69#endif /* U_HIDE_INTERNAL_API */
70
213public:
214
223
229
234 virtual ~PluralRules();
235
241
247
260
270
288
306
307#ifndef U_HIDE_INTERNAL_API
314
321
330 const Locale& locale, UPluralType type, UErrorCode& status);
331
332
333#endif /* U_HIDE_INTERNAL_API */
334
345
355 UnicodeString select(double number) const;
356
373
391
392#ifndef U_HIDE_INTERNAL_API
396 UnicodeString select(const IFixedDecimal &number) const;
400 UnicodeString select(const number::impl::UFormattedNumberRangeData* urange, UErrorCode& status) const;
401#endif /* U_HIDE_INTERNAL_API */
402
414
415#ifndef U_HIDE_DEPRECATED_API
427
449 double *dest, int32_t destCapacity,
451#endif /* U_HIDE_DEPRECATED_API */
452
472 double *dest, int32_t destCapacity,
474
475#ifndef U_HIDE_INTERNAL_API
497 DecimalQuantity *dest, int32_t destCapacity,
499#endif /* U_HIDE_INTERNAL_API */
500
511
512
520
521#ifndef U_HIDE_INTERNAL_API
527#endif /* U_HIDE_INTERNAL_API */
528
537 virtual bool operator==(const PluralRules& other) const;
538
547 bool operator!=(const PluralRules& other) const {return !operator==(other);}
548
549
557
563 virtual UClassID getDynamicClassID() const override;
564
565
566private:
567 RuleChain *mRules;
568 StandardPluralRanges *mStandardPluralRanges;
569
570 PluralRules() = delete; // default constructor not implemented
571 UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status);
572 RuleChain *rulesForKeyword(const UnicodeString &keyword) const;
573 PluralRules *clone(UErrorCode& status) const;
574
579 UErrorCode mInternalStatus;
580
581 friend class PluralRuleParser;
582};
583
585
586#endif /* #if !UCONFIG_NO_FORMATTING */
587
588#endif /* U_SHOW_CPLUSPLUS_API */
589
590#endif // _PLURRULE
591//eof
"Smart pointer" base class; do not use directly: use LocalPointer etc.
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:195
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition plurrule.h:212
UnicodeString select(const number::FormattedNumber &number, UErrorCode &status) const
Given a formatted number, returns the keyword of the first rule that applies to the number.
UnicodeString select(const number::FormattedNumberRange &range, UErrorCode &status) const
Given a formatted number range, returns the overall plural form of the range.
static const SharedPluralRules * createSharedInstance(const Locale &locale, UPluralType type, UErrorCode &status)
For ICU use only.
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
static PluralRules * createRules(const UnicodeString &description, UErrorCode &status)
Creates a PluralRules from a description if it is parsable, otherwise returns nullptr.
UBool isKeyword(const UnicodeString &keyword) const
Returns true if the given keyword is defined in this PluralRules object.
PluralRules(UErrorCode &status)
Constructor.
static PluralRules * createDefaultRules(UErrorCode &status)
The default rules that accept any number.
PluralRules & operator=(const PluralRules &)
Assignment operator.
PluralRules * clone() const
Clone.
PluralRules(const PluralRules &other)
Copy constructor.
double getUniqueKeywordValue(const UnicodeString &keyword)
Deprecated Function, does not return useful results.
UnicodeString select(const number::impl::UFormattedNumberRangeData *urange, UErrorCode &status) const
static StringEnumeration * getAvailableLocales(UErrorCode &status)
Return a StringEnumeration over the locales for which there is plurals data.
virtual ~PluralRules()
Destructor.
UnicodeString select(double number) const
Given a floating-point number, returns the keyword of the first rule that applies to the number.
UnicodeString getKeywordOther() const
Returns keyword for default plural form.
StringEnumeration * getKeywords(UErrorCode &status) const
Returns a list of all rule keywords used in this PluralRules object.
UnicodeString getRules() const
UnicodeString select(int32_t number) const
Given an integer, returns the keyword of the first rule that applies to the number.
int32_t getSamples(const UnicodeString &keyword, double *dest, int32_t destCapacity, UErrorCode &status)
Returns sample values for which select() would return the keyword.
static PluralRules * internalForLocale(const Locale &locale, UPluralType type, UErrorCode &status)
For ICU use only.
int32_t getSamples(const UnicodeString &keyword, DecimalQuantity *dest, int32_t destCapacity, UErrorCode &status)
Internal-only function that returns DecimalQuantitys instead of doubles.
bool operator!=(const PluralRules &other) const
Compares the inequality of two PluralRules objects.
Definition plurrule.h:547
int32_t getAllKeywordValues(const UnicodeString &keyword, double *dest, int32_t destCapacity, UErrorCode &status)
Deprecated Function, does not produce useful results.
UnicodeString select(const IFixedDecimal &number) const
virtual bool operator==(const PluralRules &other) const
Compares the equality of two PluralRules objects.
static PluralRules * forLocale(const Locale &locale, UErrorCode &status)
Provides access to the predefined cardinal-number PluralRules for a given locale.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
static PluralRules * forLocale(const Locale &locale, UPluralType type, UErrorCode &status)
Provides access to the predefined PluralRules for a given locale and the plural type.
Base class for 'pure' C++ implementations of uenum api.
Definition strenum.h:61
UObject is the common ICU "boilerplate" class.
Definition uobject.h:223
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:296
The result of a number range formatting operation.
The result of a number formatting operation.
C++ API: Base class for all formats.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
C++ API: Compatibility APIs for number formatting.
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:247
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
C API: Plural rules, select plural keywords for numeric values.
UPluralType
Type of plurals and PluralRules.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:430
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:316