summaryrefslogtreecommitdiffstats
path: root/intl/icu/source/i18n/decimalformatpattern.h
blob: c8998f95f8f67cb91f08029f9230613a56cbf242 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 1997-2015, International Business Machines Corporation and    *
* others. All Rights Reserved.                                                *
*******************************************************************************
*/
#ifndef _DECIMAL_FORMAT_PATTERN
#define _DECIMAL_FORMAT_PATTERN

#include "unicode/utypes.h"

#if !UCONFIG_NO_FORMATTING

#include "unicode/uobject.h"
#include "unicode/unistr.h"
#include "digitlst.h"
#include "affixpatternparser.h"

U_NAMESPACE_BEGIN

// currency sign count
enum CurrencySignCount {
    fgCurrencySignCountZero,
    fgCurrencySignCountInSymbolFormat,
    fgCurrencySignCountInISOFormat,
    fgCurrencySignCountInPluralFormat
};

class DecimalFormatSymbols;

struct DecimalFormatPattern : public UMemory {
  enum EPadPosition {
      kPadBeforePrefix,
      kPadAfterPrefix,
      kPadBeforeSuffix,
      kPadAfterSuffix
  };

  DecimalFormatPattern();

  int32_t fMinimumIntegerDigits;
  int32_t fMaximumIntegerDigits;
  int32_t fMinimumFractionDigits;
  int32_t fMaximumFractionDigits;
  UBool fUseSignificantDigits;
  int32_t fMinimumSignificantDigits;
  int32_t fMaximumSignificantDigits;
  UBool fUseExponentialNotation;
  int32_t fMinExponentDigits;
  UBool fExponentSignAlwaysShown;
  int32_t fCurrencySignCount;
  UBool fGroupingUsed;
  int32_t fGroupingSize;
  int32_t fGroupingSize2;
  int32_t fMultiplier;
  UBool fDecimalSeparatorAlwaysShown;
  int32_t fFormatWidth;
  UBool fRoundingIncrementUsed;
  DigitList fRoundingIncrement;
  UChar32 fPad;
  UBool fNegPatternsBogus;
  UBool fPosPatternsBogus;
  UnicodeString fNegPrefixPattern;
  UnicodeString fNegSuffixPattern;
  UnicodeString fPosPrefixPattern;
  UnicodeString fPosSuffixPattern;
  AffixPattern fNegPrefixAffix; 
  AffixPattern fNegSuffixAffix; 
  AffixPattern fPosPrefixAffix; 
  AffixPattern fPosSuffixAffix; 
  EPadPosition fPadPosition;
};

class DecimalFormatPatternParser : public UMemory {
  public:
    DecimalFormatPatternParser();
    void useSymbols(const DecimalFormatSymbols& symbols);

    void applyPatternWithoutExpandAffix(
        const UnicodeString& pattern,
        DecimalFormatPattern& out,
        UParseError& parseError,
        UErrorCode& status);
  private:
    DecimalFormatPatternParser(const DecimalFormatPatternParser&);
    DecimalFormatPatternParser& operator=(DecimalFormatPatternParser& rhs);
    UChar32 fZeroDigit;
    UChar32 fSigDigit;
    UnicodeString fGroupingSeparator;
    UnicodeString fDecimalSeparator;
    UnicodeString fPercent;
    UnicodeString fPerMill;
    UnicodeString fDigit;
    UnicodeString fSeparator;
    UnicodeString fExponent;
    UnicodeString fPlus;
    UnicodeString fMinus;
    UnicodeString fPadEscape;
};

U_NAMESPACE_END

#endif /* !UCONFIG_NO_FORMATTING */
#endif