number_scientific.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // © 2017 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. #include "unicode/utypes.h"
  4. #if !UCONFIG_NO_FORMATTING
  5. #ifndef __NUMBER_SCIENTIFIC_H__
  6. #define __NUMBER_SCIENTIFIC_H__
  7. #include "number_types.h"
  8. U_NAMESPACE_BEGIN namespace number {
  9. namespace impl {
  10. // Forward-declare
  11. class ScientificHandler;
  12. class U_I18N_API ScientificModifier : public UMemory, public Modifier {
  13. public:
  14. ScientificModifier();
  15. void set(int32_t exponent, const ScientificHandler *handler);
  16. int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex,
  17. UErrorCode &status) const override;
  18. int32_t getPrefixLength() const override;
  19. int32_t getCodePointCount() const override;
  20. bool isStrong() const override;
  21. bool containsField(Field field) const override;
  22. void getParameters(Parameters& output) const override;
  23. bool semanticallyEquivalent(const Modifier& other) const override;
  24. private:
  25. int32_t fExponent;
  26. const ScientificHandler *fHandler;
  27. };
  28. class ScientificHandler : public UMemory, public MicroPropsGenerator, public MultiplierProducer {
  29. public:
  30. ScientificHandler(const Notation *notation, const DecimalFormatSymbols *symbols,
  31. const MicroPropsGenerator *parent);
  32. void
  33. processQuantity(DecimalQuantity &quantity, MicroProps &micros, UErrorCode &status) const override;
  34. int32_t getMultiplier(int32_t magnitude) const override;
  35. private:
  36. const Notation::ScientificSettings fSettings;
  37. const DecimalFormatSymbols *fSymbols;
  38. const MicroPropsGenerator *fParent;
  39. friend class ScientificModifier;
  40. };
  41. } // namespace impl
  42. } // namespace number
  43. U_NAMESPACE_END
  44. #endif //__NUMBER_SCIENTIFIC_H__
  45. #endif /* #if !UCONFIG_NO_FORMATTING */