NullPointerEvaluator.cpp 1000 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-08
  6. * Changed: 2023-02-08
  7. *
  8. * */
  9. #include <ls-std/core/evaluator/NullPointerEvaluator.hpp>
  10. #include <ls-std/core/exception/NullPointerException.hpp>
  11. ls::std::core::NullPointerEvaluator::NullPointerEvaluator(const ::std::shared_ptr<void> &_argument) : argument(_argument)
  12. {}
  13. ls::std::core::NullPointerEvaluator::NullPointerEvaluator(const ::std::shared_ptr<void> &_argument, ::std::string _message) : argument(_argument), message(::std::move(_message))
  14. {}
  15. ls::std::core::NullPointerEvaluator::~NullPointerEvaluator() = default;
  16. void ls::std::core::NullPointerEvaluator::evaluate()
  17. {
  18. if (this->argument == nullptr)
  19. {
  20. if (this->message.empty())
  21. {
  22. throw ls::std::core::NullPointerException{"reference in use is null!"};
  23. }
  24. else
  25. {
  26. throw ls::std::core::NullPointerException{this->message};
  27. }
  28. }
  29. }