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 |
7 | #ifndef __NUMBER_SCIENTIFIC_H__ |
8 | #define __NUMBER_SCIENTIFIC_H__ |
9 | |
10 | #include "number_types.h" |
11 | |
12 | U_NAMESPACE_BEGIN namespace number { |
13 | namespace impl { |
14 | |
15 | // Forward-declare |
16 | class ScientificHandler; |
17 | |
18 | class U_I18N_API ScientificModifier : public UMemory, public Modifier { |
19 | public: |
20 | ScientificModifier(); |
21 | |
22 | void set(int32_t exponent, const ScientificHandler *handler); |
23 | |
24 | int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, |
25 | UErrorCode &status) const U_OVERRIDE; |
26 | |
27 | int32_t getPrefixLength() const U_OVERRIDE; |
28 | |
29 | int32_t getCodePointCount() const U_OVERRIDE; |
30 | |
31 | bool isStrong() const U_OVERRIDE; |
32 | |
33 | bool containsField(UNumberFormatFields field) const U_OVERRIDE; |
34 | |
35 | void getParameters(Parameters& output) const U_OVERRIDE; |
36 | |
37 | bool semanticallyEquivalent(const Modifier& other) const U_OVERRIDE; |
38 | |
39 | private: |
40 | int32_t fExponent; |
41 | const ScientificHandler *fHandler; |
42 | }; |
43 | |
44 | class ScientificHandler : public UMemory, public MicroPropsGenerator, public MultiplierProducer { |
45 | public: |
46 | ScientificHandler(const Notation *notation, const DecimalFormatSymbols *symbols, |
47 | const MicroPropsGenerator *parent); |
48 | |
49 | void |
50 | processQuantity(DecimalQuantity &quantity, MicroProps µs, UErrorCode &status) const U_OVERRIDE; |
51 | |
52 | int32_t getMultiplier(int32_t magnitude) const U_OVERRIDE; |
53 | |
54 | private: |
55 | const Notation::ScientificSettings& fSettings; |
56 | const DecimalFormatSymbols *fSymbols; |
57 | const MicroPropsGenerator *fParent; |
58 | |
59 | friend class ScientificModifier; |
60 | }; |
61 | |
62 | } // namespace impl |
63 | } // namespace number |
64 | U_NAMESPACE_END |
65 | |
66 | #endif //__NUMBER_SCIENTIFIC_H__ |
67 | |
68 | #endif /* #if !UCONFIG_NO_FORMATTING */ |
69 | |