OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * Copyright (C) 1997-2014, International Business Machines Corporation and * | 3 * Copyright (C) 1997-2015, International Business Machines Corporation and * |
4 * others. All Rights Reserved. * | 4 * others. All Rights Reserved. * |
5 ******************************************************************************* | 5 ******************************************************************************* |
6 */ | 6 */ |
7 | 7 |
8 #include "uassert.h" | 8 #include "uassert.h" |
9 #include "decimalformatpattern.h" | 9 #include "decimalformatpattern.h" |
10 | 10 |
11 #if !UCONFIG_NO_FORMATTING | 11 #if !UCONFIG_NO_FORMATTING |
12 | 12 |
13 #include "unicode/dcfmtsym.h" | 13 #include "unicode/dcfmtsym.h" |
14 #include "unicode/format.h" | 14 #include "unicode/format.h" |
15 #include "unicode/utf16.h" | 15 #include "unicode/utf16.h" |
| 16 #include "decimalformatpatternimpl.h" |
| 17 |
16 | 18 |
17 #ifdef FMT_DEBUG | 19 #ifdef FMT_DEBUG |
18 #define debug(x) printf("%s:%d: %s\n", __FILE__,__LINE__, x); | 20 #define debug(x) printf("%s:%d: %s\n", __FILE__,__LINE__, x); |
19 #else | 21 #else |
20 #define debug(x) | 22 #define debug(x) |
21 #endif | 23 #endif |
22 | 24 |
23 #define kPatternZeroDigit ((UChar)0x0030) /*'0'*/ | |
24 #define kPatternSignificantDigit ((UChar)0x0040) /*'@'*/ | |
25 #define kPatternGroupingSeparator ((UChar)0x002C) /*','*/ | |
26 #define kPatternDecimalSeparator ((UChar)0x002E) /*'.'*/ | |
27 #define kPatternPerMill ((UChar)0x2030) | |
28 #define kPatternPercent ((UChar)0x0025) /*'%'*/ | |
29 #define kPatternDigit ((UChar)0x0023) /*'#'*/ | |
30 #define kPatternSeparator ((UChar)0x003B) /*';'*/ | |
31 #define kPatternExponent ((UChar)0x0045) /*'E'*/ | |
32 #define kPatternPlus ((UChar)0x002B) /*'+'*/ | |
33 #define kPatternMinus ((UChar)0x002D) /*'-'*/ | |
34 #define kPatternPadEscape ((UChar)0x002A) /*'*'*/ | |
35 #define kQuote ((UChar)0x0027) /*'\''*/ | |
36 | |
37 #define kCurrencySign ((UChar)0x00A4) | |
38 #define kDefaultPad ((UChar)0x0020) /* */ | |
39 | |
40 U_NAMESPACE_BEGIN | 25 U_NAMESPACE_BEGIN |
41 | 26 |
42 // TODO: Travis Keep: Copied from numfmt.cpp | 27 // TODO: Travis Keep: Copied from numfmt.cpp |
43 static int32_t kDoubleIntegerDigits = 309; | 28 static int32_t kDoubleIntegerDigits = 309; |
44 static int32_t kDoubleFractionDigits = 340; | 29 static int32_t kDoubleFractionDigits = 340; |
45 | 30 |
46 | 31 |
47 // TODO: Travis Keep: Copied from numfmt.cpp | 32 // TODO: Travis Keep: Copied from numfmt.cpp |
48 static int32_t gDefaultMaxIntegerDigits = 2000000000; | 33 static int32_t gDefaultMaxIntegerDigits = 2000000000; |
49 | 34 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 fExponentSignAlwaysShown(FALSE), | 69 fExponentSignAlwaysShown(FALSE), |
85 fCurrencySignCount(fgCurrencySignCountZero), | 70 fCurrencySignCount(fgCurrencySignCountZero), |
86 fGroupingUsed(TRUE), | 71 fGroupingUsed(TRUE), |
87 fGroupingSize(0), | 72 fGroupingSize(0), |
88 fGroupingSize2(0), | 73 fGroupingSize2(0), |
89 fMultiplier(1), | 74 fMultiplier(1), |
90 fDecimalSeparatorAlwaysShown(FALSE), | 75 fDecimalSeparatorAlwaysShown(FALSE), |
91 fFormatWidth(0), | 76 fFormatWidth(0), |
92 fRoundingIncrementUsed(FALSE), | 77 fRoundingIncrementUsed(FALSE), |
93 fRoundingIncrement(), | 78 fRoundingIncrement(), |
94 fPad(kPatternPadEscape), | 79 fPad(kDefaultPad), |
95 fNegPatternsBogus(TRUE), | 80 fNegPatternsBogus(TRUE), |
96 fPosPatternsBogus(TRUE), | 81 fPosPatternsBogus(TRUE), |
97 fNegPrefixPattern(), | 82 fNegPrefixPattern(), |
98 fNegSuffixPattern(), | 83 fNegSuffixPattern(), |
99 fPosPrefixPattern(), | 84 fPosPrefixPattern(), |
100 fPosSuffixPattern(), | 85 fPosSuffixPattern(), |
101 fPadPosition(DecimalFormatPattern::kPadBeforePrefix) { | 86 fPadPosition(DecimalFormatPattern::kPadBeforePrefix) { |
102 } | 87 } |
103 | 88 |
104 | 89 |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 // positive pattern to form the negative pattern. | 629 // positive pattern to form the negative pattern. |
645 if (out.fNegPatternsBogus || | 630 if (out.fNegPatternsBogus || |
646 (out.fNegPrefixPattern == out.fPosPrefixPattern | 631 (out.fNegPrefixPattern == out.fPosPrefixPattern |
647 && out.fNegSuffixPattern == out.fPosSuffixPattern)) { | 632 && out.fNegSuffixPattern == out.fPosSuffixPattern)) { |
648 out.fNegPatternsBogus = FALSE; | 633 out.fNegPatternsBogus = FALSE; |
649 out.fNegSuffixPattern = out.fPosSuffixPattern; | 634 out.fNegSuffixPattern = out.fPosSuffixPattern; |
650 out.fNegPrefixPattern.remove(); | 635 out.fNegPrefixPattern.remove(); |
651 out.fNegPrefixPattern.append(kQuote).append(kPatternMinus) | 636 out.fNegPrefixPattern.append(kQuote).append(kPatternMinus) |
652 .append(out.fPosPrefixPattern); | 637 .append(out.fPosPrefixPattern); |
653 } | 638 } |
| 639 // TODO: Deprecate/Remove out.fNegSuffixPattern and 3 other fields. |
| 640 AffixPattern::parseAffixString( |
| 641 out.fNegSuffixPattern, out.fNegSuffixAffix, status); |
| 642 AffixPattern::parseAffixString( |
| 643 out.fPosSuffixPattern, out.fPosSuffixAffix, status); |
| 644 AffixPattern::parseAffixString( |
| 645 out.fNegPrefixPattern, out.fNegPrefixAffix, status); |
| 646 AffixPattern::parseAffixString( |
| 647 out.fPosPrefixPattern, out.fPosPrefixAffix, status); |
654 } | 648 } |
655 | 649 |
656 U_NAMESPACE_END | 650 U_NAMESPACE_END |
657 | 651 |
658 #endif /* !UCONFIG_NO_FORMATTING */ | 652 #endif /* !UCONFIG_NO_FORMATTING */ |
OLD | NEW |