Long.hpp 2.6 KB

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