00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#ifndef DCFMTSYM_H
00026
#define DCFMTSYM_H
00027
00028
#include "unicode/utypes.h"
00029
#include "unicode/locid.h"
00030
00031 U_NAMESPACE_BEGIN
00032
00072 class U_I18N_API DecimalFormatSymbols {
00073
public:
00078 enum ENumberFormatSymbol {
00080 kDecimalSeparatorSymbol,
00082 kGroupingSeparatorSymbol,
00084 kPatternSeparatorSymbol,
00086 kPercentSymbol,
00088 kZeroDigitSymbol,
00090 kDigitSymbol,
00092 kMinusSignSymbol,
00094 kPlusSignSymbol,
00096 kCurrencySymbol,
00098 kIntlCurrencySymbol,
00100 kMonetarySeparatorSymbol,
00102 kExponentialSymbol,
00104 kPerMillSymbol,
00106 kPadEscapeSymbol,
00108 kInfinitySymbol,
00110 kNaNSymbol,
00112 kFormatSymbolCount
00113 };
00114
00123 DecimalFormatSymbols(
const Locale& locale, UErrorCode& status);
00124
00135 DecimalFormatSymbols( UErrorCode& status);
00136
00141 DecimalFormatSymbols(
const DecimalFormatSymbols&);
00142
00147 DecimalFormatSymbols& operator=(
const DecimalFormatSymbols&);
00148
00153 ~DecimalFormatSymbols();
00154
00159 UBool operator==(
const DecimalFormatSymbols& other)
const;
00160
00165 UBool operator!=(
const DecimalFormatSymbols& other)
const {
return !operator==(other); }
00166
00173
UnicodeString getSymbol(ENumberFormatSymbol symbol)
const;
00174
00181
void setSymbol(ENumberFormatSymbol symbol,
UnicodeString value);
00182
00183
#ifdef ICU_DECIMALFORMATSYMBOLS_USE_DEPRECATES
00184
00190
UChar getZeroDigit(
void) const;
00197
void setZeroDigit(UChar zeroDigit);
00198
00205 UChar getGroupingSeparator(
void) const;
00212
void setGroupingSeparator(UChar groupingSeparator);
00213
00220 UChar getDecimalSeparator(
void) const;
00227
void setDecimalSeparator(UChar decimalSeparator);
00228
00235 UChar getPerMill(
void) const;
00242
void setPerMill(UChar permill);
00243
00250 UChar getPercent(
void) const;
00257
void setPercent(UChar percent);
00258
00265 UChar getDigit(
void) const;
00272
void setDigit(UChar digit);
00273
00281 UChar getPatternSeparator(
void) const;
00289
void setPatternSeparator(UChar patternSeparator);
00290
00296
UnicodeString& getInfinity(
UnicodeString& result) const;
00302
void setInfinity(const
UnicodeString& infinity);
00309 int32_t compareInfinity(const
UnicodeString& text, int32_t offset) const;
00310
00316
UnicodeString& getNaN(
UnicodeString& result) const;
00322
void setNaN(const
UnicodeString& NaN);
00329 int32_t compareNaN(const
UnicodeString& text, int32_t offset) const;
00330
00337 UChar getPlusSign(
void) const;
00344
void setPlusSign(UChar minusSign);
00345
00354 UChar getMinusSign(
void) const;
00363
void setMinusSign(UChar minusSign);
00364
00372 UChar getExponentialSymbol(
void) const;
00380
void setExponentialSymbol(UChar exponential);
00381
00386
UnicodeString& getCurrencySymbol(
UnicodeString& result) const;
00391
void setCurrencySymbol(const
UnicodeString& currency);
00399 int32_t compareCurrencySymbol(const
UnicodeString& text, int32_t offset) const;
00400
00405
UnicodeString& getInternationalCurrencySymbol(
UnicodeString& result) const;
00410
void setInternationalCurrencySymbol(const
UnicodeString& currency);
00419 int32_t compareInternationalCurrencySymbol(const
UnicodeString& text, int32_t offset) const;
00420
00427 UChar getMonetaryDecimalSeparator(
void) const;
00434
void setMonetaryDecimalSeparator(UChar sep);
00435
00450 UChar getPadEscape(
void) const;
00451
00465
void setPadEscape(UChar c);
00466 #endif
00467 private:
00473
void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
00474
00479
void initialize(const
UnicodeString* numberElements, const
UnicodeString* currencyElements);
00480
00484
void initialize();
00485
00486
UnicodeString fSymbols[kFormatSymbolCount];
00487
00488 static const
char fgNumberElements[];
00489 static const
char fgCurrencyElements[];
00490 };
00491
00492
00493
00494
00495 inline
UnicodeString
00496 DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol)
const {
00497
if(symbol<kFormatSymbolCount) {
00498
return fSymbols[symbol];
00499 }
else {
00500
return UnicodeString();
00501 }
00502 }
00503
00504
00505
00506
00507
inline void
00508 DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol,
UnicodeString value) {
00509
if(symbol<
kFormatSymbolCount) {
00510 fSymbols[symbol]=value;
00511 }
00512 }
00513
00514
#ifdef ICU_DECIMALFORMATSYMBOLS_USE_DEPRECATES
00515
00516
00517
inline UChar
00518 DecimalFormatSymbols::getZeroDigit()
const
00519
{
00520
return fSymbols[kZeroDigitSymbol].
charAt(0);
00521 }
00522
00523
00524
00525
inline void
00526 DecimalFormatSymbols::setZeroDigit(UChar zeroDigit)
00527 {
00528 fSymbols[
kZeroDigitSymbol] = zeroDigit;
00529 }
00530
00531
00532
00533
inline UChar
00534 DecimalFormatSymbols::getGroupingSeparator()
const
00535
{
00536
return fSymbols[
kGroupingSeparatorSymbol].
charAt(0);
00537 }
00538
00539
00540
00541
inline void
00542 DecimalFormatSymbols::setGroupingSeparator(UChar groupingSeparator)
00543 {
00544 fSymbols[
kGroupingSeparatorSymbol] = groupingSeparator;
00545 }
00546
00547
00548
00549
inline UChar
00550 DecimalFormatSymbols::getDecimalSeparator()
const
00551
{
00552
return fSymbols[
kDecimalSeparatorSymbol].
charAt(0);
00553 }
00554
00555
00556
00557
inline void
00558 DecimalFormatSymbols::setDecimalSeparator(UChar decimalSeparator)
00559 {
00560 fSymbols[
kDecimalSeparatorSymbol] = decimalSeparator;
00561 }
00562
00563
00564
00565
inline UChar
00566 DecimalFormatSymbols::getPerMill()
const
00567
{
00568
return fSymbols[kPermillSymbol].
charAt(0);
00569 }
00570
00571
00572
00573
inline void
00574 DecimalFormatSymbols::setPerMill(UChar permill)
00575 {
00576 fSymbols[kPermillSymbol] = permill;
00577 }
00578
00579
00580
00581
inline UChar
00582 DecimalFormatSymbols::getPercent()
const
00583
{
00584
return fSymbols[
kPercentSymbol].
charAt(0);
00585 }
00586
00587
00588
00589
inline void
00590 DecimalFormatSymbols::setPercent(UChar percent)
00591 {
00592 fSymbols[
kPercentSymbol] = percent;
00593 }
00594
00595
00596
00597
inline UChar
00598 DecimalFormatSymbols::getDigit()
const
00599
{
00600
return fSymbols[
kDigitSymbol].
charAt(0);
00601 }
00602
00603
00604
00605
inline void
00606 DecimalFormatSymbols::setDigit(UChar digit)
00607 {
00608 fSymbols[
kDigitSymbol] = digit;
00609 }
00610
00611
00612
00613
inline UChar
00614 DecimalFormatSymbols::getPatternSeparator()
const
00615
{
00616
return fSymbols[
kPatternSeparatorSymbol].
charAt(0);
00617 }
00618
00619
00620
00621
inline void
00622 DecimalFormatSymbols::setPatternSeparator(UChar patternSeparator)
00623 {
00624 fSymbols[
kPatternSeparatorSymbol] = patternSeparator;
00625 }
00626
00627
00628
00629
inline UnicodeString&
00630 DecimalFormatSymbols::getInfinity(
UnicodeString& result)
const
00631
{
00632
return result = fSymbols[
kInfinitySymbol];
00633 }
00634
00635
00636
00637
inline void
00638 DecimalFormatSymbols::setInfinity(
const UnicodeString& infinity)
00639 {
00640 fSymbols[
kInfinitySymbol] = infinity;
00641 }
00642
00643
00644
00645
inline int32_t
00646 DecimalFormatSymbols::compareInfinity(
const UnicodeString& text,
00647 int32_t offset)
const
00648
{
00649 int32_t symbolLength = fSymbols[
kInfinitySymbol].
length();
00650
return text.
compare(offset,
00651 symbolLength,
00652 fSymbols[kInfinitySymbol],
00653 0,
00654 symbolLength)
00655 ? 0 : symbolLength;
00656 }
00657
00658
00659
00660
inline UnicodeString&
00661 DecimalFormatSymbols::getNaN(
UnicodeString& result)
const
00662
{
00663
return result = fSymbols[
kNaNSymbol];
00664 }
00665
00666
00667
00668
inline void
00669 DecimalFormatSymbols::setNaN(
const UnicodeString& NaN)
00670 {
00671 fSymbols[
kNaNSymbol] = NaN;
00672 }
00673
00674
00675
00676
inline int32_t
00677 DecimalFormatSymbols::compareNaN(
const UnicodeString& text, int32_t offset)
const
00678
{
00679 int32_t symbolLength = fSymbols[
kNaNSymbol].
length();
00680
return text.
compare(offset,
00681 symbolLength,
00682 fSymbols[kNaNSymbol],
00683 0,
00684 symbolLength)
00685 ? 0 : symbolLength;
00686 }
00687
00688
00689
00690
inline UChar
00691 DecimalFormatSymbols::getPlusSign()
const
00692
{
00693
return fSymbols[
kPlusSignSymbol].
charAt(0);
00694 }
00695
00696
00697
00698
inline void
00699 DecimalFormatSymbols::setPlusSign(UChar plusSign)
00700 {
00701 fSymbols[
kPlusSignSymbol] = plusSign;
00702 }
00703
00704
00705
00706
inline UChar
00707 DecimalFormatSymbols::getMinusSign()
const
00708
{
00709
return fSymbols[
kMinusSignSymbol].
charAt(0);
00710 }
00711
00712
00713
00714
inline void
00715 DecimalFormatSymbols::setMinusSign(UChar minusSign)
00716 {
00717 fSymbols[
kMinusSignSymbol] = minusSign;
00718 }
00719
00720
00721
00722
inline UChar
00723 DecimalFormatSymbols::getExponentialSymbol(
void)
const
00724
{
00725
return fSymbols[
kExponentialSymbol].
charAt(0);
00726 }
00727
00728
00729
00730
inline void
00731 DecimalFormatSymbols::setExponentialSymbol(UChar exponential)
00732 {
00733 fSymbols[
kExponentialSymbol] = exponential;
00734 }
00735
00736
00737
00738
inline UnicodeString&
00739 DecimalFormatSymbols::getCurrencySymbol(
UnicodeString& result)
const
00740
{
00741
return result = fSymbols[
kCurrencySymbol];
00742 }
00743
00744
00745
00746
inline void
00747 DecimalFormatSymbols::setCurrencySymbol(
const UnicodeString& str)
00748 {
00749 fSymbols[
kCurrencySymbol] = str;
00750 }
00751
00752
00753
00754
inline int32_t
00755 DecimalFormatSymbols::compareCurrencySymbol(
const UnicodeString& text,
00756 int32_t offset)
const
00757
{
00758 int32_t symbolLength = fSymbols[
kCurrencySymbol].
length();
00759
return text.
compare(offset,
00760 symbolLength,
00761 fSymbols[kCurrencySymbol],
00762 0,
00763 symbolLength)
00764 ? 0 : symbolLength;
00765 }
00766
00767
00768
00769
inline UnicodeString&
00770 DecimalFormatSymbols::getInternationalCurrencySymbol(
UnicodeString& result)
const
00771
{
00772
return result = fSymbols[
kIntlCurrencySymbol];
00773 }
00774
00775
00776
00777
inline void
00778 DecimalFormatSymbols::setInternationalCurrencySymbol(
const UnicodeString& str)
00779 {
00780 fSymbols[
kIntlCurrencySymbol] = str;
00781 }
00782
00783
00784
00785
inline int32_t
00786 DecimalFormatSymbols::compareInternationalCurrencySymbol(
const UnicodeString& text,
00787 int32_t offset)
const
00788
{
00789 int32_t symbolLength = fSymbols[
kIntlCurrencySymbol].
length();
00790
return text.
compare(offset,
00791 symbolLength,
00792 fSymbols[kIntlCurrencySymbol],
00793 0,
00794 symbolLength)
00795 ? 0 : symbolLength;
00796 }
00797
00798
00799
00800
inline UChar
00801 DecimalFormatSymbols::getMonetaryDecimalSeparator(
void)
const
00802
{
00803
return fSymbols[
kMonetarySeparatorSymbol].
charAt(0);
00804 }
00805
00806
00807
00808
inline void
00809 DecimalFormatSymbols::setMonetaryDecimalSeparator(UChar sep)
00810 {
00811 fSymbols[
kMonetarySeparatorSymbol] = sep;
00812 }
00813
00814
inline UChar DecimalFormatSymbols::getPadEscape(
void)
const {
00815
return fSymbols[
kPadEscapeSymbol].
charAt(0);
00816 }
00817
00818
inline void DecimalFormatSymbols::setPadEscape(UChar c) {
00819 fSymbols[
kPadEscapeSymbol] = c;
00820 }
00821
#endif
00822
00823 U_NAMESPACE_END
00824
00825
#endif // _DCFMTSYM
00826