Integer.hpp 3.2 KB

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