Double.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-14
  6. * Changed: 2021-07-12
  7. *
  8. * */
  9. #ifndef LS_STD_DOUBLE_HPP
  10. #define LS_STD_DOUBLE_HPP
  11. #include <memory>
  12. #include <ls_std/base/Class.hpp>
  13. #include "IBoxing.hpp"
  14. namespace ls_std
  15. {
  16. class Double : public ls_std::Class, public ls_std::IBoxing
  17. {
  18. public:
  19. Double();
  20. explicit Double(double _value);
  21. ~Double() override = default;
  22. // conversion operator
  23. operator double() const; // do not make explicit!
  24. // assignment operators
  25. ls_std::Double &operator=(double _value);
  26. // arithmetic operators
  27. double operator-() const;
  28. double operator+(const ls_std::Double &_double) const;
  29. double operator+(double _value) const;
  30. double operator*(const ls_std::Double &_double) const;
  31. double operator*(double _value) const;
  32. double operator-(const ls_std::Double &_double) const;
  33. double operator-(double _value) const;
  34. double operator/(const ls_std::Double &_double) const;
  35. double operator/(double _value) const;
  36. // compound operators
  37. ls_std::Double &operator+=(const ls_std::Double &_double);
  38. ls_std::Double &operator+=(double _value);
  39. ls_std::Double &operator-=(const ls_std::Double &_double);
  40. ls_std::Double &operator-=(double _value);
  41. ls_std::Double &operator*=(const ls_std::Double &_double);
  42. ls_std::Double &operator*=(double _value);
  43. ls_std::Double &operator/=(const ls_std::Double &_double);
  44. ls_std::Double &operator/=(double _value);
  45. // comparison operators
  46. bool operator==(const ls_std::Double &_double) const;
  47. bool operator==(double _value) const;
  48. bool operator!=(const ls_std::Double &_double) const;
  49. bool operator!=(double _value) const;
  50. bool operator>(const ls_std::Double &_double) const;
  51. bool operator>(double _value) const;
  52. bool operator>=(const ls_std::Double &_double) const;
  53. bool operator>=(double _value) const;
  54. bool operator<(const ls_std::Double &_double) const;
  55. bool operator<(double _value) const;
  56. bool operator<=(const ls_std::Double &_double) const;
  57. bool operator<=(double _value) const;
  58. // increment / decrement operator
  59. void operator++();
  60. void operator--();
  61. // implementation
  62. void parse(std::string _parseText) override;
  63. std::string toString() override;
  64. // additional functionality
  65. double getEpsilon();
  66. double getValue();
  67. void setEpsilon(double _epsilon);
  68. private:
  69. double epsilon{};
  70. double value{};
  71. void _assignEpsilon(double _epsilon);
  72. };
  73. }
  74. #endif