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