currpinf.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) 2009-2015, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
#ifndef CURRPINF_H
#define CURRPINF_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_FORMATTING
#include "unicode/unistr.h"
U_NAMESPACE_BEGIN
class Locale;
class PluralRules;
class Hashtable;
class U_I18N_API CurrencyPluralInfo : public UObject {
public:
CurrencyPluralInfo(UErrorCode& status);
CurrencyPluralInfo(const Locale& locale, UErrorCode& status);
CurrencyPluralInfo(const CurrencyPluralInfo& info);
CurrencyPluralInfo& operator=(const CurrencyPluralInfo& info);
virtual ~CurrencyPluralInfo();
bool operator==(const CurrencyPluralInfo& info) const;
bool operator!=(const CurrencyPluralInfo& info) const;
CurrencyPluralInfo* clone() const;
const PluralRules* getPluralRules() const;
UnicodeString& getCurrencyPluralPattern(const UnicodeString& pluralCount,
UnicodeString& result) const;
const Locale& getLocale() const;
void setPluralRules(const UnicodeString& ruleDescription,
UErrorCode& status);
void setCurrencyPluralPattern(const UnicodeString& pluralCount,
const UnicodeString& pattern,
UErrorCode& status);
void setLocale(const Locale& loc, UErrorCode& status);
virtual UClassID getDynamicClassID() const override;
static UClassID U_EXPORT2 getStaticClassID();
private:
friend class DecimalFormat;
friend class DecimalFormatImpl;
void initialize(const Locale& loc, UErrorCode& status);
void setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status);
/*
* delete hash table
*
* @param hTable hash table to be deleted
*/
void deleteHash(Hashtable* hTable);
/*
* initialize hash table
*
* @param status output param set to success/failure code on exit
* @return hash table initialized
*/
Hashtable* initHash(UErrorCode& status);
void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
//-------------------- private data member ---------------------
// map from plural count to currency plural pattern, for example
// a plural pattern defined in "CurrencyUnitPatterns" is
// "one{{0} {1}}", in which "one" is a plural count
// and "{0} {1}" is a currency plural pattern".
// The currency plural pattern saved in this mapping is the pattern
// defined in "CurrencyUnitPattern" by replacing
// {0} with the number format pattern,
// and {1} with 3 currency sign.
Hashtable* fPluralCountToCurrencyUnitPattern;
/*
* The plural rule is used to format currency plural name,
* for example: "3.00 US Dollars".
* If there are 3 currency signs in the currency pattern,
* the 3 currency signs will be replaced by currency plural name.
*/
PluralRules* fPluralRules;
// locale
Locale* fLocale;
private:
UErrorCode fInternalStatus;
};
inline bool
CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const {
return !operator==(info);
}
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // _CURRPINFO
//eof
icu::CurrencyPluralInfo
This class represents the information needed by DecimalFormat to format currency plural,...
Definition: currpinf.h:48
icu::CurrencyPluralInfo::getLocale
const Locale & getLocale() const
Get locale.
icu::CurrencyPluralInfo::operator=
CurrencyPluralInfo & operator=(const CurrencyPluralInfo &info)
Assignment operator.
icu::CurrencyPluralInfo::clone
CurrencyPluralInfo * clone() const
Clone.
icu::CurrencyPluralInfo::getCurrencyPluralPattern
UnicodeString & getCurrencyPluralPattern(const UnicodeString &pluralCount, UnicodeString &result) const
Given a plural count, gets currency plural pattern of this locale, used for currency plural format.
icu::CurrencyPluralInfo::setPluralRules
void setPluralRules(const UnicodeString &ruleDescription, UErrorCode &status)
Set plural rules.
icu::CurrencyPluralInfo::operator==
bool operator==(const CurrencyPluralInfo &info) const
Equal operator.
icu::CurrencyPluralInfo::CurrencyPluralInfo
CurrencyPluralInfo(UErrorCode &status)
Create a CurrencyPluralInfo object for the default locale.
icu::CurrencyPluralInfo::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::CurrencyPluralInfo::CurrencyPluralInfo
CurrencyPluralInfo(const Locale &locale, UErrorCode &status)
Create a CurrencyPluralInfo object for the given locale.
icu::CurrencyPluralInfo::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::CurrencyPluralInfo::setLocale
void setLocale(const Locale &loc, UErrorCode &status)
Set locale.
icu::CurrencyPluralInfo::getPluralRules
const PluralRules * getPluralRules() const
Gets plural rules of this locale, used for currency plural format.
icu::CurrencyPluralInfo::CurrencyPluralInfo
CurrencyPluralInfo(const CurrencyPluralInfo &info)
Copy constructor.
icu::CurrencyPluralInfo::~CurrencyPluralInfo
virtual ~CurrencyPluralInfo()
Destructor.
icu::CurrencyPluralInfo::setCurrencyPluralPattern
void setCurrencyPluralPattern(const UnicodeString &pluralCount, const UnicodeString &pattern, UErrorCode &status)
Set currency plural pattern.
icu::DecimalFormat
IMPORTANT: New users are strongly encouraged to see if numberformatter.h fits their use case.
Definition: decimfmt.h:668
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
icu::PluralRules
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:212
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::operator!=
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:335
unistr.h
C++ API: Unicode String.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
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:415
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:301