/src/icu/source/i18n/numrange_impl.h
Line | Count | Source (jump to first uncovered line) |
1 | | // © 2018 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 __SOURCE_NUMRANGE_TYPES_H__ |
8 | | #define __SOURCE_NUMRANGE_TYPES_H__ |
9 | | |
10 | | #include "unicode/numberformatter.h" |
11 | | #include "unicode/numberrangeformatter.h" |
12 | | #include "unicode/simpleformatter.h" |
13 | | #include "number_types.h" |
14 | | #include "number_decimalquantity.h" |
15 | | #include "number_formatimpl.h" |
16 | | #include "formatted_string_builder.h" |
17 | | #include "formattedval_impl.h" |
18 | | #include "pluralranges.h" |
19 | | |
20 | | U_NAMESPACE_BEGIN namespace number { |
21 | | namespace impl { |
22 | | |
23 | | |
24 | | /** |
25 | | * Class similar to UFormattedNumberData. |
26 | | * |
27 | | * Has incomplete magic number logic that will need to be finished |
28 | | * if this is to be exposed as C API in the future. |
29 | | * |
30 | | * Possible magic number: 0x46445200 |
31 | | * Reads in ASCII as "FDR" (FormatteDnumberRange with room at the end) |
32 | | */ |
33 | | class UFormattedNumberRangeData : public FormattedValueStringBuilderImpl { |
34 | | public: |
35 | 0 | UFormattedNumberRangeData() : FormattedValueStringBuilderImpl(kUndefinedField) {} |
36 | | virtual ~UFormattedNumberRangeData(); |
37 | | |
38 | | DecimalQuantity quantity1; |
39 | | DecimalQuantity quantity2; |
40 | | UNumberRangeIdentityResult identityResult = UNUM_IDENTITY_RESULT_COUNT; |
41 | | }; |
42 | | |
43 | | |
44 | | class NumberRangeFormatterImpl : public UMemory { |
45 | | public: |
46 | | NumberRangeFormatterImpl(const RangeMacroProps& macros, UErrorCode& status); |
47 | | |
48 | | void format(UFormattedNumberRangeData& data, bool equalBeforeRounding, UErrorCode& status) const; |
49 | | |
50 | | private: |
51 | | NumberFormatterImpl formatterImpl1; |
52 | | NumberFormatterImpl formatterImpl2; |
53 | | bool fSameFormatters; |
54 | | |
55 | | UNumberRangeCollapse fCollapse; |
56 | | UNumberRangeIdentityFallback fIdentityFallback; |
57 | | |
58 | | SimpleFormatter fRangeFormatter; |
59 | | NumberFormatterImpl fApproximatelyFormatter; |
60 | | |
61 | | StandardPluralRanges fPluralRanges; |
62 | | |
63 | | void formatSingleValue(UFormattedNumberRangeData& data, |
64 | | MicroProps& micros1, MicroProps& micros2, |
65 | | UErrorCode& status) const; |
66 | | |
67 | | void formatApproximately(UFormattedNumberRangeData& data, |
68 | | MicroProps& micros1, MicroProps& micros2, |
69 | | UErrorCode& status) const; |
70 | | |
71 | | void formatRange(UFormattedNumberRangeData& data, |
72 | | MicroProps& micros1, MicroProps& micros2, |
73 | | UErrorCode& status) const; |
74 | | |
75 | | const Modifier& resolveModifierPlurals(const Modifier& first, const Modifier& second) const; |
76 | | }; |
77 | | |
78 | | |
79 | | /** Helper function used in upluralrules.cpp */ |
80 | | const UFormattedNumberRangeData* validateUFormattedNumberRange( |
81 | | const UFormattedNumberRange* uresult, UErrorCode& status); |
82 | | |
83 | | |
84 | | } // namespace impl |
85 | | } // namespace number |
86 | | U_NAMESPACE_END |
87 | | |
88 | | #endif //__SOURCE_NUMRANGE_TYPES_H__ |
89 | | #endif /* #if !UCONFIG_NO_FORMATTING */ |