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

- Search for |

- File List
- Globals

# dcfmtsym.h

Go to the documentation of this file.

    00001 /*
    00002 ********************************************************************************
    00003 *   Copyright (C) 1997-2009, 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
    00136      enum ECurrencySpacing {
    00137        kCurrencyMatch,
    00138        kSurroundingMatch,
    00139        kInsert,
    00140        kCurrencySpacingCount
    00141      };
    00142
    00151     DecimalFormatSymbols(const Locale& locale, UErrorCode& status);
    00152
    00163     DecimalFormatSymbols( UErrorCode& status);
    00164
    00169     DecimalFormatSymbols(const DecimalFormatSymbols&);
    00170
    00175     DecimalFormatSymbols& operator=(const DecimalFormatSymbols&);
    00176
    00181     virtual ~DecimalFormatSymbols();
    00182
    00190     UBool operator==(const DecimalFormatSymbols& other) const;
    00191
    00199     UBool operator!=(const DecimalFormatSymbols& other) const { return !operator==(other); }
    00200
    00210     inline UnicodeString getSymbol(ENumberFormatSymbol symbol) const;
    00211
    00221     void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value);
    00222
    00227     inline Locale getLocale() const;
    00228
    00234     Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
    00235
    00252      const UnicodeString& getPatternForCurrencySpacing(ECurrencySpacing type,
    00253                                                  UBool beforeCurrency,
    00254                                                  UErrorCode& status) const;
    00265      void setPatternForCurrencySpacing(ECurrencySpacing type,
    00266                                        UBool beforeCurrency,
    00267                                        const UnicodeString& pattern);
    00268
    00274     virtual UClassID getDynamicClassID() const;
    00275
    00281     static UClassID U_EXPORT2 getStaticClassID();
    00282
    00283 private:
    00284     DecimalFormatSymbols(); // default constructor not implemented
    00285
    00296     void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
    00297
    00305     void initialize(const UChar** numberElements, int32_t *numberElementsStrLen, int32_t numberElementsLength);
    00306
    00310     void initialize();
    00311
    00312     void setCurrencyForSymbols();
    00313
    00314 public:
    00326     inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
    00327
    00332     inline const UChar* getCurrencyPattern(void) const;
    00333
    00334 private:
    00350     UnicodeString fSymbols[kFormatSymbolCount];
    00351
    00356     UnicodeString fNoSymbol;
    00357
    00358     Locale locale;
    00359
    00360     char actualLocale[ULOC_FULLNAME_CAPACITY];
    00361     char validLocale[ULOC_FULLNAME_CAPACITY];
    00362     const UChar* currPattern;
    00363
    00364     UnicodeString currencySpcBeforeSym[kCurrencySpacingCount];
    00365     UnicodeString currencySpcAfterSym[kCurrencySpacingCount];
    00366 };
    00367
    00368 // -------------------------------------
    00369
    00370 inline UnicodeString
    00371 DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const {
    00372     const UnicodeString *strPtr;
    00373     if(symbol < kFormatSymbolCount) {
    00374         strPtr = &fSymbols[symbol];
    00375     } else {
    00376         strPtr = &fNoSymbol;
    00377     }
    00378     return *strPtr;
    00379 }
    00380
    00381 inline const UnicodeString &
    00382 DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
    00383     const UnicodeString *strPtr;
    00384     if(symbol < kFormatSymbolCount) {
    00385         strPtr = &fSymbols[symbol];
    00386     } else {
    00387         strPtr = &fNoSymbol;
    00388     }
    00389     return *strPtr;
    00390 }
    00391
    00392 // -------------------------------------
    00393
    00394 inline void
    00395 DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value) {
    00396     if(symbol<kFormatSymbolCount) {
    00397         fSymbols[symbol]=value;
    00398     }
    00399 }
    00400
    00401 // -------------------------------------
    00402
    00403 inline Locale
    00404 DecimalFormatSymbols::getLocale() const {
    00405     return locale;
    00406 }
    00407
    00408 inline const UChar*
    00409 DecimalFormatSymbols::getCurrencyPattern() const {
    00410     return currPattern;
    00411 }
    00412 U_NAMESPACE_END
    00413
    00414 #endif /* #if !UCONFIG_NO_FORMATTING */
    00415
    00416 #endif // _DCFMTSYM
    00417 //eof