Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

dcfmtsym.h

00001 /*
00002 ********************************************************************************
00003 *   Copyright (C) 1997-2003, 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,
00116         kFormatSymbolCount
00117     };
00118 
00127     DecimalFormatSymbols(const Locale& locale, UErrorCode& status);
00128 
00139     DecimalFormatSymbols( UErrorCode& status);
00140 
00145     DecimalFormatSymbols(const DecimalFormatSymbols&);
00146 
00151     DecimalFormatSymbols& operator=(const DecimalFormatSymbols&);
00152 
00157     ~DecimalFormatSymbols();
00158 
00166     UBool operator==(const DecimalFormatSymbols& other) const;
00167 
00175     UBool operator!=(const DecimalFormatSymbols& other) const { return !operator==(other); }
00176 
00186     inline UnicodeString getSymbol(ENumberFormatSymbol symbol) const;
00187 
00197     void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value);
00198 
00203     inline Locale getLocale() const;
00204 
00210     Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
00211 
00217     virtual UClassID getDynamicClassID() const;
00218 
00224     static UClassID getStaticClassID();
00225 
00226 private:
00227     DecimalFormatSymbols(); // default constructor not implemented
00228 
00239     void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
00240 
00248     void initialize(const UnicodeString* numberElements, int32_t numberElementsLength);
00249 
00253     void initialize();
00254 
00255     void setCurrencyForSymbols();
00256 
00257 public:
00269     inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
00270 
00271 private:
00287     UnicodeString fSymbols[kFormatSymbolCount];
00288 
00293     UnicodeString fNoSymbol;
00294 
00295     Locale locale;
00296 
00297     char actualLocale[ULOC_FULLNAME_CAPACITY];
00298     char validLocale[ULOC_FULLNAME_CAPACITY];
00299 };
00300 
00301 // -------------------------------------
00302 
00303 inline UnicodeString
00304 DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const {
00305     const UnicodeString *strPtr;
00306     if(symbol < kFormatSymbolCount) {
00307         strPtr = &fSymbols[symbol];
00308     } else {
00309         strPtr = &fNoSymbol;
00310     }
00311     return *strPtr;
00312 }
00313 
00314 inline const UnicodeString &
00315 DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
00316     const UnicodeString *strPtr;
00317     if(symbol < kFormatSymbolCount) {
00318         strPtr = &fSymbols[symbol];
00319     } else {
00320         strPtr = &fNoSymbol;
00321     }
00322     return *strPtr;
00323 }
00324 
00325 // -------------------------------------
00326 
00327 inline void
00328 DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value) {
00329     if(symbol<kFormatSymbolCount) {
00330         fSymbols[symbol]=value;
00331     }
00332 }
00333 
00334 // -------------------------------------
00335 
00336 inline Locale
00337 DecimalFormatSymbols::getLocale() const {
00338     return locale;
00339 }
00340 
00341 
00342 U_NAMESPACE_END
00343 
00344 #endif /* #if !UCONFIG_NO_FORMATTING */
00345 
00346 #endif // _DCFMTSYM
00347 //eof

Generated on Wed May 18 17:29:14 2005 for ICU 2.8 by  doxygen 1.4.2