|
||||
Warning, file /include/unicode/currpinf.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // © 2016 and later: Unicode, Inc. and others. 0002 // License & terms of use: http://www.unicode.org/copyright.html 0003 /* 0004 ******************************************************************************* 0005 * Copyright (C) 2009-2015, International Business Machines Corporation and * 0006 * others. All Rights Reserved. * 0007 ******************************************************************************* 0008 */ 0009 #ifndef CURRPINF_H 0010 #define CURRPINF_H 0011 0012 #include "unicode/utypes.h" 0013 0014 #if U_SHOW_CPLUSPLUS_API 0015 0016 /** 0017 * \file 0018 * \brief C++ API: Currency Plural Information used by Decimal Format 0019 */ 0020 0021 #if !UCONFIG_NO_FORMATTING 0022 0023 #include "unicode/unistr.h" 0024 0025 U_NAMESPACE_BEGIN 0026 0027 class Locale; 0028 class PluralRules; 0029 class Hashtable; 0030 0031 /** 0032 * This class represents the information needed by 0033 * DecimalFormat to format currency plural, 0034 * such as "3.00 US dollars" or "1.00 US dollar". 0035 * DecimalFormat creates for itself an instance of 0036 * CurrencyPluralInfo from its locale data. 0037 * If you need to change any of these symbols, you can get the 0038 * CurrencyPluralInfo object from your 0039 * DecimalFormat and modify it. 0040 * 0041 * Following are the information needed for currency plural format and parse: 0042 * locale information, 0043 * plural rule of the locale, 0044 * currency plural pattern of the locale. 0045 * 0046 * @stable ICU 4.2 0047 */ 0048 class U_I18N_API CurrencyPluralInfo : public UObject { 0049 public: 0050 0051 /** 0052 * Create a CurrencyPluralInfo object for the default locale. 0053 * @param status output param set to success/failure code on exit 0054 * @stable ICU 4.2 0055 */ 0056 CurrencyPluralInfo(UErrorCode& status); 0057 0058 /** 0059 * Create a CurrencyPluralInfo object for the given locale. 0060 * @param locale the locale 0061 * @param status output param set to success/failure code on exit 0062 * @stable ICU 4.2 0063 */ 0064 CurrencyPluralInfo(const Locale& locale, UErrorCode& status); 0065 0066 /** 0067 * Copy constructor 0068 * 0069 * @stable ICU 4.2 0070 */ 0071 CurrencyPluralInfo(const CurrencyPluralInfo& info); 0072 0073 0074 /** 0075 * Assignment operator 0076 * 0077 * @stable ICU 4.2 0078 */ 0079 CurrencyPluralInfo& operator=(const CurrencyPluralInfo& info); 0080 0081 0082 /** 0083 * Destructor 0084 * 0085 * @stable ICU 4.2 0086 */ 0087 virtual ~CurrencyPluralInfo(); 0088 0089 0090 /** 0091 * Equal operator. 0092 * 0093 * @stable ICU 4.2 0094 */ 0095 bool operator==(const CurrencyPluralInfo& info) const; 0096 0097 0098 /** 0099 * Not equal operator 0100 * 0101 * @stable ICU 4.2 0102 */ 0103 bool operator!=(const CurrencyPluralInfo& info) const; 0104 0105 0106 /** 0107 * Clone 0108 * 0109 * @stable ICU 4.2 0110 */ 0111 CurrencyPluralInfo* clone() const; 0112 0113 0114 /** 0115 * Gets plural rules of this locale, used for currency plural format 0116 * 0117 * @return plural rule 0118 * @stable ICU 4.2 0119 */ 0120 const PluralRules* getPluralRules() const; 0121 0122 /** 0123 * Given a plural count, gets currency plural pattern of this locale, 0124 * used for currency plural format 0125 * 0126 * @param pluralCount currency plural count 0127 * @param result output param to receive the pattern 0128 * @return a currency plural pattern based on plural count 0129 * @stable ICU 4.2 0130 */ 0131 UnicodeString& getCurrencyPluralPattern(const UnicodeString& pluralCount, 0132 UnicodeString& result) const; 0133 0134 /** 0135 * Get locale 0136 * 0137 * @return locale 0138 * @stable ICU 4.2 0139 */ 0140 const Locale& getLocale() const; 0141 0142 /** 0143 * Set plural rules. 0144 * The plural rule is set when CurrencyPluralInfo 0145 * instance is created. 0146 * You can call this method to reset plural rules only if you want 0147 * to modify the default plural rule of the locale. 0148 * 0149 * @param ruleDescription new plural rule description 0150 * @param status output param set to success/failure code on exit 0151 * @stable ICU 4.2 0152 */ 0153 void setPluralRules(const UnicodeString& ruleDescription, 0154 UErrorCode& status); 0155 0156 /** 0157 * Set currency plural pattern. 0158 * The currency plural pattern is set when CurrencyPluralInfo 0159 * instance is created. 0160 * You can call this method to reset currency plural pattern only if 0161 * you want to modify the default currency plural pattern of the locale. 0162 * 0163 * @param pluralCount the plural count for which the currency pattern will 0164 * be overridden. 0165 * @param pattern the new currency plural pattern 0166 * @param status output param set to success/failure code on exit 0167 * @stable ICU 4.2 0168 */ 0169 void setCurrencyPluralPattern(const UnicodeString& pluralCount, 0170 const UnicodeString& pattern, 0171 UErrorCode& status); 0172 0173 /** 0174 * Set locale 0175 * 0176 * @param loc the new locale to set 0177 * @param status output param set to success/failure code on exit 0178 * @stable ICU 4.2 0179 */ 0180 void setLocale(const Locale& loc, UErrorCode& status); 0181 0182 /** 0183 * ICU "poor man's RTTI", returns a UClassID for the actual class. 0184 * 0185 * @stable ICU 4.2 0186 */ 0187 virtual UClassID getDynamicClassID() const override; 0188 0189 /** 0190 * ICU "poor man's RTTI", returns a UClassID for this class. 0191 * 0192 * @stable ICU 4.2 0193 */ 0194 static UClassID U_EXPORT2 getStaticClassID(); 0195 0196 private: 0197 friend class DecimalFormat; 0198 friend class DecimalFormatImpl; 0199 0200 void initialize(const Locale& loc, UErrorCode& status); 0201 0202 void setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status); 0203 0204 /* 0205 * delete hash table 0206 * 0207 * @param hTable hash table to be deleted 0208 */ 0209 void deleteHash(Hashtable* hTable); 0210 0211 0212 /* 0213 * initialize hash table 0214 * 0215 * @param status output param set to success/failure code on exit 0216 * @return hash table initialized 0217 */ 0218 Hashtable* initHash(UErrorCode& status); 0219 0220 0221 0222 /** 0223 * copy hash table 0224 * 0225 * @param source the source to copy from 0226 * @param target the target to copy to 0227 * @param status error code 0228 */ 0229 void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status); 0230 0231 //-------------------- private data member --------------------- 0232 // map from plural count to currency plural pattern, for example 0233 // a plural pattern defined in "CurrencyUnitPatterns" is 0234 // "one{{0} {1}}", in which "one" is a plural count 0235 // and "{0} {1}" is a currency plural pattern". 0236 // The currency plural pattern saved in this mapping is the pattern 0237 // defined in "CurrencyUnitPattern" by replacing 0238 // {0} with the number format pattern, 0239 // and {1} with 3 currency sign. 0240 Hashtable* fPluralCountToCurrencyUnitPattern; 0241 0242 /* 0243 * The plural rule is used to format currency plural name, 0244 * for example: "3.00 US Dollars". 0245 * If there are 3 currency signs in the currency pattern, 0246 * the 3 currency signs will be replaced by currency plural name. 0247 */ 0248 PluralRules* fPluralRules; 0249 0250 // locale 0251 Locale* fLocale; 0252 0253 private: 0254 /** 0255 * An internal status variable used to indicate that the object is in an 'invalid' state. 0256 * Used by copy constructor, the assignment operator and the clone method. 0257 */ 0258 UErrorCode fInternalStatus; 0259 }; 0260 0261 0262 inline bool 0263 CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const { 0264 return !operator==(info); 0265 } 0266 0267 U_NAMESPACE_END 0268 0269 #endif /* #if !UCONFIG_NO_FORMATTING */ 0270 0271 #endif /* U_SHOW_CPLUSPLUS_API */ 0272 0273 #endif // _CURRPINFO 0274 //eof
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |