IndexOutOfBoundsEvaluator.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-10
  6. * Changed: 2024-05-31
  7. *
  8. * */
  9. #include <ls-std/core/evaluator/IndexOutOfBoundsEvaluator.hpp>
  10. #include <ls-std/core/exception/IndexOutOfBoundsException.hpp>
  11. using ls::std::core::IndexOutOfBoundsEvaluator;
  12. using ls::std::core::IndexOutOfBoundsException;
  13. using std::move;
  14. using std::string;
  15. IndexOutOfBoundsEvaluator::IndexOutOfBoundsEvaluator(const size_t _index, const size_t _size) : index(_index), size(_size)
  16. {}
  17. IndexOutOfBoundsEvaluator::IndexOutOfBoundsEvaluator(const size_t _index, const size_t _size, string _message) : index(_index), message(::move(_message)), size(_size)
  18. {}
  19. IndexOutOfBoundsEvaluator::~IndexOutOfBoundsEvaluator() noexcept = default;
  20. void IndexOutOfBoundsEvaluator::evaluate()
  21. {
  22. if (this->index >= this->size)
  23. {
  24. if (this->message.empty())
  25. {
  26. throw IndexOutOfBoundsException{};
  27. }
  28. throw IndexOutOfBoundsException{this->message};
  29. }
  30. }