Main Page | Class Hierarchy | Alphabetical List | Data Structures | 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     UnicodeString getSymbol(ENumberFormatSymbol symbol) const;
00187 
00197     void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value);
00198 
00203     inline Locale getLocale() const;
00204 
00210     virtual inline UClassID getDynamicClassID() const;
00211 
00217     static inline UClassID getStaticClassID();
00218 
00219 private:
00220     DecimalFormatSymbols(); // default constructor not implemented
00221 
00232     void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
00233 
00241     void initialize(const UnicodeString* numberElements, int32_t numberElementsLength);
00242 
00246     void initialize();
00247 
00248     void setCurrencyForSymbols();
00249 
00250 public:
00262     inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
00263 
00264 private:
00280     UnicodeString fSymbols[kFormatSymbolCount];
00281 
00286     UnicodeString fNoSymbol;
00287 
00288     Locale locale;
00289 
00290     static const char fgNumberElements[];
00291 
00296     static const char fgClassID;
00297 };
00298 
00299 inline UClassID
00300 DecimalFormatSymbols::getStaticClassID()
00301 { return (UClassID)&fgClassID; }
00302 
00303 inline UClassID
00304 DecimalFormatSymbols::getDynamicClassID() const
00305 { return DecimalFormatSymbols::getStaticClassID(); }
00306 
00307 // -------------------------------------
00308 
00309 inline UnicodeString
00310 DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const {
00311     if(symbol<kFormatSymbolCount) {
00312         return fSymbols[symbol];
00313     } else {
00314         return UnicodeString();
00315     }
00316 }
00317 
00318 inline const UnicodeString &
00319 DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
00320     if(symbol<kFormatSymbolCount) {
00321         return fSymbols[symbol];
00322     } else {
00323         return fNoSymbol;
00324     }
00325 }
00326 
00327 // -------------------------------------
00328 
00329 inline void
00330 DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value) {
00331     if(symbol<kFormatSymbolCount) {
00332         fSymbols[symbol]=value;
00333     }
00334 }
00335 
00336 // -------------------------------------
00337 
00338 inline Locale
00339 DecimalFormatSymbols::getLocale() const {
00340     return locale;
00341 }
00342 
00343 
00344 U_NAMESPACE_END
00345 
00346 #endif /* #if !UCONFIG_NO_FORMATTING */
00347 
00348 #endif // _DCFMTSYM
00349 //eof

Generated on Wed Sep 3 17:47:08 2003 for ICU 2.6 by doxygen 1.3.2