Double.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-16
  7. *
  8. * */
  9. #ifndef LS_STD_DOUBLE_HPP
  10. #define LS_STD_DOUBLE_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 Double : public ls::std::core::Class, public ls::std::core::interface::IBoxing
  21. {
  22. public:
  23. Double();
  24. explicit Double(double _value);
  25. ~Double() override = default;
  26. // conversion operator
  27. operator double() const; // do not make explicit!
  28. // assignment operators
  29. ls::std::boxing::Double &operator=(double _value);
  30. // arithmetic operators
  31. double operator-() const;
  32. double operator+(const ls::std::boxing::Double &_double) const;
  33. double operator+(double _value) const;
  34. double operator*(const ls::std::boxing::Double &_double) const;
  35. double operator*(double _value) const;
  36. double operator-(const ls::std::boxing::Double &_double) const;
  37. double operator-(double _value) const;
  38. double operator/(const ls::std::boxing::Double &_double) const;
  39. double operator/(double _value) const;
  40. // compound operators
  41. ls::std::boxing::Double &operator+=(const ls::std::boxing::Double &_double);
  42. ls::std::boxing::Double &operator+=(double _value);
  43. ls::std::boxing::Double &operator-=(const ls::std::boxing::Double &_double);
  44. ls::std::boxing::Double &operator-=(double _value);
  45. ls::std::boxing::Double &operator*=(const ls::std::boxing::Double &_double);
  46. ls::std::boxing::Double &operator*=(double _value);
  47. ls::std::boxing::Double &operator/=(const ls::std::boxing::Double &_double);
  48. ls::std::boxing::Double &operator/=(double _value);
  49. // comparison operators
  50. bool operator==(const ls::std::boxing::Double &_double) const;
  51. bool operator==(double _value) const;
  52. bool operator!=(const ls::std::boxing::Double &_double) const;
  53. bool operator!=(double _value) const;
  54. bool operator>(const ls::std::boxing::Double &_double) const;
  55. bool operator>(double _value) const;
  56. bool operator>=(const ls::std::boxing::Double &_double) const;
  57. bool operator>=(double _value) const;
  58. bool operator<(const ls::std::boxing::Double &_double) const;
  59. bool operator<(double _value) const;
  60. bool operator<=(const ls::std::boxing::Double &_double) const;
  61. bool operator<=(double _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. double getEpsilon();
  70. double getValue();
  71. void setEpsilon(double _epsilon);
  72. private:
  73. double epsilon{};
  74. double value{};
  75. void _assignEpsilon(double _epsilon);
  76. };
  77. }
  78. }
  79. }
  80. #endif