ICU 4.8.1.1  4.8.1.1
currpinf.h
Go to the documentation of this file.
00001 /*
00002  *******************************************************************************
00003  * Copyright (C) 2009-2011, International Business Machines Corporation and         *
00004  * others. All Rights Reserved.                                                *
00005  *******************************************************************************
00006  */
00007 #ifndef CURRPINF_H
00008 #define CURRPINF_H
00009 
00010 #include "unicode/utypes.h"
00011 
00017 #if !UCONFIG_NO_FORMATTING
00018 
00019 #include "unicode/unistr.h"
00020 
00021 union UHashTok;
00022 
00023 U_NAMESPACE_BEGIN
00024 
00025 class Locale;
00026 class PluralRules;
00027 class Hashtable;
00028 
00046 class  U_I18N_API CurrencyPluralInfo : public UObject {
00047 public:
00048 
00054     CurrencyPluralInfo(UErrorCode& status);
00055 
00062     CurrencyPluralInfo(const Locale& locale, UErrorCode& status); 
00063 
00069     CurrencyPluralInfo(const CurrencyPluralInfo& info);
00070 
00071 
00077     CurrencyPluralInfo& operator=(const CurrencyPluralInfo& info);
00078 
00079 
00085     virtual ~CurrencyPluralInfo();
00086 
00087 
00093     UBool operator==(const CurrencyPluralInfo& info) const;
00094 
00095 
00101     UBool operator!=(const CurrencyPluralInfo& info) const;
00102 
00103 
00109     CurrencyPluralInfo* clone() const;
00110 
00111 
00118     const PluralRules* getPluralRules() const;
00119 
00129     UnicodeString& getCurrencyPluralPattern(const UnicodeString& pluralCount,
00130                                             UnicodeString& result) const; 
00131 
00138     const Locale& getLocale() const;
00139 
00151     void setPluralRules(const UnicodeString& ruleDescription,
00152                         UErrorCode& status);
00153 
00167     void setCurrencyPluralPattern(const UnicodeString& pluralCount, 
00168                                   const UnicodeString& pattern,
00169                                   UErrorCode& status);
00170 
00178     void setLocale(const Locale& loc, UErrorCode& status);
00179 
00185     virtual UClassID getDynamicClassID() const;
00186 
00192     static UClassID U_EXPORT2 getStaticClassID();
00193 
00194 private:
00195     friend class DecimalFormat;
00196 
00197     void initialize(const Locale& loc, UErrorCode& status);
00198    
00199     void setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status);
00200 
00201     /*
00202      * delete hash table
00203      *
00204      * @param hTable  hash table to be deleted
00205      */
00206     void deleteHash(Hashtable* hTable);
00207 
00208 
00209     /*
00210      * initialize hash table
00211      *
00212      * @param status   output param set to success/failure code on exit
00213      * @return         hash table initialized
00214      */
00215     Hashtable* initHash(UErrorCode& status);
00216 
00217 
00218 
00226     void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
00227 
00228     //-------------------- private data member ---------------------
00229     // map from plural count to currency plural pattern, for example
00230     // a plural pattern defined in "CurrencyUnitPatterns" is
00231     // "one{{0} {1}}", in which "one" is a plural count
00232     // and "{0} {1}" is a currency plural pattern".
00233     // The currency plural pattern saved in this mapping is the pattern
00234     // defined in "CurrencyUnitPattern" by replacing
00235     // {0} with the number format pattern,
00236     // and {1} with 3 currency sign.
00237     Hashtable* fPluralCountToCurrencyUnitPattern;
00238 
00239     /*
00240      * The plural rule is used to format currency plural name,
00241      * for example: "3.00 US Dollars".
00242      * If there are 3 currency signs in the currency patttern,
00243      * the 3 currency signs will be replaced by currency plural name.
00244      */
00245     PluralRules* fPluralRules;
00246 
00247     // locale
00248     Locale* fLocale;
00249 };
00250 
00251 
00252 inline UBool
00253 CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const {              return !operator==(info);                                                   }  
00254 
00255 U_NAMESPACE_END
00256 
00257 #endif /* #if !UCONFIG_NO_FORMATTING */
00258 
00259 #endif // _CURRPINFO
00260 //eof
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines