Integer.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-07
  6. * Changed: 2022-07-03
  7. *
  8. * */
  9. #ifndef LS_STD_INTEGER_HPP
  10. #define LS_STD_INTEGER_HPP
  11. #include <memory>
  12. #include <ls_std/core/Class.hpp>
  13. #include <ls_std/core/interface/IBoxing.hpp>
  14. #include <ls_std/os/dynamic_goal.hpp>
  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() override = default;
  23. // conversion operator
  24. operator int() const;
  25. // assignment operators
  26. ls::std::boxing::Integer &operator=(int _value);
  27. // arithmetic operators
  28. int operator-() 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. int operator%(const ls::std::boxing::Integer &_integer) const;
  38. int operator%(int _value) const;
  39. // compound operators
  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. ls::std::boxing::Integer &operator/=(const ls::std::boxing::Integer &_integer);
  47. ls::std::boxing::Integer &operator/=(int _value);
  48. // comparison operators
  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. bool operator<=(const ls::std::boxing::Integer &_integer) const;
  60. bool operator<=(int _value) const;
  61. // logical operators
  62. friend bool operator!(const ls::std::boxing::Integer &_integer)
  63. {
  64. return !_integer.value;
  65. }
  66. bool operator&&(const ls::std::boxing::Integer &_integer) const;
  67. bool operator&&(int _value) const;
  68. bool operator&&(bool _expression) const;
  69. bool operator||(const ls::std::boxing::Integer &_integer) const;
  70. bool operator||(int _value) const;
  71. bool operator||(bool _expression) const;
  72. // increment / decrement operator
  73. void operator++();
  74. void operator--();
  75. // implementation
  76. void parse(::std::string _parseText) override;
  77. ::std::string toString() override;
  78. // additional functionality
  79. [[nodiscard]] int getValue() const;
  80. private:
  81. int value{};
  82. };
  83. }
  84. #endif