dcfmtsym.h

Go to the documentation of this file.
00001 /*
00002 ********************************************************************************
00003 *   Copyright (C) 1997-2005, International Business Machines
00004 *   Corporation and others.  All Rights Reserved.
00005 ********************************************************************************
00006 *
00007 * File DCFMTSYM.H
00008 *
00009 * Modification History:
00010 * 
00011 *   Date        Name        Description
00012 *   02/19/97    aliu        Converted from java.
00013 *   03/18/97    clhuang     Updated per C++ implementation.
00014 *   03/27/97    helena      Updated to pass the simple test after code review.
00015 *   08/26/97    aliu        Added currency/intl currency symbol support.
00016 *   07/22/98    stephen     Changed to match C++ style 
00017 *                            currencySymbol -> fCurrencySymbol
00018 *                            Constants changed from CAPS to kCaps
00019 *   06/24/99    helena      Integrated Alan's NF enhancements and Java2 bug fixes
00020 *   09/22/00    grhoten     Marked deprecation tags with a pointer to replacement
00021 *                            functions.
00022 ********************************************************************************
00023 */
00024  
00025 #ifndef DCFMTSYM_H
00026 #define DCFMTSYM_H
00027  
00028 #include "unicode/utypes.h"
00029 
00030 #if !UCONFIG_NO_FORMATTING
00031 
00032 #include "unicode/uobject.h"
00033 #include "unicode/locid.h"
00034 
00041 U_NAMESPACE_BEGIN
00042 
00082 class U_I18N_API DecimalFormatSymbols : public UObject {
00083 public:
00088     enum ENumberFormatSymbol {
00090         kDecimalSeparatorSymbol,
00092         kGroupingSeparatorSymbol,
00094         kPatternSeparatorSymbol,
00096         kPercentSymbol,
00098         kZeroDigitSymbol,
00100         kDigitSymbol,
00102         kMinusSignSymbol,
00104         kPlusSignSymbol,
00106         kCurrencySymbol,
00108         kIntlCurrencySymbol,
00110         kMonetarySeparatorSymbol,
00112         kExponentialSymbol,
00114         kPerMillSymbol,
00116         kPadEscapeSymbol,
00118         kInfinitySymbol,
00120         kNaNSymbol,
00123         kSignificantDigitSymbol,
00125         kFormatSymbolCount
00126     };
00127 
00136     DecimalFormatSymbols(const Locale& locale, UErrorCode& status);
00137 
00148     DecimalFormatSymbols( UErrorCode& status);
00149 
00154     DecimalFormatSymbols(const DecimalFormatSymbols&);
00155 
00160     DecimalFormatSymbols& operator=(const DecimalFormatSymbols&);
00161 
00166     virtual ~DecimalFormatSymbols();
00167 
00175     UBool operator==(const DecimalFormatSymbols& other) const;
00176 
00184     UBool operator!=(const DecimalFormatSymbols& other) const { return !operator==(other); }
00185 
00195     inline UnicodeString getSymbol(ENumberFormatSymbol symbol) const;
00196 
00206     void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value);
00207 
00212     inline Locale getLocale() const;
00213 
00219     Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
00220 
00226     virtual UClassID getDynamicClassID() const;
00227 
00233     static UClassID U_EXPORT2 getStaticClassID();
00234 
00235 private:
00236     DecimalFormatSymbols(); // default constructor not implemented
00237 
00248     void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
00249 
00257     void initialize(const UChar** numberElements, int32_t *numberElementsStrLen, int32_t numberElementsLength);
00258 
00262     void initialize();
00263 
00264     void setCurrencyForSymbols();
00265 
00266 public:
00278     inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
00279 
00280 private:
00296     UnicodeString fSymbols[kFormatSymbolCount];
00297 
00302     UnicodeString fNoSymbol;
00303 
00304     Locale locale;
00305 
00306     char actualLocale[ULOC_FULLNAME_CAPACITY];
00307     char validLocale[ULOC_FULLNAME_CAPACITY];
00308 };
00309 
00310 // -------------------------------------
00311 
00312 inline UnicodeString
00313 DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const {
00314     const UnicodeString *strPtr;
00315     if(symbol < kFormatSymbolCount) {
00316         strPtr = &fSymbols[symbol];
00317     } else {
00318         strPtr = &fNoSymbol;
00319     }
00320     return *strPtr;
00321 }
00322 
00323 inline const UnicodeString &
00324 DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
00325     const UnicodeString *strPtr;
00326     if(symbol < kFormatSymbolCount) {
00327         strPtr = &fSymbols[symbol];
00328     } else {
00329         strPtr = &fNoSymbol;
00330     }
00331     return *strPtr;
00332 }
00333 
00334 // -------------------------------------
00335 
00336 inline void
00337 DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value) {
00338     if(symbol<kFormatSymbolCount) {
00339         fSymbols[symbol]=value;
00340     }
00341 }
00342 
00343 // -------------------------------------
00344 
00345 inline Locale
00346 DecimalFormatSymbols::getLocale() const {
00347     return locale;
00348 }
00349 
00350 
00351 U_NAMESPACE_END
00352 
00353 #endif /* #if !UCONFIG_NO_FORMATTING */
00354 
00355 #endif // _DCFMTSYM
00356 //eof

Generated on Tue Sep 13 11:03:32 2005 for ICU 3.4 by  doxygen 1.4.4