annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/unicode/currpinf.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 // © 2016 and later: Unicode, Inc. and others.
jpayne@69 2 // License & terms of use: http://www.unicode.org/copyright.html
jpayne@69 3 /*
jpayne@69 4 *******************************************************************************
jpayne@69 5 * Copyright (C) 2009-2015, International Business Machines Corporation and *
jpayne@69 6 * others. All Rights Reserved. *
jpayne@69 7 *******************************************************************************
jpayne@69 8 */
jpayne@69 9 #ifndef CURRPINF_H
jpayne@69 10 #define CURRPINF_H
jpayne@69 11
jpayne@69 12 #include "unicode/utypes.h"
jpayne@69 13
jpayne@69 14 #if U_SHOW_CPLUSPLUS_API
jpayne@69 15
jpayne@69 16 /**
jpayne@69 17 * \file
jpayne@69 18 * \brief C++ API: Currency Plural Information used by Decimal Format
jpayne@69 19 */
jpayne@69 20
jpayne@69 21 #if !UCONFIG_NO_FORMATTING
jpayne@69 22
jpayne@69 23 #include "unicode/unistr.h"
jpayne@69 24
jpayne@69 25 U_NAMESPACE_BEGIN
jpayne@69 26
jpayne@69 27 class Locale;
jpayne@69 28 class PluralRules;
jpayne@69 29 class Hashtable;
jpayne@69 30
jpayne@69 31 /**
jpayne@69 32 * This class represents the information needed by
jpayne@69 33 * DecimalFormat to format currency plural,
jpayne@69 34 * such as "3.00 US dollars" or "1.00 US dollar".
jpayne@69 35 * DecimalFormat creates for itself an instance of
jpayne@69 36 * CurrencyPluralInfo from its locale data.
jpayne@69 37 * If you need to change any of these symbols, you can get the
jpayne@69 38 * CurrencyPluralInfo object from your
jpayne@69 39 * DecimalFormat and modify it.
jpayne@69 40 *
jpayne@69 41 * Following are the information needed for currency plural format and parse:
jpayne@69 42 * locale information,
jpayne@69 43 * plural rule of the locale,
jpayne@69 44 * currency plural pattern of the locale.
jpayne@69 45 *
jpayne@69 46 * @stable ICU 4.2
jpayne@69 47 */
jpayne@69 48 class U_I18N_API CurrencyPluralInfo : public UObject {
jpayne@69 49 public:
jpayne@69 50
jpayne@69 51 /**
jpayne@69 52 * Create a CurrencyPluralInfo object for the default locale.
jpayne@69 53 * @param status output param set to success/failure code on exit
jpayne@69 54 * @stable ICU 4.2
jpayne@69 55 */
jpayne@69 56 CurrencyPluralInfo(UErrorCode& status);
jpayne@69 57
jpayne@69 58 /**
jpayne@69 59 * Create a CurrencyPluralInfo object for the given locale.
jpayne@69 60 * @param locale the locale
jpayne@69 61 * @param status output param set to success/failure code on exit
jpayne@69 62 * @stable ICU 4.2
jpayne@69 63 */
jpayne@69 64 CurrencyPluralInfo(const Locale& locale, UErrorCode& status);
jpayne@69 65
jpayne@69 66 /**
jpayne@69 67 * Copy constructor
jpayne@69 68 *
jpayne@69 69 * @stable ICU 4.2
jpayne@69 70 */
jpayne@69 71 CurrencyPluralInfo(const CurrencyPluralInfo& info);
jpayne@69 72
jpayne@69 73
jpayne@69 74 /**
jpayne@69 75 * Assignment operator
jpayne@69 76 *
jpayne@69 77 * @stable ICU 4.2
jpayne@69 78 */
jpayne@69 79 CurrencyPluralInfo& operator=(const CurrencyPluralInfo& info);
jpayne@69 80
jpayne@69 81
jpayne@69 82 /**
jpayne@69 83 * Destructor
jpayne@69 84 *
jpayne@69 85 * @stable ICU 4.2
jpayne@69 86 */
jpayne@69 87 virtual ~CurrencyPluralInfo();
jpayne@69 88
jpayne@69 89
jpayne@69 90 /**
jpayne@69 91 * Equal operator.
jpayne@69 92 *
jpayne@69 93 * @stable ICU 4.2
jpayne@69 94 */
jpayne@69 95 UBool operator==(const CurrencyPluralInfo& info) const;
jpayne@69 96
jpayne@69 97
jpayne@69 98 /**
jpayne@69 99 * Not equal operator
jpayne@69 100 *
jpayne@69 101 * @stable ICU 4.2
jpayne@69 102 */
jpayne@69 103 UBool operator!=(const CurrencyPluralInfo& info) const;
jpayne@69 104
jpayne@69 105
jpayne@69 106 /**
jpayne@69 107 * Clone
jpayne@69 108 *
jpayne@69 109 * @stable ICU 4.2
jpayne@69 110 */
jpayne@69 111 CurrencyPluralInfo* clone() const;
jpayne@69 112
jpayne@69 113
jpayne@69 114 /**
jpayne@69 115 * Gets plural rules of this locale, used for currency plural format
jpayne@69 116 *
jpayne@69 117 * @return plural rule
jpayne@69 118 * @stable ICU 4.2
jpayne@69 119 */
jpayne@69 120 const PluralRules* getPluralRules() const;
jpayne@69 121
jpayne@69 122 /**
jpayne@69 123 * Given a plural count, gets currency plural pattern of this locale,
jpayne@69 124 * used for currency plural format
jpayne@69 125 *
jpayne@69 126 * @param pluralCount currency plural count
jpayne@69 127 * @param result output param to receive the pattern
jpayne@69 128 * @return a currency plural pattern based on plural count
jpayne@69 129 * @stable ICU 4.2
jpayne@69 130 */
jpayne@69 131 UnicodeString& getCurrencyPluralPattern(const UnicodeString& pluralCount,
jpayne@69 132 UnicodeString& result) const;
jpayne@69 133
jpayne@69 134 /**
jpayne@69 135 * Get locale
jpayne@69 136 *
jpayne@69 137 * @return locale
jpayne@69 138 * @stable ICU 4.2
jpayne@69 139 */
jpayne@69 140 const Locale& getLocale() const;
jpayne@69 141
jpayne@69 142 /**
jpayne@69 143 * Set plural rules.
jpayne@69 144 * The plural rule is set when CurrencyPluralInfo
jpayne@69 145 * instance is created.
jpayne@69 146 * You can call this method to reset plural rules only if you want
jpayne@69 147 * to modify the default plural rule of the locale.
jpayne@69 148 *
jpayne@69 149 * @param ruleDescription new plural rule description
jpayne@69 150 * @param status output param set to success/failure code on exit
jpayne@69 151 * @stable ICU 4.2
jpayne@69 152 */
jpayne@69 153 void setPluralRules(const UnicodeString& ruleDescription,
jpayne@69 154 UErrorCode& status);
jpayne@69 155
jpayne@69 156 /**
jpayne@69 157 * Set currency plural pattern.
jpayne@69 158 * The currency plural pattern is set when CurrencyPluralInfo
jpayne@69 159 * instance is created.
jpayne@69 160 * You can call this method to reset currency plural pattern only if
jpayne@69 161 * you want to modify the default currency plural pattern of the locale.
jpayne@69 162 *
jpayne@69 163 * @param pluralCount the plural count for which the currency pattern will
jpayne@69 164 * be overridden.
jpayne@69 165 * @param pattern the new currency plural pattern
jpayne@69 166 * @param status output param set to success/failure code on exit
jpayne@69 167 * @stable ICU 4.2
jpayne@69 168 */
jpayne@69 169 void setCurrencyPluralPattern(const UnicodeString& pluralCount,
jpayne@69 170 const UnicodeString& pattern,
jpayne@69 171 UErrorCode& status);
jpayne@69 172
jpayne@69 173 /**
jpayne@69 174 * Set locale
jpayne@69 175 *
jpayne@69 176 * @param loc the new locale to set
jpayne@69 177 * @param status output param set to success/failure code on exit
jpayne@69 178 * @stable ICU 4.2
jpayne@69 179 */
jpayne@69 180 void setLocale(const Locale& loc, UErrorCode& status);
jpayne@69 181
jpayne@69 182 /**
jpayne@69 183 * ICU "poor man's RTTI", returns a UClassID for the actual class.
jpayne@69 184 *
jpayne@69 185 * @stable ICU 4.2
jpayne@69 186 */
jpayne@69 187 virtual UClassID getDynamicClassID() const;
jpayne@69 188
jpayne@69 189 /**
jpayne@69 190 * ICU "poor man's RTTI", returns a UClassID for this class.
jpayne@69 191 *
jpayne@69 192 * @stable ICU 4.2
jpayne@69 193 */
jpayne@69 194 static UClassID U_EXPORT2 getStaticClassID();
jpayne@69 195
jpayne@69 196 private:
jpayne@69 197 friend class DecimalFormat;
jpayne@69 198 friend class DecimalFormatImpl;
jpayne@69 199
jpayne@69 200 void initialize(const Locale& loc, UErrorCode& status);
jpayne@69 201
jpayne@69 202 void setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status);
jpayne@69 203
jpayne@69 204 /*
jpayne@69 205 * delete hash table
jpayne@69 206 *
jpayne@69 207 * @param hTable hash table to be deleted
jpayne@69 208 */
jpayne@69 209 void deleteHash(Hashtable* hTable);
jpayne@69 210
jpayne@69 211
jpayne@69 212 /*
jpayne@69 213 * initialize hash table
jpayne@69 214 *
jpayne@69 215 * @param status output param set to success/failure code on exit
jpayne@69 216 * @return hash table initialized
jpayne@69 217 */
jpayne@69 218 Hashtable* initHash(UErrorCode& status);
jpayne@69 219
jpayne@69 220
jpayne@69 221
jpayne@69 222 /**
jpayne@69 223 * copy hash table
jpayne@69 224 *
jpayne@69 225 * @param source the source to copy from
jpayne@69 226 * @param target the target to copy to
jpayne@69 227 * @param status error code
jpayne@69 228 */
jpayne@69 229 void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
jpayne@69 230
jpayne@69 231 //-------------------- private data member ---------------------
jpayne@69 232 // map from plural count to currency plural pattern, for example
jpayne@69 233 // a plural pattern defined in "CurrencyUnitPatterns" is
jpayne@69 234 // "one{{0} {1}}", in which "one" is a plural count
jpayne@69 235 // and "{0} {1}" is a currency plural pattern".
jpayne@69 236 // The currency plural pattern saved in this mapping is the pattern
jpayne@69 237 // defined in "CurrencyUnitPattern" by replacing
jpayne@69 238 // {0} with the number format pattern,
jpayne@69 239 // and {1} with 3 currency sign.
jpayne@69 240 Hashtable* fPluralCountToCurrencyUnitPattern;
jpayne@69 241
jpayne@69 242 /*
jpayne@69 243 * The plural rule is used to format currency plural name,
jpayne@69 244 * for example: "3.00 US Dollars".
jpayne@69 245 * If there are 3 currency signs in the currency pattern,
jpayne@69 246 * the 3 currency signs will be replaced by currency plural name.
jpayne@69 247 */
jpayne@69 248 PluralRules* fPluralRules;
jpayne@69 249
jpayne@69 250 // locale
jpayne@69 251 Locale* fLocale;
jpayne@69 252
jpayne@69 253 private:
jpayne@69 254 /**
jpayne@69 255 * An internal status variable used to indicate that the object is in an 'invalid' state.
jpayne@69 256 * Used by copy constructor, the assignment operator and the clone method.
jpayne@69 257 */
jpayne@69 258 UErrorCode fInternalStatus;
jpayne@69 259 };
jpayne@69 260
jpayne@69 261
jpayne@69 262 inline UBool
jpayne@69 263 CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const {
jpayne@69 264 return !operator==(info);
jpayne@69 265 }
jpayne@69 266
jpayne@69 267 U_NAMESPACE_END
jpayne@69 268
jpayne@69 269 #endif /* #if !UCONFIG_NO_FORMATTING */
jpayne@69 270
jpayne@69 271 #endif /* U_SHOW_CPLUSPLUS_API */
jpayne@69 272
jpayne@69 273 #endif // _CURRPINFO
jpayne@69 274 //eof