ICU 4.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
currpinf.h
Go to the documentation of this file.
1 /*
2  *******************************************************************************
3  * Copyright (C) 2009, International Business Machines Corporation and *
4  * others. All Rights Reserved. *
5  *******************************************************************************
6  */
7 #ifndef CURRPINF_H
8 #define CURRPINF_H
9 
10 #include "unicode/utypes.h"
11 
17 #if !UCONFIG_NO_FORMATTING
18 
19 #include "unicode/unistr.h"
20 
21 union UHashTok;
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 
77  CurrencyPluralInfo& operator=(const CurrencyPluralInfo& info);
78 
79 
85  virtual ~CurrencyPluralInfo();
86 
87 
93  UBool operator==(const CurrencyPluralInfo& info) const;
94 
95 
101  UBool operator!=(const CurrencyPluralInfo& info) const;
102 
103 
109  CurrencyPluralInfo* clone() const;
110 
111 
118  const PluralRules* getPluralRules() const;
119 
129  UnicodeString& getCurrencyPluralPattern(const UnicodeString& pluralCount,
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 
197  void initialize(const Locale& loc, UErrorCode& status);
198 
199  void setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status);
200 
201  /*
202  * delete hash table
203  *
204  * @param hTable hash table to be deleted
205  */
206  void deleteHash(Hashtable* hTable);
207 
208 
209  /*
210  * initialize hash table
211  *
212  * @param status output param set to success/failure code on exit
213  * @return hash table initialized
214  */
215  Hashtable* initHash(UErrorCode& status);
216 
217 
218 
225  void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
226 
227  //-------------------- private data member ---------------------
228  // map from plural count to currency plural pattern, for example
229  // a plural pattern defined in "CurrencyUnitPatterns" is
230  // "one{{0} {1}}", in which "one" is a plural count
231  // and "{0} {1}" is a currency plural pattern".
232  // The currency plural pattern saved in this mapping is the pattern
233  // defined in "CurrencyUnitPattern" by replacing
234  // {0} with the number format pattern,
235  // and {1} with 3 currency sign.
236  Hashtable* fPluralCountToCurrencyUnitPattern;
237 
238  /*
239  * The plural rule is used to format currency plural name,
240  * for example: "3.00 US Dollars".
241  * If there are 3 currency signs in the currency patttern,
242  * the 3 currency signs will be replaced by currency plural name.
243  */
244  PluralRules* fPluralRules;
245 
246  // locale
247  Locale* fLocale;
248 };
249 
250 
251 inline UBool
252 CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const { return !operator==(info); }
253 
255 
256 #endif /* #if !UCONFIG_NO_FORMATTING */
257 
258 #endif // _CURRPINFO
259 //eof
This class represents the information needed by DecimalFormat to format currency plural, such as "3.00 US dollars" or "1.00 US dollar".
Definition: currpinf.h:46
C++ API: Unicode String.
UBool operator==(const CurrencyPluralInfo &info) const
Equal operator.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:475
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:183
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:187
#define U_EXPORT2
Definition: platform.h:338
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API If the compiler doesn't support namespaces...
Definition: uversion.h:184
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:212
UBool operator!=(const CurrencyPluralInfo &info) const
Not equal operator.
Definition: currpinf.h:252
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
Definition: utypes.h:339
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:593
Defines rules for mapping positive long values onto a small set of keywords.
Definition: plurrule.h:104
DecimalFormat is a concrete subclass of NumberFormat that formats decimal numbers.
Definition: decimfmt.h:650
Basic definitions for ICU, for both C and C++ APIs.
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:181
virtual UClassID getDynamicClassID() const =0
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:208