- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- Search for |

- File List
- Globals

# dcfmtsym.h

Go to the documentation of this file.

    00001 /*
    00002 ********************************************************************************
    00003 *   Copyright (C) 1997-2007, 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,
    00127         kMonetaryGroupingSeparatorSymbol,
    00129         kFormatSymbolCount
    00130     };
    00131
    00140     DecimalFormatSymbols(const Locale& locale, UErrorCode& status);
    00141
    00152     DecimalFormatSymbols( UErrorCode& status);
    00153
    00158     DecimalFormatSymbols(const DecimalFormatSymbols&);
    00159
    00164     DecimalFormatSymbols& operator=(const DecimalFormatSymbols&);
    00165
    00170     virtual ~DecimalFormatSymbols();
    00171
    00179     UBool operator==(const DecimalFormatSymbols& other) const;
    00180
    00188     UBool operator!=(const DecimalFormatSymbols& other) const { return !operator==(other); }
    00189
    00199     inline UnicodeString getSymbol(ENumberFormatSymbol symbol) const;
    00200
    00210     void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value);
    00211
    00216     inline Locale getLocale() const;
    00217
    00223     Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
    00224
    00230     virtual UClassID getDynamicClassID() const;
    00231
    00237     static UClassID U_EXPORT2 getStaticClassID();
    00238
    00239 private:
    00240     DecimalFormatSymbols(); // default constructor not implemented
    00241
    00252     void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
    00253
    00261     void initialize(const UChar** numberElements, int32_t *numberElementsStrLen, int32_t numberElementsLength);
    00262
    00266     void initialize();
    00267
    00268     void setCurrencyForSymbols();
    00269
    00270 public:
    00282     inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
    00283
    00288     inline const UChar* getCurrencyPattern(void) const;
    00289
    00290 private:
    00306     UnicodeString fSymbols[kFormatSymbolCount];
    00307
    00312     UnicodeString fNoSymbol;
    00313
    00314     Locale locale;
    00315
    00316     char actualLocale[ULOC_FULLNAME_CAPACITY];
    00317     char validLocale[ULOC_FULLNAME_CAPACITY];
    00318     const UChar* currPattern;
    00319 };
    00320
    00321 // -------------------------------------
    00322
    00323 inline UnicodeString
    00324 DecimalFormatSymbols::getSymbol(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 inline const UnicodeString &
    00335 DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
    00336     const UnicodeString *strPtr;
    00337     if(symbol < kFormatSymbolCount) {
    00338         strPtr = &fSymbols[symbol];
    00339     } else {
    00340         strPtr = &fNoSymbol;
    00341     }
    00342     return *strPtr;
    00343 }
    00344
    00345 // -------------------------------------
    00346
    00347 inline void
    00348 DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value) {
    00349     if(symbol<kFormatSymbolCount) {
    00350         fSymbols[symbol]=value;
    00351     }
    00352 }
    00353
    00354 // -------------------------------------
    00355
    00356 inline Locale
    00357 DecimalFormatSymbols::getLocale() const {
    00358     return locale;
    00359 }
    00360
    00361 inline const UChar*
    00362 DecimalFormatSymbols::getCurrencyPattern() const {
    00363     return currPattern;
    00364 }
    00365 U_NAMESPACE_END
    00366
    00367 #endif /* #if !UCONFIG_NO_FORMATTING */
    00368
    00369 #endif // _DCFMTSYM
    00370 //eof