Integer.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-07
  6. * Changed: 2023-05-17
  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. // increment / decrement operator
  65. void operator++();
  66. void operator--();
  67. // implementation
  68. void parse(const ::std::string &_parseText) override;
  69. [[nodiscard]] ::std::string toString() override;
  70. // additional functionality
  71. [[nodiscard]] int getValue() const;
  72. private:
  73. int value{};
  74. [[nodiscard]] static ::std::string _fetchClassName();
  75. };
  76. }
  77. #endif