Integer.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-07
  6. * Changed: 2023-02-22
  7. *
  8. * */
  9. #ifndef LS_STD_INTEGER_HPP
  10. #define LS_STD_INTEGER_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. namespace ls::std::boxing
  16. {
  17. class LS_STD_DYNAMIC_GOAL Integer : public ls::std::core::Class, public ls::std::core::interface_type::IBoxing
  18. {
  19. public:
  20. explicit Integer(int _value);
  21. Integer();
  22. ~Integer() noexcept override;
  23. // assignment operators
  24. ls::std::boxing::Integer &operator=(int _value);
  25. // arithmetic operators
  26. int operator-() const;
  27. int operator+(const ls::std::boxing::Integer &_integer) const;
  28. int operator+(int _value) const;
  29. int operator*(const ls::std::boxing::Integer &_integer) const;
  30. int operator*(int _value) const;
  31. int operator-(const ls::std::boxing::Integer &_integer) const;
  32. int operator-(int _value) const;
  33. int operator/(const ls::std::boxing::Integer &_integer) const;
  34. int operator/(int _value) const;
  35. int operator%(const ls::std::boxing::Integer &_integer) const;
  36. int operator%(int _value) const;
  37. // compound operators
  38. ls::std::boxing::Integer &operator+=(const ls::std::boxing::Integer &_integer);
  39. ls::std::boxing::Integer &operator+=(int _value);
  40. ls::std::boxing::Integer &operator-=(const ls::std::boxing::Integer &_integer);
  41. ls::std::boxing::Integer &operator-=(int _value);
  42. ls::std::boxing::Integer &operator*=(const ls::std::boxing::Integer &_integer);
  43. ls::std::boxing::Integer &operator*=(int _value);
  44. ls::std::boxing::Integer &operator/=(const ls::std::boxing::Integer &_integer);
  45. ls::std::boxing::Integer &operator/=(int _value);
  46. // comparison operators
  47. bool operator==(const ls::std::boxing::Integer &_integer) const;
  48. bool operator==(int _value) const;
  49. bool operator!=(const ls::std::boxing::Integer &_integer) const;
  50. bool operator!=(int _value) const;
  51. bool operator>(const ls::std::boxing::Integer &_integer) const;
  52. bool operator>(int _value) const;
  53. bool operator>=(const ls::std::boxing::Integer &_integer) const;
  54. bool operator>=(int _value) const;
  55. bool operator<(const ls::std::boxing::Integer &_integer) const;
  56. bool operator<(int _value) const;
  57. bool operator<=(const ls::std::boxing::Integer &_integer) const;
  58. bool operator<=(int _value) const;
  59. // logical operators
  60. friend bool operator!(const ls::std::boxing::Integer &_integer)
  61. {
  62. return !_integer.value;
  63. }
  64. bool operator&&(const ls::std::boxing::Integer &_integer) const;
  65. bool operator&&(int _value) const;
  66. bool operator&&(bool _expression) const;
  67. bool operator||(const ls::std::boxing::Integer &_integer) const;
  68. bool operator||(int _value) const;
  69. bool operator||(bool _expression) const;
  70. // increment / decrement operator
  71. void operator++();
  72. void operator--();
  73. // implementation
  74. void parse(::std::string _parseText) override;
  75. [[nodiscard]] ::std::string toString() override;
  76. // additional functionality
  77. [[nodiscard]] int getValue() const;
  78. private:
  79. int value{};
  80. };
  81. }
  82. #endif