ICU 73.1 73.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
25U_NAMESPACE_BEGIN
26
27class Locale;
28class PluralRules;
29class Hashtable;
30
49public:
50
57
64 CurrencyPluralInfo(const Locale& locale, UErrorCode& status);
65
72
73
80
81
88
89
95 bool operator==(const CurrencyPluralInfo& info) const;
96
97
103 bool operator!=(const CurrencyPluralInfo& info) const;
104
105
112
113
121
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
196private:
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
253private:
258 UErrorCode fInternalStatus;
259};
260
261
262inline bool
264 return !operator==(info);
265}
266
267U_NAMESPACE_END
268
269#endif /* #if !UCONFIG_NO_FORMATTING */
270
271#endif /* U_SHOW_CPLUSPLUS_API */
272
273#endif // _CURRPINFO
274//eof
This class represents the information needed by DecimalFormat to format currency plural,...
Definition: currpinf.h:48
CurrencyPluralInfo & operator=(const CurrencyPluralInfo &info)
Assignment operator.
const PluralRules * getPluralRules() const
Gets plural rules of this locale, used for currency plural format.
UnicodeString & getCurrencyPluralPattern(const UnicodeString &pluralCount, UnicodeString &result) const
Given a plural count, gets currency plural pattern of this locale, used for currency plural format.
void setPluralRules(const UnicodeString &ruleDescription, UErrorCode &status)
Set plural rules.
bool operator==(const CurrencyPluralInfo &info) const
Equal operator.
CurrencyPluralInfo(UErrorCode &status)
Create a CurrencyPluralInfo object for the default locale.
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
CurrencyPluralInfo(const Locale &locale, UErrorCode &status)
Create a CurrencyPluralInfo object for the given locale.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
CurrencyPluralInfo * clone() const
Clone.
void setLocale(const Locale &loc, UErrorCode &status)
Set locale.
const Locale & getLocale() const
Get locale.
CurrencyPluralInfo(const CurrencyPluralInfo &info)
Copy constructor.
virtual ~CurrencyPluralInfo()
Destructor.
void setCurrencyPluralPattern(const UnicodeString &pluralCount, const UnicodeString &pattern, UErrorCode &status)
Set currency plural pattern.
IMPORTANT: New users are strongly encouraged to see if numberformatter.h fits their use case.
Definition: decimfmt.h:668
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
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
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:335
C++ API: Unicode String.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:301