1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/unicode/currpinf.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,258 @@ 1.4 +/* 1.5 + ******************************************************************************* 1.6 + * Copyright (C) 2009-2011, International Business Machines Corporation and * 1.7 + * others. All Rights Reserved. * 1.8 + ******************************************************************************* 1.9 + */ 1.10 +#ifndef CURRPINF_H 1.11 +#define CURRPINF_H 1.12 + 1.13 +#include "unicode/utypes.h" 1.14 + 1.15 +/** 1.16 + * \file 1.17 + * \brief C++ API: Currency Plural Information used by Decimal Format 1.18 + */ 1.19 + 1.20 +#if !UCONFIG_NO_FORMATTING 1.21 + 1.22 +#include "unicode/unistr.h" 1.23 + 1.24 +U_NAMESPACE_BEGIN 1.25 + 1.26 +class Locale; 1.27 +class PluralRules; 1.28 +class Hashtable; 1.29 + 1.30 +/** 1.31 + * This class represents the information needed by 1.32 + * DecimalFormat to format currency plural, 1.33 + * such as "3.00 US dollars" or "1.00 US dollar". 1.34 + * DecimalFormat creates for itself an instance of 1.35 + * CurrencyPluralInfo from its locale data. 1.36 + * If you need to change any of these symbols, you can get the 1.37 + * CurrencyPluralInfo object from your 1.38 + * DecimalFormat and modify it. 1.39 + * 1.40 + * Following are the information needed for currency plural format and parse: 1.41 + * locale information, 1.42 + * plural rule of the locale, 1.43 + * currency plural pattern of the locale. 1.44 + * 1.45 + * @stable ICU 4.2 1.46 + */ 1.47 +class U_I18N_API CurrencyPluralInfo : public UObject { 1.48 +public: 1.49 + 1.50 + /** 1.51 + * Create a CurrencyPluralInfo object for the default locale. 1.52 + * @param status output param set to success/failure code on exit 1.53 + * @stable ICU 4.2 1.54 + */ 1.55 + CurrencyPluralInfo(UErrorCode& status); 1.56 + 1.57 + /** 1.58 + * Create a CurrencyPluralInfo object for the given locale. 1.59 + * @param locale the locale 1.60 + * @param status output param set to success/failure code on exit 1.61 + * @stable ICU 4.2 1.62 + */ 1.63 + CurrencyPluralInfo(const Locale& locale, UErrorCode& status); 1.64 + 1.65 + /** 1.66 + * Copy constructor 1.67 + * 1.68 + * @stable ICU 4.2 1.69 + */ 1.70 + CurrencyPluralInfo(const CurrencyPluralInfo& info); 1.71 + 1.72 + 1.73 + /** 1.74 + * Assignment operator 1.75 + * 1.76 + * @stable ICU 4.2 1.77 + */ 1.78 + CurrencyPluralInfo& operator=(const CurrencyPluralInfo& info); 1.79 + 1.80 + 1.81 + /** 1.82 + * Destructor 1.83 + * 1.84 + * @stable ICU 4.2 1.85 + */ 1.86 + virtual ~CurrencyPluralInfo(); 1.87 + 1.88 + 1.89 + /** 1.90 + * Equal operator. 1.91 + * 1.92 + * @stable ICU 4.2 1.93 + */ 1.94 + UBool operator==(const CurrencyPluralInfo& info) const; 1.95 + 1.96 + 1.97 + /** 1.98 + * Not equal operator 1.99 + * 1.100 + * @stable ICU 4.2 1.101 + */ 1.102 + UBool operator!=(const CurrencyPluralInfo& info) const; 1.103 + 1.104 + 1.105 + /** 1.106 + * Clone 1.107 + * 1.108 + * @stable ICU 4.2 1.109 + */ 1.110 + CurrencyPluralInfo* clone() const; 1.111 + 1.112 + 1.113 + /** 1.114 + * Gets plural rules of this locale, used for currency plural format 1.115 + * 1.116 + * @return plural rule 1.117 + * @stable ICU 4.2 1.118 + */ 1.119 + const PluralRules* getPluralRules() const; 1.120 + 1.121 + /** 1.122 + * Given a plural count, gets currency plural pattern of this locale, 1.123 + * used for currency plural format 1.124 + * 1.125 + * @param pluralCount currency plural count 1.126 + * @param result output param to receive the pattern 1.127 + * @return a currency plural pattern based on plural count 1.128 + * @stable ICU 4.2 1.129 + */ 1.130 + UnicodeString& getCurrencyPluralPattern(const UnicodeString& pluralCount, 1.131 + UnicodeString& result) const; 1.132 + 1.133 + /** 1.134 + * Get locale 1.135 + * 1.136 + * @return locale 1.137 + * @stable ICU 4.2 1.138 + */ 1.139 + const Locale& getLocale() const; 1.140 + 1.141 + /** 1.142 + * Set plural rules. 1.143 + * The plural rule is set when CurrencyPluralInfo 1.144 + * instance is created. 1.145 + * You can call this method to reset plural rules only if you want 1.146 + * to modify the default plural rule of the locale. 1.147 + * 1.148 + * @param ruleDescription new plural rule description 1.149 + * @param status output param set to success/failure code on exit 1.150 + * @stable ICU 4.2 1.151 + */ 1.152 + void setPluralRules(const UnicodeString& ruleDescription, 1.153 + UErrorCode& status); 1.154 + 1.155 + /** 1.156 + * Set currency plural pattern. 1.157 + * The currency plural pattern is set when CurrencyPluralInfo 1.158 + * instance is created. 1.159 + * You can call this method to reset currency plural pattern only if 1.160 + * you want to modify the default currency plural pattern of the locale. 1.161 + * 1.162 + * @param pluralCount the plural count for which the currency pattern will 1.163 + * be overridden. 1.164 + * @param pattern the new currency plural pattern 1.165 + * @param status output param set to success/failure code on exit 1.166 + * @stable ICU 4.2 1.167 + */ 1.168 + void setCurrencyPluralPattern(const UnicodeString& pluralCount, 1.169 + const UnicodeString& pattern, 1.170 + UErrorCode& status); 1.171 + 1.172 + /** 1.173 + * Set locale 1.174 + * 1.175 + * @param loc the new locale to set 1.176 + * @param status output param set to success/failure code on exit 1.177 + * @stable ICU 4.2 1.178 + */ 1.179 + void setLocale(const Locale& loc, UErrorCode& status); 1.180 + 1.181 + /** 1.182 + * ICU "poor man's RTTI", returns a UClassID for the actual class. 1.183 + * 1.184 + * @stable ICU 4.2 1.185 + */ 1.186 + virtual UClassID getDynamicClassID() const; 1.187 + 1.188 + /** 1.189 + * ICU "poor man's RTTI", returns a UClassID for this class. 1.190 + * 1.191 + * @stable ICU 4.2 1.192 + */ 1.193 + static UClassID U_EXPORT2 getStaticClassID(); 1.194 + 1.195 +private: 1.196 + friend class DecimalFormat; 1.197 + 1.198 + void initialize(const Locale& loc, UErrorCode& status); 1.199 + 1.200 + void setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status); 1.201 + 1.202 + /* 1.203 + * delete hash table 1.204 + * 1.205 + * @param hTable hash table to be deleted 1.206 + */ 1.207 + void deleteHash(Hashtable* hTable); 1.208 + 1.209 + 1.210 + /* 1.211 + * initialize hash table 1.212 + * 1.213 + * @param status output param set to success/failure code on exit 1.214 + * @return hash table initialized 1.215 + */ 1.216 + Hashtable* initHash(UErrorCode& status); 1.217 + 1.218 + 1.219 + 1.220 + /** 1.221 + * copy hash table 1.222 + * 1.223 + * @param source the source to copy from 1.224 + * @param target the target to copy to 1.225 + * @param status error code 1.226 + */ 1.227 + void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status); 1.228 + 1.229 + //-------------------- private data member --------------------- 1.230 + // map from plural count to currency plural pattern, for example 1.231 + // a plural pattern defined in "CurrencyUnitPatterns" is 1.232 + // "one{{0} {1}}", in which "one" is a plural count 1.233 + // and "{0} {1}" is a currency plural pattern". 1.234 + // The currency plural pattern saved in this mapping is the pattern 1.235 + // defined in "CurrencyUnitPattern" by replacing 1.236 + // {0} with the number format pattern, 1.237 + // and {1} with 3 currency sign. 1.238 + Hashtable* fPluralCountToCurrencyUnitPattern; 1.239 + 1.240 + /* 1.241 + * The plural rule is used to format currency plural name, 1.242 + * for example: "3.00 US Dollars". 1.243 + * If there are 3 currency signs in the currency patttern, 1.244 + * the 3 currency signs will be replaced by currency plural name. 1.245 + */ 1.246 + PluralRules* fPluralRules; 1.247 + 1.248 + // locale 1.249 + Locale* fLocale; 1.250 +}; 1.251 + 1.252 + 1.253 +inline UBool 1.254 +CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const { return !operator==(info); } 1.255 + 1.256 +U_NAMESPACE_END 1.257 + 1.258 +#endif /* #if !UCONFIG_NO_FORMATTING */ 1.259 + 1.260 +#endif // _CURRPINFO 1.261 +//eof