Long.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-17
  6. * Changed: 2021-07-14
  7. *
  8. * */
  9. #ifndef LS_STD_LONG_HPP
  10. #define LS_STD_LONG_HPP
  11. #include <memory>
  12. #include <ls_std/base/Class.hpp>
  13. #include "IBoxing.hpp"
  14. #include <ls_std/base/Types.hpp>
  15. #include <ls_std/serialization/ISerializable.hpp>
  16. #include <ls_std/io/IStorable.hpp>
  17. namespace ls_std
  18. {
  19. class Long : public ls_std::Class, public ls_std::IBoxing
  20. {
  21. public:
  22. explicit Long(ls_std::long_type _value);
  23. Long();
  24. ~Long() override = default;
  25. // conversion operator
  26. operator ls_std::long_type() const;
  27. // assignment operators
  28. ls_std::Long &operator=(ls_std::long_type _value);
  29. // arithmetic operators
  30. ls_std::long_type operator-() const;
  31. ls_std::long_type operator+(const ls_std::Long &_long) const;
  32. ls_std::long_type operator+(ls_std::long_type _value) const;
  33. ls_std::long_type operator*(const ls_std::Long &_long) const;
  34. ls_std::long_type operator*(ls_std::long_type _value) const;
  35. ls_std::long_type operator-(const ls_std::Long &_long) const;
  36. ls_std::long_type operator-(ls_std::long_type _value) const;
  37. ls_std::long_type operator/(const ls_std::Long &_long) const;
  38. ls_std::long_type operator/(ls_std::long_type _value) const;
  39. ls_std::long_type operator%(const ls_std::Long &_long) const;
  40. ls_std::long_type operator%(ls_std::long_type _value) const;
  41. // compound operators
  42. ls_std::Long &operator+=(const ls_std::Long &_long);
  43. ls_std::Long &operator+=(ls_std::long_type _value);
  44. ls_std::Long &operator-=(const ls_std::Long &_long);
  45. ls_std::Long &operator-=(ls_std::long_type _value);
  46. ls_std::Long &operator*=(const ls_std::Long &_long);
  47. ls_std::Long &operator*=(ls_std::long_type _value);
  48. ls_std::Long &operator/=(const ls_std::Long &_long);
  49. ls_std::Long &operator/=(ls_std::long_type _value);
  50. // comparison operators
  51. bool operator==(const ls_std::Long &_long) const;
  52. bool operator==(ls_std::long_type _value) const;
  53. bool operator!=(const ls_std::Long &_long) const;
  54. bool operator!=(ls_std::long_type _value) const;
  55. bool operator>(const ls_std::Long &_long) const;
  56. bool operator>(ls_std::long_type _value) const;
  57. bool operator>=(const ls_std::Long &_long) const;
  58. bool operator>=(ls_std::long_type _value) const;
  59. bool operator<(const ls_std::Long &_long) const;
  60. bool operator<(ls_std::long_type _value) const;
  61. bool operator<=(const ls_std::Long &_long) const;
  62. bool operator<=(ls_std::long_type _value) const;
  63. // logical operators
  64. friend bool operator!(const ls_std::Long &_long)
  65. {
  66. return !_long.value;
  67. }
  68. bool operator&&(const ls_std::Long &_long) const;
  69. bool operator&&(ls_std::long_type _value) const;
  70. bool operator&&(bool _expression) const;
  71. bool operator||(const ls_std::Long &_long) const;
  72. bool operator||(ls_std::long_type _value) const;
  73. bool operator||(bool _expression) const;
  74. // increment / decrement operator
  75. void operator++();
  76. void operator--();
  77. // implementation
  78. void parse(std::string _parseText) override;
  79. std::string toString() override;
  80. // additional functionality
  81. ls_std::long_type getValue() const;
  82. private:
  83. ls_std::long_type value{};
  84. };
  85. }
  86. #endif