Long.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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-17
  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. // stream operators
  58. // TODO: not compilable
  59. // friend std::ostream& operator<<(std::ostream& outputStream, const Long& _long) {
  60. // outputStream << _long.value;
  61. // return outputStream;
  62. // }
  63. //
  64. // friend std::istream& operator>>(std::istream& inputStream, Long& _long) {
  65. // inputStream >> _long.value;
  66. // return inputStream;
  67. // }
  68. // logical operators
  69. friend bool operator!(const Long& _long) {
  70. return !_long.value;
  71. }
  72. bool operator&&(const Long& _long) const;
  73. bool operator&&(long _value) const;
  74. bool operator&&(bool _expression) const;
  75. bool operator||(const Long& _long) const;
  76. bool operator||(long _value) const;
  77. bool operator||(bool _expression) const;
  78. // increment / decrement operator
  79. void operator++();
  80. void operator--();
  81. // implementation
  82. void parse(std::string _parseText) override;
  83. std::string toString() override;
  84. // additional functionality
  85. long getValue() const;
  86. private:
  87. long value {};
  88. };
  89. }
  90. #endif