Float.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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-31
  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/definition.hpp>
  13. #include <ls-std/core/interface/IBoxing.hpp>
  14. #include <string>
  15. namespace ls::std::boxing
  16. {
  17. ls_std_class Float final : public core::Class, public core::interface_type::IBoxing
  18. {
  19. public:
  20. Float();
  21. explicit Float(float _value);
  22. ~Float() noexcept override;
  23. // assignment operators
  24. Float &operator=(float _value);
  25. // arithmetic operators
  26. float operator-() const;
  27. float operator+(const Float &_float) const;
  28. float operator+(float _value) const;
  29. float operator*(const Float &_float) const;
  30. float operator*(float _value) const;
  31. float operator-(const Float &_float) const;
  32. float operator-(float _value) const;
  33. float operator/(const Float &_float) const;
  34. float operator/(float _value) const;
  35. // compound operators
  36. Float &operator+=(const Float &_float);
  37. Float &operator+=(float _value);
  38. Float &operator-=(const Float &_float);
  39. Float &operator-=(float _value);
  40. Float &operator*=(const Float &_float);
  41. Float &operator*=(float _value);
  42. Float &operator/=(const Float &_float);
  43. Float &operator/=(float _value);
  44. // comparison operators
  45. bool operator==(const Float &_float) const;
  46. bool operator==(float _value) const;
  47. bool operator!=(const Float &_float) const;
  48. bool operator!=(float _value) const;
  49. bool operator>(const Float &_float) const;
  50. bool operator>(float _value) const;
  51. bool operator>=(const Float &_float) const;
  52. bool operator>=(float _value) const;
  53. bool operator<(const Float &_float) const;
  54. bool operator<(float _value) const;
  55. bool operator<=(const Float &_float) const;
  56. bool operator<=(float _value) const;
  57. // increment / decrement operator
  58. void operator++();
  59. void operator--();
  60. // implementation
  61. void parse(const ::std::string &_parseText) override;
  62. [[nodiscard]] ::std::string toString() override;
  63. // additional functionality
  64. [[nodiscard]] float getEpsilon() const;
  65. [[nodiscard]] float getValue() const;
  66. void setEpsilon(float _epsilon);
  67. private:
  68. float epsilon{};
  69. float value{};
  70. void _assignEpsilon(float _epsilon);
  71. [[nodiscard]] static ::std::string _fetchClassName();
  72. };
  73. }
  74. #endif