NullPointerEvaluator.cpp 1.0 KB

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