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