Integer.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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-31
  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/definition.hpp>
  13. #include <ls-std/core/interface/IBoxing.hpp>
  14. namespace ls::std::boxing
  15. {
  16. ls_std_class Integer final : public core::Class, public core::interface_type::IBoxing
  17. {
  18. public:
  19. explicit Integer(int _value);
  20. Integer();
  21. ~Integer() noexcept override;
  22. // assignment operators
  23. Integer &operator=(int _value);
  24. // arithmetic operators
  25. int operator-() const;
  26. int operator+(const Integer &_integer) const;
  27. int operator+(int _value) const;
  28. int operator*(const Integer &_integer) const;
  29. int operator*(int _value) const;
  30. int operator-(const Integer &_integer) const;
  31. int operator-(int _value) const;
  32. int operator/(const Integer &_integer) const;
  33. int operator/(int _value) const;
  34. int operator%(const Integer &_integer) const;
  35. int operator%(int _value) const;
  36. // compound operators
  37. Integer &operator+=(const Integer &_integer);
  38. Integer &operator+=(int _value);
  39. Integer &operator-=(const Integer &_integer);
  40. Integer &operator-=(int _value);
  41. Integer &operator*=(const Integer &_integer);
  42. Integer &operator*=(int _value);
  43. Integer &operator/=(const Integer &_integer);
  44. Integer &operator/=(int _value);
  45. // comparison operators
  46. bool operator==(const Integer &_integer) const;
  47. bool operator==(int _value) const;
  48. bool operator!=(const Integer &_integer) const;
  49. bool operator!=(int _value) const;
  50. bool operator>(const Integer &_integer) const;
  51. bool operator>(int _value) const;
  52. bool operator>=(const Integer &_integer) const;
  53. bool operator>=(int _value) const;
  54. bool operator<(const Integer &_integer) const;
  55. bool operator<(int _value) const;
  56. bool operator<=(const Integer &_integer) const;
  57. bool operator<=(int _value) const;
  58. // logical operators
  59. friend bool operator!(const Integer &_integer)
  60. {
  61. return !_integer.value;
  62. }
  63. // increment / decrement operator
  64. void operator++();
  65. void operator--();
  66. // implementation
  67. void parse(const ::std::string &_parseText) override;
  68. [[nodiscard]] ::std::string toString() override;
  69. // additional functionality
  70. [[nodiscard]] int getValue() const;
  71. private:
  72. int value{};
  73. [[nodiscard]] static ::std::string _fetchClassName();
  74. };
  75. }
  76. #endif