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