dcfmtsym.h

00001 /*
00002 ********************************************************************************
00003 *   Copyright (C) 1997-2004, 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 
00035 U_NAMESPACE_BEGIN
00036 
00076 class U_I18N_API DecimalFormatSymbols : public UObject {
00077 public:
00082     enum ENumberFormatSymbol {
00084         kDecimalSeparatorSymbol,
00086         kGroupingSeparatorSymbol,
00088         kPatternSeparatorSymbol,
00090         kPercentSymbol,
00092         kZeroDigitSymbol,
00094         kDigitSymbol,
00096         kMinusSignSymbol,
00098         kPlusSignSymbol,
00100         kCurrencySymbol,
00102         kIntlCurrencySymbol,
00104         kMonetarySeparatorSymbol,
00106         kExponentialSymbol,
00108         kPerMillSymbol,
00110         kPadEscapeSymbol,
00112         kInfinitySymbol,
00114         kNaNSymbol,
00117         kSignificantDigitSymbol,
00119         kFormatSymbolCount
00120     };
00121 
00130     DecimalFormatSymbols(const Locale& locale, UErrorCode& status);
00131 
00142     DecimalFormatSymbols( UErrorCode& status);
00143 
00148     DecimalFormatSymbols(const DecimalFormatSymbols&);
00149 
00154     DecimalFormatSymbols& operator=(const DecimalFormatSymbols&);
00155 
00160     virtual ~DecimalFormatSymbols();
00161 
00169     UBool operator==(const DecimalFormatSymbols& other) const;
00170 
00178     UBool operator!=(const DecimalFormatSymbols& other) const { return !operator==(other); }
00179 
00189     inline UnicodeString getSymbol(ENumberFormatSymbol symbol) const;
00190 
00200     void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value);
00201 
00206     inline Locale getLocale() const;
00207 
00213     Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
00214 
00220     virtual UClassID getDynamicClassID() const;
00221 
00227     static UClassID U_EXPORT2 getStaticClassID();
00228 
00229 private:
00230     DecimalFormatSymbols(); // default constructor not implemented
00231 
00242     void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
00243 
00251     void initialize(const UChar** numberElements, int32_t *numberElementsStrLen, int32_t numberElementsLength);
00252 
00256     void initialize();
00257 
00258     void setCurrencyForSymbols();
00259 
00260 public:
00272     inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
00273 
00274 private:
00290     UnicodeString fSymbols[kFormatSymbolCount];
00291 
00296     UnicodeString fNoSymbol;
00297 
00298     Locale locale;
00299 
00300     char actualLocale[ULOC_FULLNAME_CAPACITY];
00301     char validLocale[ULOC_FULLNAME_CAPACITY];
00302 };
00303 
00304 // -------------------------------------
00305 
00306 inline UnicodeString
00307 DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const {
00308     const UnicodeString *strPtr;
00309     if(symbol < kFormatSymbolCount) {
00310         strPtr = &fSymbols[symbol];
00311     } else {
00312         strPtr = &fNoSymbol;
00313     }
00314     return *strPtr;
00315 }
00316 
00317 inline const UnicodeString &
00318 DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
00319     const UnicodeString *strPtr;
00320     if(symbol < kFormatSymbolCount) {
00321         strPtr = &fSymbols[symbol];
00322     } else {
00323         strPtr = &fNoSymbol;
00324     }
00325     return *strPtr;
00326 }
00327 
00328 // -------------------------------------
00329 
00330 inline void
00331 DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value) {
00332     if(symbol<kFormatSymbolCount) {
00333         fSymbols[symbol]=value;
00334     }
00335 }
00336 
00337 // -------------------------------------
00338 
00339 inline Locale
00340 DecimalFormatSymbols::getLocale() const {
00341     return locale;
00342 }
00343 
00344 
00345 U_NAMESPACE_END
00346 
00347 #endif /* #if !UCONFIG_NO_FORMATTING */
00348 
00349 #endif // _DCFMTSYM
00350 //eof

Generated on Tue Nov 16 10:03:05 2004 for ICU 3.2 by  doxygen 1.3.9.1