Float.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-14
  6. * Changed: 2024-05-25
  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. * @class(name: 'Float', package: 'boxing')
  18. * */
  19. namespace ls::std::boxing
  20. {
  21. class LS_STD_DYNAMIC_GOAL Float : public ls::std::core::Class, public ls::std::core::interface_type::IBoxing
  22. {
  23. public:
  24. Float();
  25. explicit Float(float _value);
  26. ~Float() noexcept override;
  27. // assignment operators
  28. ls::std::boxing::Float &operator=(float _value);
  29. // arithmetic operators
  30. float operator-() const;
  31. float operator+(const ls::std::boxing::Float &_float) const;
  32. float operator+(float _value) const;
  33. float operator*(const ls::std::boxing::Float &_float) const;
  34. float operator*(float _value) const;
  35. float operator-(const ls::std::boxing::Float &_float) const;
  36. float operator-(float _value) const;
  37. float operator/(const ls::std::boxing::Float &_float) const;
  38. float operator/(float _value) const;
  39. // compound operators
  40. ls::std::boxing::Float &operator+=(const ls::std::boxing::Float &_float);
  41. ls::std::boxing::Float &operator+=(float _value);
  42. ls::std::boxing::Float &operator-=(const ls::std::boxing::Float &_float);
  43. ls::std::boxing::Float &operator-=(float _value);
  44. ls::std::boxing::Float &operator*=(const ls::std::boxing::Float &_float);
  45. ls::std::boxing::Float &operator*=(float _value);
  46. ls::std::boxing::Float &operator/=(const ls::std::boxing::Float &_float);
  47. ls::std::boxing::Float &operator/=(float _value);
  48. // comparison operators
  49. bool operator==(const ls::std::boxing::Float &_float) const;
  50. bool operator==(float _value) const;
  51. bool operator!=(const ls::std::boxing::Float &_float) const;
  52. bool operator!=(float _value) const;
  53. bool operator>(const ls::std::boxing::Float &_float) const;
  54. bool operator>(float _value) const;
  55. bool operator>=(const ls::std::boxing::Float &_float) const;
  56. bool operator>=(float _value) const;
  57. bool operator<(const ls::std::boxing::Float &_float) const;
  58. bool operator<(float _value) const;
  59. bool operator<=(const ls::std::boxing::Float &_float) const;
  60. bool operator<=(float _value) const;
  61. // increment / decrement operator
  62. void operator++();
  63. void operator--();
  64. // implementation
  65. void parse(const ::std::string &_parseText) override;
  66. [[nodiscard]] ::std::string toString() override;
  67. // additional functionality
  68. [[nodiscard]] float getEpsilon() const;
  69. [[nodiscard]] float getValue() const;
  70. void setEpsilon(float _epsilon);
  71. private:
  72. float epsilon{};
  73. float value{};
  74. void _assignEpsilon(float _epsilon);
  75. [[nodiscard]] static ::std::string _fetchClassName();
  76. };
  77. }
  78. #endif