* Builds a "safe" MicroPropsGenerator, which is thread-safe and can be used repeatedly.
* The caller owns the returned NumberFormatterImpl.
*/
- static NumberFormatterImpl *fromMacros(const MacroProps ¯os, UErrorCode &status);
+ NumberFormatterImpl(const MacroProps ¯os, UErrorCode &status);
/**
* Builds and evaluates an "unsafe" MicroPropsGenerator, which is cheaper but can be used only once.
*/
- static void
- applyStatic(const MacroProps ¯os, DecimalQuantity &inValue, NumberStringBuilder &outString,
- UErrorCode &status);
+ static int32_t
+ formatStatic(const MacroProps ¯os, DecimalQuantity &inValue, NumberStringBuilder &outString,
+ UErrorCode &status);
/**
* Prints only the prefix and suffix; used for DecimalFormat getters.
/**
* Evaluates the "safe" MicroPropsGenerator created by "fromMacros".
*/
- void apply(DecimalQuantity& inValue, NumberStringBuilder& outString, UErrorCode& status) const;
+ int32_t format(DecimalQuantity& inValue, NumberStringBuilder& outString, UErrorCode& status) const;
+
+ /**
+ * Like format(), but saves the result into an output MicroProps without additional processing.
+ */
+ void preProcess(DecimalQuantity& inValue, MicroProps& microsOut, UErrorCode& status) const;
/**
* Like getPrefixSuffixStatic() but uses the safe compiled object.
int32_t getPrefixSuffix(int8_t signum, StandardPlural::Form plural, NumberStringBuilder& outString,
UErrorCode& status) const;
+ const MicroProps& getRawMicroProps() const {
+ return fMicros;
+ }
+
+ /**
+ * Synthesizes the output string from a MicroProps and DecimalQuantity.
+ * This method formats only the main number, not affixes.
+ */
+ static int32_t writeNumber(const MicroProps& micros, DecimalQuantity& quantity,
+ NumberStringBuilder& string, int32_t index, UErrorCode& status);
+
+ /**
+ * Adds the affixes. Intended to be called immediately after formatNumber.
+ */
+ static int32_t writeAffixes(const MicroProps& micros, NumberStringBuilder& string, int32_t start,
+ int32_t end, UErrorCode& status);
+
private:
// Head of the MicroPropsGenerator linked list:
const MicroPropsGenerator *fMicroPropsGenerator = nullptr;
NumberFormatterImpl(const MacroProps ¯os, bool safe, UErrorCode &status);
- void applyUnsafe(DecimalQuantity &inValue, NumberStringBuilder &outString, UErrorCode &status);
+ MicroProps& preProcessUnsafe(DecimalQuantity &inValue, UErrorCode &status);
int32_t getPrefixSuffixUnsafe(int8_t signum, StandardPlural::Form plural,
NumberStringBuilder& outString, UErrorCode& status);
const MicroPropsGenerator *
macrosToMicroGenerator(const MacroProps ¯os, bool safe, UErrorCode &status);
- /**
- * Synthesizes the output string from a MicroProps and DecimalQuantity.
- *
- * @param micros
- * The MicroProps after the quantity has been consumed. Will not be mutated.
- * @param quantity
- * The DecimalQuantity to be rendered. May be mutated.
- * @param string
- * The output string. Will be mutated.
- */
- static int32_t
- microsToString(const MicroProps µs, DecimalQuantity &quantity, NumberStringBuilder &string,
- UErrorCode &status);
-
- static int32_t
- writeNumber(const MicroProps µs, DecimalQuantity &quantity, NumberStringBuilder &string,
- UErrorCode &status);
-
static int32_t
writeIntegerDigits(const MicroProps µs, DecimalQuantity &quantity, NumberStringBuilder &string,
- UErrorCode &status);
+ int32_t index, UErrorCode &status);
static int32_t
writeFractionDigits(const MicroProps µs, DecimalQuantity &quantity, NumberStringBuilder &string,
- UErrorCode &status);
+ int32_t index, UErrorCode &status);
};
} // namespace impl