/* * Author: Patrick-Christopher Mattulat * Company: Lynar Studios * E-Mail: webmaster@lynarstudios.com * Created: 2023-05-24 * Changed: 2024-05-31 * * */ #ifndef LS_STD_RAW_NULL_POINTER_EVALUATOR_HPP #define LS_STD_RAW_NULL_POINTER_EVALUATOR_HPP #include #include #include #include namespace ls::std::core { template class RawNullPointerEvaluator final : public interface_type::IEvaluator { public: explicit RawNullPointerEvaluator(const type::RawPointer &_argument) : argument(_argument) {} RawNullPointerEvaluator(const type::RawPointer &_argument, ::std::string _message) : argument(_argument), message(::std::move(_message)) {} ~RawNullPointerEvaluator() noexcept override = default; void evaluate() override { if (this->argument.get() == nullptr) { if (this->message.empty()) { throw NullPointerException{"reference in use is null!"}; } else { throw NullPointerException{this->message}; } } } private: type::RawPointer argument{}; ::std::string message{}; }; } #endif