ICU 74.1 74.1

currpinf.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) 2009-2015, International Business Machines Corporation and *
6 * others. All Rights Reserved. *
7 *******************************************************************************
8 */
9 #ifndef CURRPINF_H
10 #define CURRPINF_H
11
12 #include "unicode/utypes.h"
13
14 #if U_SHOW_CPLUSPLUS_API
15
21 #if !UCONFIG_NO_FORMATTING
22
23 #include "unicode/unistr.h"
24
25 U_NAMESPACE_BEGIN
26
27 class Locale;
28 class PluralRules;
29 class Hashtable;
30
48 class U_I18N_API CurrencyPluralInfo : public UObject {
49 public:
50
56 CurrencyPluralInfo(UErrorCode& status);
57
64 CurrencyPluralInfo(const Locale& locale, UErrorCode& status);
65
71 CurrencyPluralInfo(const CurrencyPluralInfo& info);
72
73
79 CurrencyPluralInfo& operator=(const CurrencyPluralInfo& info);
80
81
87 virtual ~CurrencyPluralInfo();
88
89
95 bool operator==(const CurrencyPluralInfo& info) const;
96
97
103 bool operator!=(const CurrencyPluralInfo& info) const;
104
105
111 CurrencyPluralInfo* clone() const;
112
113
120 const PluralRules* getPluralRules() const;
121
131 UnicodeString& getCurrencyPluralPattern(const UnicodeString& pluralCount,
132 UnicodeString& result) const;
133
140 const Locale& getLocale() const;
141
153 void setPluralRules(const UnicodeString& ruleDescription,
154 UErrorCode& status);
155
169 void setCurrencyPluralPattern(const UnicodeString& pluralCount,
170 const UnicodeString& pattern,
171 UErrorCode& status);
172
180 void setLocale(const Locale& loc, UErrorCode& status);
181
187 virtual UClassID getDynamicClassID() const override;
188
194 static UClassID U_EXPORT2 getStaticClassID();
195
196 private:
197 friend class DecimalFormat;
198 friend class DecimalFormatImpl;
199
200 void initialize(const Locale& loc, UErrorCode& status);
201
202 void setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status);
203
204 /*
205 * delete hash table
206 *
207 * @param hTable hash table to be deleted
208 */
209 void deleteHash(Hashtable* hTable);
210
211
212 /*
213 * initialize hash table
214 *
215 * @param status output param set to success/failure code on exit
216 * @return hash table initialized
217 */
218 Hashtable* initHash(UErrorCode& status);
219
220
221
229 void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
230
231 //-------------------- private data member ---------------------
232 // map from plural count to currency plural pattern, for example
233 // a plural pattern defined in "CurrencyUnitPatterns" is
234 // "one{{0} {1}}", in which "one" is a plural count
235 // and "{0} {1}" is a currency plural pattern".
236 // The currency plural pattern saved in this mapping is the pattern
237 // defined in "CurrencyUnitPattern" by replacing
238 // {0} with the number format pattern,
239 // and {1} with 3 currency sign.
240 Hashtable* fPluralCountToCurrencyUnitPattern;
241
242 /*
243 * The plural rule is used to format currency plural name,
244 * for example: "3.00 US Dollars".
245 * If there are 3 currency signs in the currency pattern,
246 * the 3 currency signs will be replaced by currency plural name.
247 */
248 PluralRules* fPluralRules;
249
250 // locale
251 Locale* fLocale;
252
253 private:
258 UErrorCode fInternalStatus;
259 };
260
261
262 inline bool
263 CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const {
264 return !operator==(info);
265 }
266
267 U_NAMESPACE_END
268
269 #endif /* #if !UCONFIG_NO_FORMATTING */
270
271 #endif /* U_SHOW_CPLUSPLUS_API */
272
273 #endif // _CURRPINFO
274 //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