/* * Author: Patrick-Christopher Mattulat * Company: Lynar Studios * E-Mail: webmaster@lynarstudios.com * Created: 2023-05-23 * Changed: 2024-09-09 * * */ #ifndef LS_STD_RAW_NULL_POINTER_ARGUMENT_EVALUATOR_HPP #define LS_STD_RAW_NULL_POINTER_ARGUMENT_EVALUATOR_HPP #include #include #include #include /* * @doc: class(name: 'RawNullPointerArgumentEvaluator', package: 'core') * */ namespace ls::std::core { template class RawNullPointerArgumentEvaluator : public ls::std::core::interface_type::IEvaluator { public: explicit RawNullPointerArgumentEvaluator(const ls::std::core::type::RawPointer &_argument) : argument(_argument) {} explicit RawNullPointerArgumentEvaluator(const ls::std::core::type::RawPointer &_argument, const ::std::string &_message) : argument(_argument), message(_message) {} ~RawNullPointerArgumentEvaluator() noexcept override = default; void evaluate() override { if (this->argument.get() == nullptr) { if (this->message.empty()) { throw ls::std::core::IllegalArgumentException{"passed argument is null!"}; } else { throw ls::std::core::IllegalArgumentException{this->message}; } } } private: ls::std::core::type::RawPointer argument{}; ::std::string message{}; }; } #endif