Float.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-14
  6. * Changed: 2022-05-19
  7. *
  8. * */
  9. #ifndef LS_STD_FLOAT_HPP
  10. #define LS_STD_FLOAT_HPP
  11. #include <memory>
  12. #include <ls_std/core/Class.hpp>
  13. #include <ls_std/core/interface/IBoxing.hpp>
  14. namespace ls
  15. {
  16. namespace std
  17. {
  18. namespace boxing
  19. {
  20. class Float : public ls::std::core::Class, public ls::std::core::interface_type::IBoxing
  21. {
  22. public:
  23. Float();
  24. explicit Float(float _value);
  25. ~Float() override = default;
  26. // conversion operator
  27. operator float() const; // do not make explicit!
  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(::std::string _parseText) override;
  67. ::std::string toString() override;
  68. // additional functionality
  69. float getEpsilon();
  70. float getValue();
  71. void setEpsilon(float _epsilon);
  72. private:
  73. float epsilon{};
  74. float value{};
  75. void _assignEpsilon(float _epsilon);
  76. };
  77. }
  78. }
  79. }
  80. #endif