Loading...
Searching...
No Matches
plurrule.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2008-2015, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*
*
* File PLURRULE.H
*
* Modification History:*
* Date Name Description
*
********************************************************************************
*/
#ifndef PLURRULE
#define PLURRULE
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_FORMATTING
#include "unicode/format.h"
#include "unicode/upluralrules.h"
#ifndef U_HIDE_INTERNAL_API
#include "unicode/numfmt.h"
#endif /* U_HIDE_INTERNAL_API */
#define UPLRULES_NO_UNIQUE_VALUE ((double)-0.00123456777)
U_NAMESPACE_BEGIN
class Hashtable;
class IFixedDecimal;
class FixedDecimal;
class RuleChain;
class PluralRuleParser;
class PluralKeywordEnumeration;
class AndConstraint;
class SharedPluralRules;
class StandardPluralRanges;
namespace number {
class FormattedNumber;
class FormattedNumberRange;
namespace impl {
class UFormattedNumberRangeData;
class DecimalQuantity;
class DecNum;
}
}
#ifndef U_HIDE_INTERNAL_API
using icu::number::impl::DecimalQuantity;
#endif /* U_HIDE_INTERNAL_API */
class U_I18N_API PluralRules : public UObject {
public:
PluralRules(UErrorCode& status);
PluralRules(const PluralRules& other);
virtual ~PluralRules();
PluralRules* clone() const;
PluralRules& operator=(const PluralRules&);
static PluralRules* U_EXPORT2 createRules(const UnicodeString& description,
UErrorCode& status);
static PluralRules* U_EXPORT2 createDefaultRules(UErrorCode& status);
static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UErrorCode& status);
static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UPluralType type, UErrorCode& status);
#ifndef U_HIDE_INTERNAL_API
static StringEnumeration* U_EXPORT2 getAvailableLocales(UErrorCode &status);
static PluralRules* U_EXPORT2 internalForLocale(const Locale& locale, UPluralType type, UErrorCode& status);
static const SharedPluralRules* U_EXPORT2 createSharedInstance(
const Locale& locale, UPluralType type, UErrorCode& status);
#endif /* U_HIDE_INTERNAL_API */
UnicodeString select(int32_t number) const;
UnicodeString select(double number) const;
UnicodeString select(const number::FormattedNumber& number, UErrorCode& status) const;
UnicodeString select(const number::FormattedNumberRange& range, UErrorCode& status) const;
#ifndef U_HIDE_INTERNAL_API
UnicodeString select(const IFixedDecimal &number) const;
UnicodeString select(const number::impl::UFormattedNumberRangeData* urange, UErrorCode& status) const;
#endif /* U_HIDE_INTERNAL_API */
StringEnumeration* getKeywords(UErrorCode& status) const;
#ifndef U_HIDE_DEPRECATED_API
double getUniqueKeywordValue(const UnicodeString& keyword);
int32_t getAllKeywordValues(const UnicodeString &keyword,
double *dest, int32_t destCapacity,
UErrorCode& status);
#endif /* U_HIDE_DEPRECATED_API */
int32_t getSamples(const UnicodeString &keyword,
double *dest, int32_t destCapacity,
UErrorCode& status);
#ifndef U_HIDE_INTERNAL_API
int32_t getSamples(const UnicodeString &keyword,
DecimalQuantity *dest, int32_t destCapacity,
UErrorCode& status);
#endif /* U_HIDE_INTERNAL_API */
UBool isKeyword(const UnicodeString& keyword) const;
UnicodeString getKeywordOther() const;
#ifndef U_HIDE_INTERNAL_API
UnicodeString getRules() const;
#endif /* U_HIDE_INTERNAL_API */
virtual bool operator==(const PluralRules& other) const;
bool operator!=(const PluralRules& other) const {return !operator==(other);}
static UClassID U_EXPORT2 getStaticClassID();
virtual UClassID getDynamicClassID() const override;
private:
RuleChain *mRules;
StandardPluralRanges *mStandardPluralRanges;
PluralRules() = delete; // default constructor not implemented
UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status);
RuleChain *rulesForKeyword(const UnicodeString &keyword) const;
PluralRules *clone(UErrorCode& status) const;
UErrorCode mInternalStatus;
friend class PluralRuleParser;
};
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // _PLURRULE
//eof
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:198
icu::PluralRules::select
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.
icu::PluralRules::select
UnicodeString select(const number::FormattedNumberRange &range, UErrorCode &status) const
Given a formatted number range, returns the overall plural form of the range.
icu::PluralRules::createSharedInstance
static const SharedPluralRules * createSharedInstance(const Locale &locale, UPluralType type, UErrorCode &status)
For ICU use only.
icu::PluralRules::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::PluralRules::createRules
static PluralRules * createRules(const UnicodeString &description, UErrorCode &status)
Creates a PluralRules from a description if it is parsable, otherwise returns nullptr.
icu::PluralRules::isKeyword
UBool isKeyword(const UnicodeString &keyword) const
Returns true if the given keyword is defined in this PluralRules object.
icu::PluralRules::PluralRules
PluralRules(UErrorCode &status)
Constructor.
icu::PluralRules::createDefaultRules
static PluralRules * createDefaultRules(UErrorCode &status)
The default rules that accept any number.
icu::PluralRules::operator=
PluralRules & operator=(const PluralRules &)
Assignment operator.
icu::PluralRules::clone
PluralRules * clone() const
Clone.
icu::PluralRules::PluralRules
PluralRules(const PluralRules &other)
Copy constructor.
icu::PluralRules::getUniqueKeywordValue
double getUniqueKeywordValue(const UnicodeString &keyword)
Deprecated Function, does not return useful results.
icu::PluralRules::select
UnicodeString select(const number::impl::UFormattedNumberRangeData *urange, UErrorCode &status) const
icu::PluralRules::getAvailableLocales
static StringEnumeration * getAvailableLocales(UErrorCode &status)
Return a StringEnumeration over the locales for which there is plurals data.
icu::PluralRules::~PluralRules
virtual ~PluralRules()
Destructor.
icu::PluralRules::select
UnicodeString select(double number) const
Given a floating-point number, returns the keyword of the first rule that applies to the number.
icu::PluralRules::getKeywordOther
UnicodeString getKeywordOther() const
Returns keyword for default plural form.
icu::PluralRules::getKeywords
StringEnumeration * getKeywords(UErrorCode &status) const
Returns a list of all rule keywords used in this PluralRules object.
icu::PluralRules::getRules
UnicodeString getRules() const
icu::PluralRules::select
UnicodeString select(int32_t number) const
Given an integer, returns the keyword of the first rule that applies to the number.
icu::PluralRules::getSamples
int32_t getSamples(const UnicodeString &keyword, double *dest, int32_t destCapacity, UErrorCode &status)
Returns sample values for which select() would return the keyword.
icu::PluralRules::internalForLocale
static PluralRules * internalForLocale(const Locale &locale, UPluralType type, UErrorCode &status)
For ICU use only.
icu::PluralRules::getSamples
int32_t getSamples(const UnicodeString &keyword, DecimalQuantity *dest, int32_t destCapacity, UErrorCode &status)
Internal-only function that returns DecimalQuantitys instead of doubles.
icu::PluralRules::operator!=
bool operator!=(const PluralRules &other) const
Compares the inequality of two PluralRules objects.
Definition plurrule.h:547
icu::PluralRules::getAllKeywordValues
int32_t getAllKeywordValues(const UnicodeString &keyword, double *dest, int32_t destCapacity, UErrorCode &status)
Deprecated Function, does not produce useful results.
icu::PluralRules::select
UnicodeString select(const IFixedDecimal &number) const
icu::PluralRules::operator==
virtual bool operator==(const PluralRules &other) const
Compares the equality of two PluralRules objects.
icu::PluralRules::forLocale
static PluralRules * forLocale(const Locale &locale, UErrorCode &status)
Provides access to the predefined cardinal-number PluralRules for a given locale.
icu::PluralRules::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::PluralRules::forLocale
static PluralRules * forLocale(const Locale &locale, UPluralType type, UErrorCode &status)
Provides access to the predefined PluralRules for a given locale and the plural type.
icu::StringEnumeration
Base class for 'pure' C++ implementations of uenum api.
Definition strenum.h:61
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition uobject.h:222
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
icu::number::FormattedNumberRange
The result of a number range formatting operation.
Definition numberrangeformatter.h:594
icu::number::FormattedNumber
The result of a number formatting operation.
Definition formattednumber.h:48
format.h
C++ API: Base class for all formats.
icu::operator==
U_COMMON_API UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
numfmt.h
C++ API: Compatibility APIs for number formatting.
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
upluralrules.h
C API: Plural rules, select plural keywords for numeric values.
UPluralType
UPluralType
Type of plurals and PluralRules.
Definition upluralrules.h:59
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
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:316