ICU 63.1  63.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 
19 #if !UCONFIG_NO_FORMATTING
20 
21 #include "unicode/unistr.h"
22 
24 
25 class Locale;
26 class PluralRules;
27 class Hashtable;
28 
47 public:
48 
55 
62  CurrencyPluralInfo(const Locale& locale, UErrorCode& status);
63 
70 
71 
78 
79 
86 
87 
93  UBool operator==(const CurrencyPluralInfo& info) const;
94 
95 
101  UBool operator!=(const CurrencyPluralInfo& info) const;
102 
103 
110 
111 
118  const PluralRules* getPluralRules() const;
119 
130  UnicodeString& result) const;
131 
138  const Locale& getLocale() const;
139 
151  void setPluralRules(const UnicodeString& ruleDescription,
152  UErrorCode& status);
153 
167  void setCurrencyPluralPattern(const UnicodeString& pluralCount,
168  const UnicodeString& pattern,
169  UErrorCode& status);
170 
178  void setLocale(const Locale& loc, UErrorCode& status);
179 
185  virtual UClassID getDynamicClassID() const;
186 
192  static UClassID U_EXPORT2 getStaticClassID();
193 
194 private:
195  friend class DecimalFormat;
196  friend class DecimalFormatImpl;
197 
198  void initialize(const Locale& loc, UErrorCode& status);
199 
200  void setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status);
201 
202  /*
203  * delete hash table
204  *
205  * @param hTable hash table to be deleted
206  */
207  void deleteHash(Hashtable* hTable);
208 
209 
210  /*
211  * initialize hash table
212  *
213  * @param status output param set to success/failure code on exit
214  * @return hash table initialized
215  */
216  Hashtable* initHash(UErrorCode& status);
217 
218 
219 
227  void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
228 
229  //-------------------- private data member ---------------------
230  // map from plural count to currency plural pattern, for example
231  // a plural pattern defined in "CurrencyUnitPatterns" is
232  // "one{{0} {1}}", in which "one" is a plural count
233  // and "{0} {1}" is a currency plural pattern".
234  // The currency plural pattern saved in this mapping is the pattern
235  // defined in "CurrencyUnitPattern" by replacing
236  // {0} with the number format pattern,
237  // and {1} with 3 currency sign.
238  Hashtable* fPluralCountToCurrencyUnitPattern;
239 
240  /*
241  * The plural rule is used to format currency plural name,
242  * for example: "3.00 US Dollars".
243  * If there are 3 currency signs in the currency pattern,
244  * the 3 currency signs will be replaced by currency plural name.
245  */
246  PluralRules* fPluralRules;
247 
248  // locale
249  Locale* fLocale;
250 
251 private:
256  UErrorCode fInternalStatus;
257 };
258 
259 
260 inline UBool
262  return !operator==(info);
263 }
264 
266 
267 #endif /* #if !UCONFIG_NO_FORMATTING */
268 
269 #endif // _CURRPINFO
270 //eof
icu::CurrencyPluralInfo::setCurrencyPluralPattern
void setCurrencyPluralPattern(const UnicodeString &pluralCount, const UnicodeString &pattern, UErrorCode &status)
Set currency plural pattern.
icu::CurrencyPluralInfo::setLocale
void setLocale(const Locale &loc, UErrorCode &status)
Set locale.
icu::CurrencyPluralInfo::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::CurrencyPluralInfo::getLocale
const Locale & getLocale() const
Get locale.
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
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225
icu::CurrencyPluralInfo::CurrencyPluralInfo
CurrencyPluralInfo(const Locale &locale, UErrorCode &status)
Create a CurrencyPluralInfo object for the given locale.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::PluralRules
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition: plurrule.h:194
icu::CurrencyPluralInfo::setPluralRules
void setPluralRules(const UnicodeString &ruleDescription, UErrorCode &status)
Set plural rules.
icu::CurrencyPluralInfo::operator==
UBool operator==(const CurrencyPluralInfo &info) const
Equal operator.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:290
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:220
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:90
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:401
icu::CurrencyPluralInfo::getPluralRules
const PluralRules * getPluralRules() const
Gets plural rules of this locale, used for currency plural format.
icu::operator!=
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
icu::DecimalFormat
IMPORTANT: New users are strongly encouraged to see if numberformatter.h fits their use case.
Definition: decimfmt.h:677
icu::CurrencyPluralInfo::clone
CurrencyPluralInfo * clone() const
Clone.
icu::CurrencyPluralInfo::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::CurrencyPluralInfo::~CurrencyPluralInfo
virtual ~CurrencyPluralInfo()
Destructor.
icu::CurrencyPluralInfo
This class represents the information needed by DecimalFormat to format currency plural,...
Definition: currpinf.h:46
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:192
icu::CurrencyPluralInfo::operator=
CurrencyPluralInfo & operator=(const CurrencyPluralInfo &info)
Assignment operator.
unistr.h
C++ API: Unicode String.
icu::CurrencyPluralInfo::CurrencyPluralInfo
CurrencyPluralInfo(const CurrencyPluralInfo &info)
Copy constructor.
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::CurrencyPluralInfo
CurrencyPluralInfo(UErrorCode &status)
Create a CurrencyPluralInfo object for the default locale.