• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 *******************************************************************************
3 * Copyright (C) 1997-2014, 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 
18 U_NAMESPACE_BEGIN
19 
20 // currency sign count
21 enum CurrencySignCount {
22     fgCurrencySignCountZero,
23     fgCurrencySignCountInSymbolFormat,
24     fgCurrencySignCountInISOFormat,
25     fgCurrencySignCountInPluralFormat
26 };
27 
28 class DecimalFormatSymbols;
29 
30 struct DecimalFormatPattern : UMemory {
31   enum EPadPosition {
32       kPadBeforePrefix,
33       kPadAfterPrefix,
34       kPadBeforeSuffix,
35       kPadAfterSuffix
36   };
37 
38   DecimalFormatPattern();
39 
40   int32_t fMinimumIntegerDigits;
41   int32_t fMaximumIntegerDigits;
42   int32_t fMinimumFractionDigits;
43   int32_t fMaximumFractionDigits;
44   UBool fUseSignificantDigits;
45   int32_t fMinimumSignificantDigits;
46   int32_t fMaximumSignificantDigits;
47   UBool fUseExponentialNotation;
48   int32_t fMinExponentDigits;
49   UBool fExponentSignAlwaysShown;
50   int32_t fCurrencySignCount;
51   UBool fGroupingUsed;
52   int32_t fGroupingSize;
53   int32_t fGroupingSize2;
54   int32_t fMultiplier;
55   UBool fDecimalSeparatorAlwaysShown;
56   int32_t fFormatWidth;
57   UBool fRoundingIncrementUsed;
58   DigitList fRoundingIncrement;
59   UChar32 fPad;
60   UBool fNegPatternsBogus;
61   UBool fPosPatternsBogus;
62   UnicodeString fNegPrefixPattern;
63   UnicodeString fNegSuffixPattern;
64   UnicodeString fPosPrefixPattern;
65   UnicodeString fPosSuffixPattern;
66   EPadPosition fPadPosition;
67 };
68 
69 class DecimalFormatPatternParser : UMemory {
70   public:
71     DecimalFormatPatternParser();
72     void useSymbols(const DecimalFormatSymbols& symbols);
73 
74     void applyPatternWithoutExpandAffix(
75         const UnicodeString& pattern,
76         DecimalFormatPattern& out,
77         UParseError& parseError,
78         UErrorCode& status);
79   private:
80     DecimalFormatPatternParser(const DecimalFormatPatternParser&);
81     DecimalFormatPatternParser& operator=(DecimalFormatPatternParser& rhs);
82     UChar32 fZeroDigit;
83     UChar32 fSigDigit;
84     UnicodeString fGroupingSeparator;
85     UnicodeString fDecimalSeparator;
86     UnicodeString fPercent;
87     UnicodeString fPerMill;
88     UnicodeString fDigit;
89     UnicodeString fSeparator;
90     UnicodeString fExponent;
91     UnicodeString fPlus;
92     UnicodeString fMinus;
93     UnicodeString fPadEscape;
94 };
95 
96 U_NAMESPACE_END
97 
98 #endif /* !UCONFIG_NO_FORMATTING */
99 #endif
100