Float.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-14
  6. * Changed: 2024-09-11
  7. *
  8. * */
  9. #ifndef LS_STD_FLOAT_HPP
  10. #define LS_STD_FLOAT_HPP
  11. #include <ls-std/core/Class.hpp>
  12. #include <ls-std/core/interface/IBoxing.hpp>
  13. #include <ls-std/os/dynamic-goal.hpp>
  14. #include <memory>
  15. #include <string>
  16. /*
  17. * @doc: class(name: 'Float', package: 'boxing')
  18. * @doc: boxing.Float.description('This class represents the primitive datatype float and provides functionalities for arithmetic operations, accuracy and string representation.')
  19. * */
  20. namespace ls::std::boxing
  21. {
  22. class LS_STD_DYNAMIC_GOAL Float : public ls::std::core::Class, public ls::std::core::interface_type::IBoxing
  23. {
  24. public:
  25. Float();
  26. explicit Float(float _value);
  27. ~Float() noexcept override;
  28. // assignment operators
  29. ls::std::boxing::Float &operator=(float _value);
  30. // arithmetic operators
  31. float operator-() const;
  32. float operator+(const ls::std::boxing::Float &_float) const;
  33. float operator+(float _value) const;
  34. float operator*(const ls::std::boxing::Float &_float) const;
  35. float operator*(float _value) const;
  36. float operator-(const ls::std::boxing::Float &_float) const;
  37. float operator-(float _value) const;
  38. float operator/(const ls::std::boxing::Float &_float) const;
  39. float operator/(float _value) const;
  40. // compound operators
  41. ls::std::boxing::Float &operator+=(const ls::std::boxing::Float &_float);
  42. ls::std::boxing::Float &operator+=(float _value);
  43. ls::std::boxing::Float &operator-=(const ls::std::boxing::Float &_float);
  44. ls::std::boxing::Float &operator-=(float _value);
  45. ls::std::boxing::Float &operator*=(const ls::std::boxing::Float &_float);
  46. ls::std::boxing::Float &operator*=(float _value);
  47. ls::std::boxing::Float &operator/=(const ls::std::boxing::Float &_float);
  48. ls::std::boxing::Float &operator/=(float _value);
  49. // comparison operators
  50. bool operator==(const ls::std::boxing::Float &_float) const;
  51. bool operator==(float _value) const;
  52. bool operator!=(const ls::std::boxing::Float &_float) const;
  53. bool operator!=(float _value) const;
  54. bool operator>(const ls::std::boxing::Float &_float) const;
  55. bool operator>(float _value) const;
  56. bool operator>=(const ls::std::boxing::Float &_float) const;
  57. bool operator>=(float _value) const;
  58. bool operator<(const ls::std::boxing::Float &_float) const;
  59. bool operator<(float _value) const;
  60. bool operator<=(const ls::std::boxing::Float &_float) const;
  61. bool operator<=(float _value) const;
  62. // increment / decrement operator
  63. void operator++();
  64. void operator--();
  65. // implementation
  66. void parse(const ::std::string &_parseText) override;
  67. [[nodiscard]] ::std::string toString() override;
  68. // additional functionality
  69. [[nodiscard]] float getEpsilon() const;
  70. [[nodiscard]] float getValue() const;
  71. void setEpsilon(float _epsilon);
  72. private:
  73. float epsilon{};
  74. float value{};
  75. void _assignEpsilon(float _epsilon);
  76. [[nodiscard]] static ::std::string _fetchClassName();
  77. };
  78. }
  79. #endif