Home | History | Annotate | Download | only in i18n
      1 //  2017 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html
      3 
      4 #include "unicode/utypes.h"
      5 
      6 #if !UCONFIG_NO_FORMATTING && !UPRV_INCOMPLETE_CPP11_SUPPORT
      7 #ifndef __NUMBER_DECIMFMTPROPS_H__
      8 #define __NUMBER_DECIMFMTPROPS_H__
      9 
     10 #include "unicode/unistr.h"
     11 #include <cstdint>
     12 #include "unicode/plurrule.h"
     13 #include "unicode/currpinf.h"
     14 #include "unicode/unum.h"
     15 #include "unicode/localpointer.h"
     16 #include "number_types.h"
     17 
     18 U_NAMESPACE_BEGIN
     19 
     20 // Export an explicit template instantiation of the LocalPointer that is used as a
     21 // data member of CurrencyPluralInfoWrapper.
     22 // (MSVC requires this, even though it should not be necessary.)
     23 #if defined (_MSC_VER)
     24 // Ignore warning 4661 as LocalPointerBase does not use operator== or operator!=
     25 #pragma warning(suppress: 4661)
     26 template class U_I18N_API LocalPointerBase<CurrencyPluralInfo>;
     27 template class U_I18N_API LocalPointer<CurrencyPluralInfo>;
     28 #endif
     29 
     30 namespace number {
     31 namespace impl {
     32 
     33 // TODO: Figure out a nicer way to deal with CurrencyPluralInfo.
     34 // Exported as U_I18N_API because it is a public member field of exported DecimalFormatProperties
     35 struct U_I18N_API CurrencyPluralInfoWrapper {
     36     LocalPointer<CurrencyPluralInfo> fPtr;
     37 
     38     CurrencyPluralInfoWrapper() {}
     39     CurrencyPluralInfoWrapper(const CurrencyPluralInfoWrapper& other) {
     40         if (!other.fPtr.isNull()) {
     41             fPtr.adoptInstead(new CurrencyPluralInfo(*other.fPtr));
     42         }
     43     }
     44 };
     45 
     46 // Exported as U_I18N_API because it is needed for the unit test PatternStringTest
     47 struct U_I18N_API DecimalFormatProperties {
     48 
     49   public:
     50     NullableValue<UNumberCompactStyle> compactStyle;
     51     NullableValue<CurrencyUnit> currency;
     52     CurrencyPluralInfoWrapper currencyPluralInfo;
     53     NullableValue<UCurrencyUsage> currencyUsage;
     54     bool decimalPatternMatchRequired;
     55     bool decimalSeparatorAlwaysShown;
     56     bool exponentSignAlwaysShown;
     57     int32_t formatWidth;
     58     int32_t groupingSize;
     59     int32_t magnitudeMultiplier;
     60     int32_t maximumFractionDigits;
     61     int32_t maximumIntegerDigits;
     62     int32_t maximumSignificantDigits;
     63     int32_t minimumExponentDigits;
     64     int32_t minimumFractionDigits;
     65     int32_t minimumGroupingDigits;
     66     int32_t minimumIntegerDigits;
     67     int32_t minimumSignificantDigits;
     68     int32_t multiplier;
     69     UnicodeString negativePrefix;
     70     UnicodeString negativePrefixPattern;
     71     UnicodeString negativeSuffix;
     72     UnicodeString negativeSuffixPattern;
     73     NullableValue<PadPosition> padPosition;
     74     UnicodeString padString;
     75     bool parseCaseSensitive;
     76     bool parseIntegerOnly;
     77     bool parseLenient;
     78     bool parseNoExponent;
     79     bool parseToBigDecimal;
     80     //PluralRules pluralRules;
     81     UnicodeString positivePrefix;
     82     UnicodeString positivePrefixPattern;
     83     UnicodeString positiveSuffix;
     84     UnicodeString positiveSuffixPattern;
     85     double roundingIncrement;
     86     NullableValue<RoundingMode> roundingMode;
     87     int32_t secondaryGroupingSize;
     88     bool signAlwaysShown;
     89 
     90     DecimalFormatProperties();
     91 
     92     //DecimalFormatProperties(const DecimalFormatProperties &other) = default;
     93 
     94     DecimalFormatProperties &operator=(const DecimalFormatProperties &other) = default;
     95 
     96     bool operator==(const DecimalFormatProperties &other) const;
     97 
     98     void clear();
     99 };
    100 
    101 } // namespace impl
    102 } // namespace number
    103 U_NAMESPACE_END
    104 
    105 
    106 #endif //__NUMBER_DECIMFMTPROPS_H__
    107 
    108 #endif /* #if !UCONFIG_NO_FORMATTING */
    109