Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

dcfmtsym.h

Go to the documentation of this file.
00001 /*
00002 ********************************************************************************
00003 *   Copyright (C) 1997-1999, 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, UnicodeString value);
00198 
00202     inline Locale getLocale() const;
00203 
00209     virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00210 
00216     static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00217 
00218 private:
00229     void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
00230 
00238     void initialize(const UnicodeString* numberElements, const UnicodeString* currencyElements);
00239 
00243     void initialize();
00244 
00245     void setCurrencyForSymbols();
00246 
00247 public:
00259     inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
00260 
00261 private:
00277     UnicodeString fSymbols[kFormatSymbolCount];
00278 
00283     UnicodeString fNoSymbol;
00284 
00285     Locale locale;
00286 
00287     static const char fgNumberElements[];
00288     static const char fgCurrencyElements[];
00289 
00294     static const char fgClassID;
00295 };
00296 
00297 
00298 // -------------------------------------
00299 
00300 inline UnicodeString
00301 DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const {
00302     if(symbol<kFormatSymbolCount) {
00303         return fSymbols[symbol];
00304     } else {
00305         return UnicodeString();
00306     }
00307 }
00308 
00309 inline const UnicodeString &
00310 DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
00311     if(symbol<kFormatSymbolCount) {
00312         return fSymbols[symbol];
00313     } else {
00314         return fNoSymbol;
00315     }
00316 }
00317 
00318 // -------------------------------------
00319 
00320 /* TODO: This should use "const UnicodeString &value" */
00321 inline void
00322 DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, UnicodeString value) {
00323     if(symbol<kFormatSymbolCount) {
00324         fSymbols[symbol]=value;
00325     }
00326 }
00327 
00328 // -------------------------------------
00329 
00330 inline Locale
00331 DecimalFormatSymbols::getLocale() const {
00332     return locale;
00333 }
00334 
00335 
00336 U_NAMESPACE_END
00337 
00338 #endif /* #if !UCONFIG_NO_FORMATTING */
00339 
00340 #endif // _DCFMTSYM
00341 //eof

Generated on Wed Dec 18 16:49:32 2002 for ICU 2.4 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001