1 /*
2 *******************************************************************************
3 * Copyright (C) 1997-2015, International Business Machines Corporation and    *
4 * others. All Rights Reserved.                                                *
5 *******************************************************************************
6 */
7 #ifndef _DECIMAL_FORMAT_PATTERN
8 #define _DECIMAL_FORMAT_PATTERN
9 
10 #include "unicode/utypes.h"
11 
12 #if !UCONFIG_NO_FORMATTING
13 
14 #include "unicode/uobject.h"
15 #include "unicode/unistr.h"
16 #include "digitlst.h"
17 #include "affixpatternparser.h"
18 
19 U_NAMESPACE_BEGIN
20 
21 // currency sign count
22 enum CurrencySignCount {
23     fgCurrencySignCountZero,
24     fgCurrencySignCountInSymbolFormat,
25     fgCurrencySignCountInISOFormat,
26     fgCurrencySignCountInPluralFormat
27 };
28 
29 class DecimalFormatSymbols;
30 
31 struct DecimalFormatPattern : UMemory {
32   enum EPadPosition {
33       kPadBeforePrefix,
34       kPadAfterPrefix,
35       kPadBeforeSuffix,
36       kPadAfterSuffix
37   };
38 
39   DecimalFormatPattern();
40 
41   int32_t fMinimumIntegerDigits;
42   int32_t fMaximumIntegerDigits;
43   int32_t fMinimumFractionDigits;
44   int32_t fMaximumFractionDigits;
45   UBool fUseSignificantDigits;
46   int32_t fMinimumSignificantDigits;
47   int32_t fMaximumSignificantDigits;
48   UBool fUseExponentialNotation;
49   int32_t fMinExponentDigits;
50   UBool fExponentSignAlwaysShown;
51   int32_t fCurrencySignCount;
52   UBool fGroupingUsed;
53   int32_t fGroupingSize;
54   int32_t fGroupingSize2;
55   int32_t fMultiplier;
56   UBool fDecimalSeparatorAlwaysShown;
57   int32_t fFormatWidth;
58   UBool fRoundingIncrementUsed;
59   DigitList fRoundingIncrement;
60   UChar32 fPad;
61   UBool fNegPatternsBogus;
62   UBool fPosPatternsBogus;
63   UnicodeString fNegPrefixPattern;
64   UnicodeString fNegSuffixPattern;
65   UnicodeString fPosPrefixPattern;
66   UnicodeString fPosSuffixPattern;
67   AffixPattern fNegPrefixAffix;
68   AffixPattern fNegSuffixAffix;
69   AffixPattern fPosPrefixAffix;
70   AffixPattern fPosSuffixAffix;
71   EPadPosition fPadPosition;
72 };
73 
74 class DecimalFormatPatternParser : UMemory {
75   public:
76     DecimalFormatPatternParser();
77     void useSymbols(const DecimalFormatSymbols& symbols);
78 
79     void applyPatternWithoutExpandAffix(
80         const UnicodeString& pattern,
81         DecimalFormatPattern& out,
82         UParseError& parseError,
83         UErrorCode& status);
84   private:
85     DecimalFormatPatternParser(const DecimalFormatPatternParser&);
86     DecimalFormatPatternParser& operator=(DecimalFormatPatternParser& rhs);
87     UChar32 fZeroDigit;
88     UChar32 fSigDigit;
89     UnicodeString fGroupingSeparator;
90     UnicodeString fDecimalSeparator;
91     UnicodeString fPercent;
92     UnicodeString fPerMill;
93     UnicodeString fDigit;
94     UnicodeString fSeparator;
95     UnicodeString fExponent;
96     UnicodeString fPlus;
97     UnicodeString fMinus;
98     UnicodeString fPadEscape;
99 };
100 
101 U_NAMESPACE_END
102 
103 #endif /* !UCONFIG_NO_FORMATTING */
104 #endif
105