Float.hpp 3.0 KB

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