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