| 1 |
. |
| 2 |
|
| 3 |
|
| 4 |
#include "unicode/utypes.h" |
| 5 |
|
| 6 |
#if !UCONFIG_NO_FORMATTING |
| 7 |
#ifndef __NUMBER_FORMATIMPL_H__ |
| 8 |
#define __NUMBER_FORMATIMPL_H__ |
| 9 |
|
| 10 |
#include "number_types.h" |
| 11 |
#include "formatted_string_builder.h" |
| 12 |
#include "number_patternstring.h" |
| 13 |
#include "number_usageprefs.h" |
| 14 |
#include "number_utils.h" |
| 15 |
#include "number_patternmodifier.h" |
| 16 |
#include "number_longnames.h" |
| 17 |
#include "number_compact.h" |
| 18 |
#include "number_microprops.h" |
| 19 |
#include "number_utypes.h" |
| 20 |
|
| 21 |
U_NAMESPACE_BEGIN |
| 22 |
namespace number::impl { |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
class NumberFormatterImpl : public UMemory { |
| 29 |
public: |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
NumberFormatterImpl(const MacroProps ¯os, UErrorCode &status); |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
NumberFormatterImpl(UErrorCode &) {} |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
static int32_t formatStatic(const MacroProps ¯os, UFormattedNumberData *results, |
| 46 |
UErrorCode &status); |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
static int32_t getPrefixSuffixStatic(const MacroProps& macros, Signum signum, |
| 55 |
StandardPlural::Form plural, FormattedStringBuilder& outString, |
| 56 |
UErrorCode& status); |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
int32_t format(UFormattedNumberData *results, UErrorCode &status) const; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
void preProcess(DecimalQuantity& inValue, MicroProps& microsOut, UErrorCode& status) const; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
int32_t getPrefixSuffix(Signum signum, StandardPlural::Form plural, FormattedStringBuilder& outString, |
| 72 |
UErrorCode& status) const; |
| 73 |
|
| 74 |
const MicroProps& getRawMicroProps() const { |
| 75 |
return fMicros; |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
static int32_t writeNumber( |
| 83 |
const SimpleMicroProps& micros, |
| 84 |
DecimalQuantity& quantity, |
| 85 |
FormattedStringBuilder& string, |
| 86 |
int32_t index, |
| 87 |
UErrorCode& status); |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
static int32_t writeAffixes( |
| 93 |
const MicroProps& micros, |
| 94 |
FormattedStringBuilder& string, |
| 95 |
int32_t start, |
| 96 |
int32_t end, |
| 97 |
UErrorCode& status); |
| 98 |
|
| 99 |
private: |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
const MicroPropsGenerator *fMicroPropsGenerator = nullptr; |
| 104 |
|
| 105 |
|
| 106 |
MicroProps fMicros; |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
LocalPointer<const UsagePrefsHandler> fUsagePrefsHandler; |
| 111 |
LocalPointer<const UnitConversionHandler> fUnitConversionHandler; |
| 112 |
LocalPointer<const DecimalFormatSymbols> fSymbols; |
| 113 |
LocalPointer<const PluralRules> fRules; |
| 114 |
LocalPointer<const ParsedPatternInfo> fPatternInfo; |
| 115 |
LocalPointer<const ScientificHandler> fScientificHandler; |
| 116 |
LocalPointer<MutablePatternModifier> fPatternModifier; |
| 117 |
LocalPointer<ImmutablePatternModifier> fImmutablePatternModifier; |
| 118 |
LocalPointer<LongNameHandler> fLongNameHandler; |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
LocalPointer<MixedUnitLongNameHandler> fMixedUnitLongNameHandler; |
| 123 |
LocalPointer<const LongNameMultiplexer> fLongNameMultiplexer; |
| 124 |
LocalPointer<const CompactHandler> fCompactHandler; |
| 125 |
|
| 126 |
NumberFormatterImpl(const MacroProps ¯os, bool safe, UErrorCode &status); |
| 127 |
|
| 128 |
MicroProps& preProcessUnsafe(DecimalQuantity &inValue, UErrorCode &status); |
| 129 |
|
| 130 |
int32_t getPrefixSuffixUnsafe(Signum signum, StandardPlural::Form plural, |
| 131 |
FormattedStringBuilder& outString, UErrorCode& status); |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
const PluralRules * |
| 138 |
resolvePluralRules(const PluralRules *rulesPtr, const Locale &locale, UErrorCode &status); |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
const MicroPropsGenerator * |
| 154 |
macrosToMicroGenerator(const MacroProps ¯os, bool safe, UErrorCode &status); |
| 155 |
|
| 156 |
static int32_t |
| 157 |
writeIntegerDigits( |
| 158 |
const SimpleMicroProps& micros, |
| 159 |
DecimalQuantity &quantity, |
| 160 |
FormattedStringBuilder &string, |
| 161 |
int32_t index, |
| 162 |
UErrorCode &status); |
| 163 |
|
| 164 |
static int32_t |
| 165 |
writeFractionDigits( |
| 166 |
const SimpleMicroProps& micros, |
| 167 |
DecimalQuantity &quantity, |
| 168 |
FormattedStringBuilder &string, |
| 169 |
int32_t index, |
| 170 |
UErrorCode &status); |
| 171 |
}; |
| 172 |
|
| 173 |
} |
| 174 |
U_NAMESPACE_END |
| 175 |
|
| 176 |
|
| 177 |
#endif |
| 178 |
|
| 179 |
#endif |