| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 ******************************************************************************* | |
| 3 * Copyright (C) 2009-2010, 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 | |
| 12 /** | |
| 13 * \file | |
| 14 * \brief C++ API: Currency Plural Information used by Decimal Format | |
| 15 */ | |
| 16 | |
| 17 #if !UCONFIG_NO_FORMATTING | |
| 18 | |
| 19 #include "unicode/unistr.h" | |
| 20 | |
| 21 union UHashTok; | |
| 22 | |
| 23 U_NAMESPACE_BEGIN | |
| 24 | |
| 25 class Locale; | |
| 26 class PluralRules; | |
| 27 class Hashtable; | |
| 28 | |
| 29 /** | |
| 30 * This class represents the information needed by | |
| 31 * DecimalFormat to format currency plural, | |
| 32 * such as "3.00 US dollars" or "1.00 US dollar". | |
| 33 * DecimalFormat creates for itself an instance of | |
| 34 * CurrencyPluralInfo from its locale data. | |
| 35 * If you need to change any of these symbols, you can get the | |
| 36 * CurrencyPluralInfo object from your | |
| 37 * DecimalFormat and modify it. | |
| 38 * | |
| 39 * Following are the information needed for currency plural format and parse: | |
| 40 * locale information, | |
| 41 * plural rule of the locale, | |
| 42 * currency plural pattern of the locale. | |
| 43 * | |
| 44 * @stable ICU 4.2 | |
| 45 */ | |
| 46 class U_I18N_API CurrencyPluralInfo : public UObject { | |
| 47 public: | |
| 48 | |
| 49 /** | |
| 50 * Create a CurrencyPluralInfo object for the default locale. | |
| 51 * @param status output param set to success/failure code on exit | |
| 52 * @stable ICU 4.2 | |
| 53 */ | |
| 54 CurrencyPluralInfo(UErrorCode& status); | |
| 55 | |
| 56 /** | |
| 57 * Create a CurrencyPluralInfo object for the given locale. | |
| 58 * @param locale the locale | |
| 59 * @param status output param set to success/failure code on exit | |
| 60 * @stable ICU 4.2 | |
| 61 */ | |
| 62 CurrencyPluralInfo(const Locale& locale, UErrorCode& status); | |
| 63 | |
| 64 /** | |
| 65 * Copy constructor | |
| 66 * | |
| 67 * @stable ICU 4.2 | |
| 68 */ | |
| 69 CurrencyPluralInfo(const CurrencyPluralInfo& info); | |
| 70 | |
| 71 | |
| 72 /** | |
| 73 * Assignment operator | |
| 74 * | |
| 75 * @stable ICU 4.2 | |
| 76 */ | |
| 77 CurrencyPluralInfo& operator=(const CurrencyPluralInfo& info); | |
| 78 | |
| 79 | |
| 80 /** | |
| 81 * Destructor | |
| 82 * | |
| 83 * @stable ICU 4.2 | |
| 84 */ | |
| 85 virtual ~CurrencyPluralInfo(); | |
| 86 | |
| 87 | |
| 88 /** | |
| 89 * Equal operator. | |
| 90 * | |
| 91 * @stable ICU 4.2 | |
| 92 */ | |
| 93 UBool operator==(const CurrencyPluralInfo& info) const; | |
| 94 | |
| 95 | |
| 96 /** | |
| 97 * Not equal operator | |
| 98 * | |
| 99 * @stable ICU 4.2 | |
| 100 */ | |
| 101 UBool operator!=(const CurrencyPluralInfo& info) const; | |
| 102 | |
| 103 | |
| 104 /** | |
| 105 * Clone | |
| 106 * | |
| 107 * @stable ICU 4.2 | |
| 108 */ | |
| 109 CurrencyPluralInfo* clone() const; | |
| 110 | |
| 111 | |
| 112 /** | |
| 113 * Gets plural rules of this locale, used for currency plural format | |
| 114 * | |
| 115 * @return plural rule | |
| 116 * @stable ICU 4.2 | |
| 117 */ | |
| 118 const PluralRules* getPluralRules() const; | |
| 119 | |
| 120 /** | |
| 121 * Given a plural count, gets currency plural pattern of this locale, | |
| 122 * used for currency plural format | |
| 123 * | |
| 124 * @param pluralCount currency plural count | |
| 125 * @param result output param to receive the pattern | |
| 126 * @return a currency plural pattern based on plural count | |
| 127 * @stable ICU 4.2 | |
| 128 */ | |
| 129 UnicodeString& getCurrencyPluralPattern(const UnicodeString& pluralCount, | |
| 130 UnicodeString& result) const; | |
| 131 | |
| 132 /** | |
| 133 * Get locale | |
| 134 * | |
| 135 * @return locale | |
| 136 * @stable ICU 4.2 | |
| 137 */ | |
| 138 const Locale& getLocale() const; | |
| 139 | |
| 140 /** | |
| 141 * Set plural rules. | |
| 142 * The plural rule is set when CurrencyPluralInfo | |
| 143 * instance is created. | |
| 144 * You can call this method to reset plural rules only if you want | |
| 145 * to modify the default plural rule of the locale. | |
| 146 * | |
| 147 * @param ruleDescription new plural rule description | |
| 148 * @param status output param set to success/failure code on exit | |
| 149 * @stable ICU 4.2 | |
| 150 */ | |
| 151 void setPluralRules(const UnicodeString& ruleDescription, | |
| 152 UErrorCode& status); | |
| 153 | |
| 154 /** | |
| 155 * Set currency plural pattern. | |
| 156 * The currency plural pattern is set when CurrencyPluralInfo | |
| 157 * instance is created. | |
| 158 * You can call this method to reset currency plural pattern only if | |
| 159 * you want to modify the default currency plural pattern of the locale. | |
| 160 * | |
| 161 * @param pluralCount the plural count for which the currency pattern will | |
| 162 * be overridden. | |
| 163 * @param pattern the new currency plural pattern | |
| 164 * @param status output param set to success/failure code on exit | |
| 165 * @stable ICU 4.2 | |
| 166 */ | |
| 167 void setCurrencyPluralPattern(const UnicodeString& pluralCount, | |
| 168 const UnicodeString& pattern, | |
| 169 UErrorCode& status); | |
| 170 | |
| 171 /** | |
| 172 * Set locale | |
| 173 * | |
| 174 * @param loc the new locale to set | |
| 175 * @param status output param set to success/failure code on exit | |
| 176 * @stable ICU 4.2 | |
| 177 */ | |
| 178 void setLocale(const Locale& loc, UErrorCode& status); | |
| 179 | |
| 180 /** | |
| 181 * ICU "poor man's RTTI", returns a UClassID for the actual class. | |
| 182 * | |
| 183 * @stable ICU 4.2 | |
| 184 */ | |
| 185 virtual UClassID getDynamicClassID() const; | |
| 186 | |
| 187 /** | |
| 188 * ICU "poor man's RTTI", returns a UClassID for this class. | |
| 189 * | |
| 190 * @stable ICU 4.2 | |
| 191 */ | |
| 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 | |
| 219 /** | |
| 220 * copy hash table | |
| 221 * | |
| 222 * @param source the source to copy from | |
| 223 * @param target the target to copy to | |
| 224 */ | |
| 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 | |
| 254 U_NAMESPACE_END | |
| 255 | |
| 256 #endif /* #if !UCONFIG_NO_FORMATTING */ | |
| 257 | |
| 258 #endif // _CURRPINFO | |
| 259 //eof | |
| OLD | NEW |