Integer.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-07
  6. * Changed: 2022-05-19
  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. namespace ls
  15. {
  16. namespace std
  17. {
  18. namespace boxing
  19. {
  20. class 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() override = default;
  26. // conversion operator
  27. operator int() const;
  28. // assignment operators
  29. ls::std::boxing::Integer &operator=(int _value);
  30. // arithmetic operators
  31. int operator-() 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. int operator%(const ls::std::boxing::Integer &_integer) const;
  41. int operator%(int _value) const;
  42. // compound operators
  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. ls::std::boxing::Integer &operator/=(const ls::std::boxing::Integer &_integer);
  50. ls::std::boxing::Integer &operator/=(int _value);
  51. // comparison operators
  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. bool operator<=(const ls::std::boxing::Integer &_integer) const;
  63. bool operator<=(int _value) const;
  64. // logical operators
  65. friend bool operator!(const ls::std::boxing::Integer &_integer)
  66. {
  67. return !_integer.value;
  68. }
  69. bool operator&&(const ls::std::boxing::Integer &_integer) const;
  70. bool operator&&(int _value) const;
  71. bool operator&&(bool _expression) const;
  72. bool operator||(const ls::std::boxing::Integer &_integer) const;
  73. bool operator||(int _value) const;
  74. bool operator||(bool _expression) const;
  75. // increment / decrement operator
  76. void operator++();
  77. void operator--();
  78. // implementation
  79. void parse(::std::string _parseText) override;
  80. ::std::string toString() override;
  81. // additional functionality
  82. int getValue() const;
  83. private:
  84. int value{};
  85. };
  86. }
  87. }
  88. }
  89. #endif