Long.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-17
  6. * Changed: 2020-11-20
  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. class Long : public Class, public IBoxing, public ISerializable, public IStorable {
  19. public:
  20. explicit Long(ls_std::long_type _value);
  21. Long();
  22. ~Long() = default;
  23. // conversion operator
  24. operator ls_std::long_type() const;
  25. // assignment operators
  26. Long& operator=(ls_std::long_type _value);
  27. // arithmetic operators
  28. ls_std::long_type operator-() const;
  29. ls_std::long_type operator+(const Long& _long) const;
  30. ls_std::long_type operator+(ls_std::long_type _value) const;
  31. ls_std::long_type operator*(const Long& _long) const;
  32. ls_std::long_type operator*(ls_std::long_type _value) const;
  33. ls_std::long_type operator-(const Long& _long) const;
  34. ls_std::long_type operator-(ls_std::long_type _value) const;
  35. ls_std::long_type operator/(const Long& _long) const;
  36. ls_std::long_type operator/(ls_std::long_type _value) const;
  37. ls_std::long_type operator%(const Long& _long) const;
  38. ls_std::long_type operator%(ls_std::long_type _value) const;
  39. // compound operators
  40. Long& operator+=(const Long& _long);
  41. Long& operator+=(ls_std::long_type _value);
  42. Long& operator-=(const Long& _long);
  43. Long& operator-=(ls_std::long_type _value);
  44. Long& operator*=(const Long& _long);
  45. Long& operator*=(ls_std::long_type _value);
  46. Long& operator/=(const Long& _long);
  47. Long& operator/=(ls_std::long_type _value);
  48. // comparison operators
  49. bool operator==(const Long& _long) const;
  50. bool operator==(ls_std::long_type _value) const;
  51. bool operator!=(const Long& _long) const;
  52. bool operator!=(ls_std::long_type _value) const;
  53. bool operator>(const Long& _long) const;
  54. bool operator>(ls_std::long_type _value) const;
  55. bool operator>=(const Long& _long) const;
  56. bool operator>=(ls_std::long_type _value) const;
  57. bool operator<(const Long& _long) const;
  58. bool operator<(ls_std::long_type _value) const;
  59. bool operator<=(const Long& _long) const;
  60. bool operator<=(ls_std::long_type _value) const;
  61. // logical operators
  62. friend bool operator!(const Long& _long) {
  63. return !_long.value;
  64. }
  65. bool operator&&(const Long& _long) const;
  66. bool operator&&(ls_std::long_type _value) const;
  67. bool operator&&(bool _expression) const;
  68. bool operator||(const Long& _long) const;
  69. bool operator||(ls_std::long_type _value) const;
  70. bool operator||(bool _expression) const;
  71. // increment / decrement operator
  72. void operator++();
  73. void operator--();
  74. // implementation
  75. ls_std::byte_field load() override;
  76. ls_std::byte_field marshal() override;
  77. void parse(std::string _parseText) override;
  78. void save(const ls_std::byte_field& _data) override;
  79. std::string toString() override;
  80. void unmarshal(const ls_std::byte_field& _data) override;
  81. // additional functionality
  82. ls_std::long_type getValue() const;
  83. void setSerializable(std::shared_ptr<ISerializable> _serializable);
  84. void setStorable(std::shared_ptr<IStorable> _storable);
  85. private:
  86. std::shared_ptr<ISerializable> serializable {};
  87. std::shared_ptr<IStorable> storable {};
  88. ls_std::long_type value {};
  89. };
  90. }
  91. #endif