Long.cpp 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-17
  6. * Changed: 2023-02-07
  7. *
  8. * */
  9. #include <ls-std/boxing/Long.hpp>
  10. #include <ls-std/core/exception/IllegalArithmeticOperationException.hpp>
  11. ls::std::boxing::Long::Long(ls::std::core::type::long_type _value) : ls::std::core::Class("Long"), value(_value)
  12. {}
  13. ls::std::boxing::Long::Long() : ls::std::core::Class("Long")
  14. {}
  15. ls::std::boxing::Long::~Long() = default;
  16. ls::std::boxing::Long::operator ls::std::core::type::long_type() const
  17. {
  18. return this->value;
  19. }
  20. ls::std::boxing::Long &ls::std::boxing::Long::operator=(ls::std::core::type::long_type _value)
  21. {
  22. this->value = _value;
  23. return *this;
  24. }
  25. ls::std::core::type::long_type ls::std::boxing::Long::operator-() const
  26. {
  27. return -this->value;
  28. }
  29. ls::std::core::type::long_type ls::std::boxing::Long::operator+(const ls::std::boxing::Long &_long) const
  30. {
  31. return this->value + _long;
  32. }
  33. ls::std::core::type::long_type ls::std::boxing::Long::operator+(ls::std::core::type::long_type _value) const
  34. {
  35. return this->value + _value;
  36. }
  37. ls::std::core::type::long_type ls::std::boxing::Long::operator*(const ls::std::boxing::Long &_long) const
  38. {
  39. return this->value * _long;
  40. }
  41. ls::std::core::type::long_type ls::std::boxing::Long::operator*(ls::std::core::type::long_type _value) const
  42. {
  43. return this->value * _value;
  44. }
  45. ls::std::core::type::long_type ls::std::boxing::Long::operator-(const ls::std::boxing::Long &_long) const
  46. {
  47. return this->value - _long;
  48. }
  49. ls::std::core::type::long_type ls::std::boxing::Long::operator-(ls::std::core::type::long_type _value) const
  50. {
  51. return this->value - _value;
  52. }
  53. ls::std::core::type::long_type ls::std::boxing::Long::operator/(const ls::std::boxing::Long &_long) const
  54. {
  55. if (_long == (ls::std::core::type::long_type) 0)
  56. {
  57. throw ls::std::core::IllegalArithmeticOperationException{"division by zero is not allowed"};
  58. }
  59. return this->value / _long;
  60. }
  61. ls::std::core::type::long_type ls::std::boxing::Long::operator/(ls::std::core::type::long_type _value) const
  62. {
  63. if (_value == 0)
  64. {
  65. throw ls::std::core::IllegalArithmeticOperationException{"division by zero is not allowed"};
  66. }
  67. return this->value / _value;
  68. }
  69. ls::std::core::type::long_type ls::std::boxing::Long::operator%(const ls::std::boxing::Long &_long) const
  70. {
  71. return this->value % _long;
  72. }
  73. ls::std::core::type::long_type ls::std::boxing::Long::operator%(ls::std::core::type::long_type _value) const
  74. {
  75. return this->value % _value;
  76. }
  77. ls::std::boxing::Long &ls::std::boxing::Long::operator+=(const ls::std::boxing::Long &_long)
  78. {
  79. this->value += _long;
  80. return *this;
  81. }
  82. ls::std::boxing::Long &ls::std::boxing::Long::operator+=(ls::std::core::type::long_type _value)
  83. {
  84. this->value += _value;
  85. return *this;
  86. }
  87. ls::std::boxing::Long &ls::std::boxing::Long::operator-=(const ls::std::boxing::Long &_long)
  88. {
  89. this->value -= _long;
  90. return *this;
  91. }
  92. ls::std::boxing::Long &ls::std::boxing::Long::operator-=(ls::std::core::type::long_type _value)
  93. {
  94. this->value -= _value;
  95. return *this;
  96. }
  97. ls::std::boxing::Long &ls::std::boxing::Long::operator*=(const ls::std::boxing::Long &_long)
  98. {
  99. this->value *= _long;
  100. return *this;
  101. }
  102. ls::std::boxing::Long &ls::std::boxing::Long::operator*=(ls::std::core::type::long_type _value)
  103. {
  104. this->value *= _value;
  105. return *this;
  106. }
  107. ls::std::boxing::Long &ls::std::boxing::Long::operator/=(const ls::std::boxing::Long &_long)
  108. {
  109. if (_long == (ls::std::core::type::long_type) 0)
  110. {
  111. throw ls::std::core::IllegalArithmeticOperationException{"division by zero is not allowed"};
  112. }
  113. this->value /= _long;
  114. return *this;
  115. }
  116. ls::std::boxing::Long &ls::std::boxing::Long::operator/=(ls::std::core::type::long_type _value)
  117. {
  118. if (_value == 0)
  119. {
  120. throw ls::std::core::IllegalArithmeticOperationException{"division by zero is not allowed"};
  121. }
  122. this->value /= _value;
  123. return *this;
  124. }
  125. bool ls::std::boxing::Long::operator==(const ls::std::boxing::Long &_long) const
  126. {
  127. return this->value == _long;
  128. }
  129. bool ls::std::boxing::Long::operator==(ls::std::core::type::long_type _value) const
  130. {
  131. return this->value == _value;
  132. }
  133. bool ls::std::boxing::Long::operator!=(const ls::std::boxing::Long &_long) const
  134. {
  135. return this->value != _long;
  136. }
  137. bool ls::std::boxing::Long::operator!=(ls::std::core::type::long_type _value) const
  138. {
  139. return this->value != _value;
  140. }
  141. bool ls::std::boxing::Long::operator>(const ls::std::boxing::Long &_long) const
  142. {
  143. return this->value > _long;
  144. }
  145. bool ls::std::boxing::Long::operator>(ls::std::core::type::long_type _value) const
  146. {
  147. return this->value > _value;
  148. }
  149. bool ls::std::boxing::Long::operator>=(const ls::std::boxing::Long &_long) const
  150. {
  151. return this->value >= _long;
  152. }
  153. bool ls::std::boxing::Long::operator>=(ls::std::core::type::long_type _value) const
  154. {
  155. return this->value >= _value;
  156. }
  157. bool ls::std::boxing::Long::operator<(const ls::std::boxing::Long &_long) const
  158. {
  159. return this->value < _long;
  160. }
  161. bool ls::std::boxing::Long::operator<(ls::std::core::type::long_type _value) const
  162. {
  163. return this->value < _value;
  164. }
  165. bool ls::std::boxing::Long::operator<=(const ls::std::boxing::Long &_long) const
  166. {
  167. return this->value <= _long;
  168. }
  169. bool ls::std::boxing::Long::operator<=(ls::std::core::type::long_type _value) const
  170. {
  171. return this->value <= _value;
  172. }
  173. bool ls::std::boxing::Long::operator&&(const ls::std::boxing::Long &_long) const
  174. {
  175. return this->value && _long;
  176. }
  177. bool ls::std::boxing::Long::operator&&(ls::std::core::type::long_type _value) const
  178. {
  179. return this->value && _value;
  180. }
  181. bool ls::std::boxing::Long::operator&&(bool _expression) const
  182. {
  183. return this->value && _expression;
  184. }
  185. bool ls::std::boxing::Long::operator||(const ls::std::boxing::Long &_long) const
  186. {
  187. return this->value || _long;
  188. }
  189. bool ls::std::boxing::Long::operator||(ls::std::core::type::long_type _value) const
  190. {
  191. return this->value || _value;
  192. }
  193. bool ls::std::boxing::Long::operator||(bool _expression) const
  194. {
  195. return this->value || _expression;
  196. }
  197. void ls::std::boxing::Long::operator++()
  198. {
  199. this->value += 1;
  200. }
  201. void ls::std::boxing::Long::operator--()
  202. {
  203. this->value -= 1;
  204. }
  205. void ls::std::boxing::Long::parse(::std::string _parseText)
  206. {
  207. this->value = ::std::stoll(_parseText);
  208. }
  209. std::string ls::std::boxing::Long::toString()
  210. {
  211. return ::std::to_string(this->value);
  212. }
  213. ls::std::core::type::long_type ls::std::boxing::Long::getValue() const
  214. {
  215. return this->value;
  216. }