Ver código fonte

Merge branch 'evaluator' of public/ls-standard-library into development

patrick-christopher.mattulat 1 ano atrás
pai
commit
d4d56ee3cb
31 arquivos alterados com 569 adições e 242 exclusões
  1. 7 0
      CMakeLists.txt
  2. 1 0
      README.md
  3. 35 0
      include/ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp
  4. 36 0
      include/ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp
  5. 36 0
      include/ls-std/core/evaluator/NullPointerEvaluator.hpp
  6. 28 0
      include/ls-std/core/interface/IEvaluator.hpp
  7. 11 14
      include/ls-std/io/xml/XmlNode.hpp
  8. 5 1
      include/ls-std/ls-std-core.hpp
  9. 3 7
      source/ls-std/core/Class.cpp
  10. 34 0
      source/ls-std/core/evaluator/EmptyStringArgumentEvaluator.cpp
  11. 34 0
      source/ls-std/core/evaluator/NullPointerArgumentEvaluator.cpp
  12. 34 0
      source/ls-std/core/evaluator/NullPointerEvaluator.cpp
  13. 14 0
      source/ls-std/core/interface/IEvaluator.cpp
  14. 3 7
      source/ls-std/event/Event.cpp
  15. 3 7
      source/ls-std/event/EventHandler.cpp
  16. 10 35
      source/ls-std/event/EventManager.cpp
  17. 10 22
      source/ls-std/event/Narrator.cpp
  18. 3 7
      source/ls-std/event/serialization/SerializableJsonEvent.cpp
  19. 3 6
      source/ls-std/io/kv/KvFileReader.cpp
  20. 3 7
      source/ls-std/io/kv/KvPair.cpp
  21. 3 7
      source/ls-std/io/kv/KvParser.cpp
  22. 3 7
      source/ls-std/io/logging/Logger.cpp
  23. 4 12
      source/ls-std/io/xml/XmlAttribute.cpp
  24. 4 12
      source/ls-std/io/xml/XmlDocument.cpp
  25. 29 71
      source/ls-std/io/xml/XmlNode.cpp
  26. 3 7
      source/ls-std/io/xml/XmlParseParameter.cpp
  27. 3 7
      source/ls-std/io/xml/XmlParser.cpp
  28. 3 6
      source/ls-std/io/xml/XmlReader.cpp
  29. 68 0
      test/cases/core/evaluator/EmptyStringArgumentEvaluatorTest.cpp
  30. 68 0
      test/cases/core/evaluator/NullPointerArgumentEvaluatorTest.cpp
  31. 68 0
      test/cases/core/evaluator/NullPointerEvaluatorTest.cpp

+ 7 - 0
CMakeLists.txt

@@ -127,6 +127,9 @@ set(SOURCE_FILES_BOXING
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/boxing/String.cpp)
 
 set(SOURCE_FILES_CORE
+        ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/core/evaluator/EmptyStringArgumentEvaluator.cpp
+        ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/core/evaluator/NullPointerArgumentEvaluator.cpp
+        ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/core/evaluator/NullPointerEvaluator.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/core/exception/EventNotHandledException.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/core/exception/EventNotSubscribedException.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/core/exception/ExceptionMessage.cpp
@@ -138,6 +141,7 @@ set(SOURCE_FILES_CORE
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/core/exception/NullPointerException.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/core/interface/IBoxing.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/core/interface/IEncoding.cpp
+        ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/core/interface/IEvaluator.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/core/interface/IEventSubscriber.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/core/interface/IListener.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-std/core/interface/IReader.cpp
@@ -204,6 +208,9 @@ if (${LS_STD_BUILD_WITH_TESTS})
             ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/StringTest.cpp)
 
     set(TEST_FILES_CORE
+            ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/evaluator/EmptyStringArgumentEvaluatorTest.cpp
+            ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/evaluator/NullPointerArgumentEvaluatorTest.cpp
+            ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/evaluator/NullPointerEvaluatorTest.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/exception/EventNotHandledExceptionTest.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/exception/EventNotSubscribedExceptionTest.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/exception/ExceptionMessageTest.cpp

+ 1 - 0
README.md

@@ -36,6 +36,7 @@ A __Date__ class comes with this submodule, which you can use to represent a dat
 
 - __AppleClang__ compiler is now officially supported
 - exceptions provided by __core__ submodule now offer a constructor for passing dedicated messages
+- evaluators have been added, which can check a state of variables and throw a dedicated exception in a single line and more convenient way
 
 #### Improvements ####
 

+ 35 - 0
include/ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp

@@ -0,0 +1,35 @@
+/*
+* Author:          Patrick-Christopher Mattulat
+* Company:         Lynar Studios
+* E-Mail:          webmaster@lynarstudios.com
+* Created:         2023-02-08
+* Changed:         2023-02-08
+*
+* */
+
+#ifndef LS_STD_EMPTY_STRING_ARGUMENT_EVALUATOR_HPP
+#define LS_STD_EMPTY_STRING_ARGUMENT_EVALUATOR_HPP
+
+#include <ls-std/core/interface/IEvaluator.hpp>
+#include <string>
+
+namespace ls::std::core
+{
+  class EmptyStringArgumentEvaluator : public ls::std::core::interface_type::IEvaluator
+  {
+    public:
+
+      explicit EmptyStringArgumentEvaluator(::std::string _argument);
+      explicit EmptyStringArgumentEvaluator(::std::string _argument, ::std::string _message);
+      ~EmptyStringArgumentEvaluator() override;
+
+      void evaluate() override;
+
+    private:
+
+      ::std::string argument{};
+      ::std::string message{};
+  };
+}
+
+#endif

+ 36 - 0
include/ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp

@@ -0,0 +1,36 @@
+/*
+* Author:          Patrick-Christopher Mattulat
+* Company:         Lynar Studios
+* E-Mail:          webmaster@lynarstudios.com
+* Created:         2023-02-08
+* Changed:         2023-02-08
+*
+* */
+
+#ifndef LS_STD_NULL_POINTER_ARGUMENT_EVALUATOR_HPP
+#define LS_STD_NULL_POINTER_ARGUMENT_EVALUATOR_HPP
+
+#include <ls-std/core/interface/IEvaluator.hpp>
+#include <memory>
+#include <string>
+
+namespace ls::std::core
+{
+  class NullPointerArgumentEvaluator : public ls::std::core::interface_type::IEvaluator
+  {
+    public:
+
+    explicit NullPointerArgumentEvaluator(const ::std::shared_ptr<void> &_argument);
+    explicit NullPointerArgumentEvaluator(const ::std::shared_ptr<void> &_argument, ::std::string _message);
+    ~NullPointerArgumentEvaluator() override;
+
+      void evaluate() override;
+
+    private:
+
+      ::std::shared_ptr<void> argument{};
+      ::std::string message{};
+  };
+}
+
+#endif

+ 36 - 0
include/ls-std/core/evaluator/NullPointerEvaluator.hpp

@@ -0,0 +1,36 @@
+/*
+* Author:          Patrick-Christopher Mattulat
+* Company:         Lynar Studios
+* E-Mail:          webmaster@lynarstudios.com
+* Created:         2023-02-08
+* Changed:         2023-02-08
+*
+* */
+
+#ifndef LS_STD_NULL_POINTER_EVALUATOR_HPP
+#define LS_STD_NULL_POINTER_EVALUATOR_HPP
+
+#include <ls-std/core/interface/IEvaluator.hpp>
+#include <memory>
+#include <string>
+
+namespace ls::std::core
+{
+  class NullPointerEvaluator : public ls::std::core::interface_type::IEvaluator
+  {
+    public:
+
+      explicit NullPointerEvaluator(const ::std::shared_ptr<void> &_argument);
+      explicit NullPointerEvaluator(const ::std::shared_ptr<void> &_argument, ::std::string _message);
+      ~NullPointerEvaluator() override;
+
+      void evaluate() override;
+
+    private:
+
+      ::std::shared_ptr<void> argument{};
+      ::std::string message{};
+  };
+}
+
+#endif

+ 28 - 0
include/ls-std/core/interface/IEvaluator.hpp

@@ -0,0 +1,28 @@
+/*
+* Author:          Patrick-Christopher Mattulat
+* Company:         Lynar Studios
+* E-Mail:          webmaster@lynarstudios.com
+* Created:         2023-02-08
+* Changed:         2023-02-08
+*
+* */
+
+#ifndef LS_STD_I_EVALUATOR_HPP
+#define LS_STD_I_EVALUATOR_HPP
+
+#include <ls-std/os/dynamic-goal.hpp>
+
+namespace ls::std::core::interface_type
+{
+  class LS_STD_DYNAMIC_GOAL IEvaluator
+  {
+    public:
+
+      IEvaluator();
+      virtual ~IEvaluator();
+
+      virtual void evaluate() = 0;
+  };
+}
+
+#endif

+ 11 - 14
include/ls-std/io/xml/XmlNode.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-24
- * Changed:         2023-02-06
+ * Changed:         2023-02-08
  *
  * */
 
@@ -25,14 +25,14 @@ namespace ls::std::io
       explicit XmlNode(::std::string _name);
       ~XmlNode() override;
 
-      bool addAttributeAfter(const ::std::shared_ptr<ls::std::io::XmlAttribute> &_attribute, const ::std::string &_name); // nodiscard is optional here
-      bool addAttributeBefore(const ::std::shared_ptr<ls::std::io::XmlAttribute> &_attribute, const ::std::string &_name); // nodiscard is optional here
-      bool addAttributeToBeginning(const ::std::shared_ptr<ls::std::io::XmlAttribute> &_attribute); // nodiscard is optional here
-      bool addAttributeToEnd(const ::std::shared_ptr<ls::std::io::XmlAttribute> &_attribute); // nodiscard is optional here
-      bool addChildAfter(const ::std::shared_ptr<ls::std::io::XmlNode> &_child, const ::std::shared_ptr<ls::std::io::XmlNode> &_search); // nodiscard is optional here
+      bool addAttributeAfter(const ::std::shared_ptr<ls::std::io::XmlAttribute> &_attribute, const ::std::string &_name);                 // nodiscard is optional here
+      bool addAttributeBefore(const ::std::shared_ptr<ls::std::io::XmlAttribute> &_attribute, const ::std::string &_name);                // nodiscard is optional here
+      bool addAttributeToBeginning(const ::std::shared_ptr<ls::std::io::XmlAttribute> &_attribute);                                       // nodiscard is optional here
+      bool addAttributeToEnd(const ::std::shared_ptr<ls::std::io::XmlAttribute> &_attribute);                                             // nodiscard is optional here
+      bool addChildAfter(const ::std::shared_ptr<ls::std::io::XmlNode> &_child, const ::std::shared_ptr<ls::std::io::XmlNode> &_search);  // nodiscard is optional here
       bool addChildBefore(const ::std::shared_ptr<ls::std::io::XmlNode> &_child, const ::std::shared_ptr<ls::std::io::XmlNode> &_search); // nodiscard is optional here
-      bool addChildToBeginning(const ::std::shared_ptr<ls::std::io::XmlNode> &_child); // nodiscard is optional here
-      bool addChildToEnd(const ::std::shared_ptr<ls::std::io::XmlNode> &_child); // nodiscard is optional here
+      bool addChildToBeginning(const ::std::shared_ptr<ls::std::io::XmlNode> &_child);                                                    // nodiscard is optional here
+      bool addChildToEnd(const ::std::shared_ptr<ls::std::io::XmlNode> &_child);                                                          // nodiscard is optional here
       void clearValue();
       [[nodiscard]] ::std::list<::std::shared_ptr<ls::std::io::XmlAttribute>> getAttributes();
       [[nodiscard]] ::std::list<::std::shared_ptr<ls::std::io::XmlNode>> getChildren();
@@ -43,9 +43,9 @@ namespace ls::std::io
       [[nodiscard]] bool hasChild(const ::std::string &_name);
       [[nodiscard]] bool hasChild(const ::std::shared_ptr<ls::std::io::XmlNode> &_child);
       bool removeFirstAttribute(); // nodiscard is optional here
-      bool removeLastAttribute(); // nodiscard is optional here
-      bool removeFirstChild(); // nodiscard is optional here
-      bool removeLastChild(); // nodiscard is optional here
+      bool removeLastAttribute();  // nodiscard is optional here
+      bool removeFirstChild();     // nodiscard is optional here
+      bool removeLastChild();      // nodiscard is optional here
       void setName(const ::std::string &_name);
       void setValue(const ::std::string &_value);
       [[nodiscard]] ::std::string toXml();
@@ -64,9 +64,6 @@ namespace ls::std::io
 
       void _assignName(const ::std::string &_name);
       void _assignValue(const ::std::string &_value);
-      static void _checkIfAttributeReferenceIsValid(const ::std::shared_ptr<ls::std::io::XmlAttribute> &_attribute);
-      static void _checkIfNameIsNotEmpty(const ::std::string &_name);
-      static void _checkIfNodeReferenceIsValid(const ::std::shared_ptr<ls::std::io::XmlNode> &_child);
       [[nodiscard]] static ::std::string _getTab(uint8_t _tabSize);
       [[nodiscard]] bool _hasAttribute(const ::std::string &_name);
       [[nodiscard]] bool _hasChild(const ::std::shared_ptr<ls::std::io::XmlNode> &_child);

+ 5 - 1
include/ls-std/ls-std-core.hpp

@@ -3,13 +3,17 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-05-13
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
 #ifndef LS_STD_LS_STD_CORE_HPP
 #define LS_STD_LS_STD_CORE_HPP
 
+#include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp>
+#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
+#include <ls-std/core/evaluator/NullPointerEvaluator.hpp>
+
 #include <ls-std/core/exception/EventNotHandledException.hpp>
 #include <ls-std/core/exception/EventNotSubscribedException.hpp>
 #include <ls-std/core/exception/ExceptionMessage.hpp>

+ 3 - 7
source/ls-std/core/Class.cpp

@@ -3,12 +3,12 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-07
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
 #include <ls-std/core/Class.hpp>
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
+#include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp>
 
 ls::std::core::Class::Class(const ::std::string &_name)
 {
@@ -24,10 +24,6 @@ ls::std::core::Class::~Class() = default;
 
 void ls::std::core::Class::_assignClassName(const ::std::string &_name)
 {
-  if (_name.empty())
-  {
-    throw ls::std::core::IllegalArgumentException{"_name is empty"};
-  }
-
+  ls::std::core::EmptyStringArgumentEvaluator{_name, "class name is empty!"}.evaluate();
   this->name = _name;
 }

+ 34 - 0
source/ls-std/core/evaluator/EmptyStringArgumentEvaluator.cpp

@@ -0,0 +1,34 @@
+/*
+* Author:          Patrick-Christopher Mattulat
+* Company:         Lynar Studios
+* E-Mail:          webmaster@lynarstudios.com
+* Created:         2023-02-08
+* Changed:         2023-02-08
+*
+* */
+
+#include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp>
+#include <ls-std/core/exception/IllegalArgumentException.hpp>
+
+ls::std::core::EmptyStringArgumentEvaluator::EmptyStringArgumentEvaluator(::std::string _argument) : argument(::std::move(_argument))
+{}
+
+ls::std::core::EmptyStringArgumentEvaluator::EmptyStringArgumentEvaluator(::std::string _argument, ::std::string _message) : argument(::std::move(_argument)), message(::std::move(_message))
+{}
+
+ls::std::core::EmptyStringArgumentEvaluator::~EmptyStringArgumentEvaluator() = default;
+
+void ls::std::core::EmptyStringArgumentEvaluator::evaluate()
+{
+  if (this->argument.empty())
+  {
+    if (this->message.empty())
+    {
+      throw ls::std::core::IllegalArgumentException{"passed argument is empty!"};
+    }
+    else
+    {
+      throw ls::std::core::IllegalArgumentException{this->message};
+    }
+  }
+}

+ 34 - 0
source/ls-std/core/evaluator/NullPointerArgumentEvaluator.cpp

@@ -0,0 +1,34 @@
+/*
+* Author:          Patrick-Christopher Mattulat
+* Company:         Lynar Studios
+* E-Mail:          webmaster@lynarstudios.com
+* Created:         2023-02-08
+* Changed:         2023-02-08
+*
+* */
+
+#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
+#include <ls-std/core/exception/IllegalArgumentException.hpp>
+
+ls::std::core::NullPointerArgumentEvaluator::NullPointerArgumentEvaluator(const ::std::shared_ptr<void> &_argument) : argument(_argument)
+{}
+
+ls::std::core::NullPointerArgumentEvaluator::NullPointerArgumentEvaluator(const ::std::shared_ptr<void> &_argument, ::std::string _message) : argument(_argument), message(::std::move(_message))
+{}
+
+ls::std::core::NullPointerArgumentEvaluator::~NullPointerArgumentEvaluator() = default;
+
+void ls::std::core::NullPointerArgumentEvaluator::evaluate()
+{
+  if (this->argument == nullptr)
+  {
+    if (this->message.empty())
+    {
+      throw ls::std::core::IllegalArgumentException{"passed argument is null!"};
+    }
+    else
+    {
+      throw ls::std::core::IllegalArgumentException{this->message};
+    }
+  }
+}

+ 34 - 0
source/ls-std/core/evaluator/NullPointerEvaluator.cpp

@@ -0,0 +1,34 @@
+/*
+* Author:          Patrick-Christopher Mattulat
+* Company:         Lynar Studios
+* E-Mail:          webmaster@lynarstudios.com
+* Created:         2023-02-08
+* Changed:         2023-02-08
+*
+* */
+
+#include <ls-std/core/evaluator/NullPointerEvaluator.hpp>
+#include <ls-std/core/exception/NullPointerException.hpp>
+
+ls::std::core::NullPointerEvaluator::NullPointerEvaluator(const ::std::shared_ptr<void> &_argument) : argument(_argument)
+{}
+
+ls::std::core::NullPointerEvaluator::NullPointerEvaluator(const ::std::shared_ptr<void> &_argument, ::std::string _message) : argument(_argument), message(::std::move(_message))
+{}
+
+ls::std::core::NullPointerEvaluator::~NullPointerEvaluator() = default;
+
+void ls::std::core::NullPointerEvaluator::evaluate()
+{
+  if (this->argument == nullptr)
+  {
+    if (this->message.empty())
+    {
+      throw ls::std::core::NullPointerException{"reference in use is null!"};
+    }
+    else
+    {
+      throw ls::std::core::NullPointerException{this->message};
+    }
+  }
+}

+ 14 - 0
source/ls-std/core/interface/IEvaluator.cpp

@@ -0,0 +1,14 @@
+/*
+* Author:          Patrick-Christopher Mattulat
+* Company:         Lynar Studios
+* E-Mail:          webmaster@lynarstudios.com
+* Created:         2023-02-08
+* Changed:         2023-02-08
+*
+* */
+
+#include <ls-std/core/interface/IEvaluator.hpp>
+
+ls::std::core::interface_type::IEvaluator::IEvaluator() = default;
+
+ls::std::core::interface_type::IEvaluator::~IEvaluator() = default;

+ 3 - 7
source/ls-std/event/Event.cpp

@@ -3,11 +3,11 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-26
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
+#include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp>
 #include <ls-std/event/Event.hpp>
 
 ls::std::event::Event::Event(const ls::std::core::type::event_id &_id) : ls::std::core::Class("Event")
@@ -56,11 +56,7 @@ void ls::std::event::Event::setId(const ls::std::core::type::event_id &_id)
 
 void ls::std::event::Event::_assignId(const ls::std::core::type::event_id &_id)
 {
-  if (_id.empty())
-  {
-    throw ls::std::core::IllegalArgumentException{"_id is empty"};
-  }
-
+  ls::std::core::EmptyStringArgumentEvaluator{_id, "event id is empty!"}.evaluate();
   this->id = _id;
 }
 

+ 3 - 7
source/ls-std/event/EventHandler.cpp

@@ -3,11 +3,11 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-27
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
+#include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp>
 #include <ls-std/event/EventHandler.hpp>
 
 ls::std::event::EventHandler::EventHandler(const ls::std::core::type::event_id &_id) : ls::std::event::Narrator()
@@ -24,10 +24,6 @@ ls::std::core::type::event_id ls::std::event::EventHandler::getId()
 
 void ls::std::event::EventHandler::_assignId(const ls::std::core::type::event_id &_id)
 {
-  if (_id.empty())
-  {
-    throw ls::std::core::IllegalArgumentException{"_id is empty"};
-  }
-
+  ls::std::core::EmptyStringArgumentEvaluator{_id, "event manager id is empty!"}.evaluate();
   this->id = _id;
 }

+ 10 - 35
source/ls-std/event/EventManager.cpp

@@ -3,13 +3,14 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-27
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
+#include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp>
+#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
 #include <ls-std/core/exception/EventNotHandledException.hpp>
 #include <ls-std/core/exception/EventNotSubscribedException.hpp>
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
 #include <ls-std/event/EventManager.hpp>
 
 ls::std::event::EventManager::EventManager() : ls::std::core::Class("EventManager")
@@ -19,15 +20,8 @@ ls::std::event::EventManager::~EventManager() = default;
 
 void ls::std::event::EventManager::subscribe(const ls::std::core::type::event_id &_id, const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener)
 {
-  if (_id.empty())
-  {
-    throw ls::std::core::IllegalArgumentException{"_id is empty"};
-  }
-
-  if (_listener == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_listener is null"};
-  }
+  ls::std::core::EmptyStringArgumentEvaluator{_id, "event id is empty and can not be subscribed!"}.evaluate();
+  ls::std::core::NullPointerArgumentEvaluator{_listener, "listener reference for subscribe attempt is null!"}.evaluate();
 
   if (this->_hasEventHandler(_id))
   {
@@ -41,15 +35,8 @@ void ls::std::event::EventManager::subscribe(const ls::std::core::type::event_id
 
 void ls::std::event::EventManager::unsubscribe(const ls::std::core::type::event_id &_id, const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener)
 {
-  if (_id.empty())
-  {
-    throw ls::std::core::IllegalArgumentException{"_id is empty"};
-  }
-
-  if (_listener == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_listener is null"};
-  }
+  ls::std::core::EmptyStringArgumentEvaluator{_id, "event id is empty and can not be unsubscribed!"}.evaluate();
+  ls::std::core::NullPointerArgumentEvaluator{_listener, "listener reference for unsubscribe attempt is null!"}.evaluate();
 
   if (this->_hasEventHandler(_id))
   {
@@ -60,11 +47,7 @@ void ls::std::event::EventManager::unsubscribe(const ls::std::core::type::event_
 bool ls::std::event::EventManager::addEventHandler(const ::std::shared_ptr<ls::std::event::EventHandler> &_eventHandler)
 {
   bool wasAdded{};
-
-  if (_eventHandler == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_eventHandler is null"};
-  }
+  ls::std::core::NullPointerArgumentEvaluator{_eventHandler, "event handler reference for add attempt is null!"}.evaluate();
 
   if (!this->_hasEventHandler(_eventHandler->getId()))
   {
@@ -89,21 +72,13 @@ void ls::std::event::EventManager::fire(ls::std::event::Event _event)
 
 bool ls::std::event::EventManager::hasEventHandler(const ls::std::core::type::event_id &_id)
 {
-  if (_id.empty())
-  {
-    throw ls::std::core::IllegalArgumentException{"_id is empty"};
-  }
-
+  ls::std::core::EmptyStringArgumentEvaluator{_id, "event id is empty and can not be passed!"}.evaluate();
   return this->_hasEventHandler(_id);
 }
 
 bool ls::std::event::EventManager::removeEventHandler(const ::std::shared_ptr<ls::std::event::EventHandler> &_eventHandler)
 {
-  if (_eventHandler == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_eventHandler is null"};
-  }
-
+  ls::std::core::NullPointerArgumentEvaluator{_eventHandler, "event handler reference for remove attempt is null!"}.evaluate();
   return this->_removeEventHandler(_eventHandler);
 }
 

+ 10 - 22
source/ls-std/event/Narrator.cpp

@@ -3,12 +3,12 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-14
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
 #include <algorithm>
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
+#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
 #include <ls-std/event/Narrator.hpp>
 
 ls::std::event::Narrator::Narrator() : ls::std::core::Class("Narrator")
@@ -19,18 +19,12 @@ ls::std::event::Narrator::~Narrator() = default;
 bool ls::std::event::Narrator::addListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener)
 {
   bool wasAdded{};
+  ls::std::core::NullPointerArgumentEvaluator{_listener, "listener reference for add attempt is null!"}.evaluate();
 
-  if (_listener == nullptr)
+  if (!this->_hasListener(_listener))
   {
-    throw ls::std::core::IllegalArgumentException{"_listener is null"};
-  }
-  else
-  {
-    if (!this->_hasListener(_listener))
-    {
-      this->listeners.push_back(_listener);
-      wasAdded = true;
-    }
+    this->listeners.push_back(_listener);
+    wasAdded = true;
   }
 
   return wasAdded;
@@ -49,18 +43,12 @@ void ls::std::event::Narrator::clear()
 bool ls::std::event::Narrator::removeListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener)
 {
   bool wasRemoved{};
+  ls::std::core::NullPointerArgumentEvaluator{_listener, "listener reference for remove attempt is null!"}.evaluate();
 
-  if (_listener == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_listener is null"};
-  }
-  else
+  if (this->_hasListener(_listener))
   {
-    if (this->_hasListener(_listener))
-    {
-      this->listeners.remove(_listener);
-      wasRemoved = true;
-    }
+    this->listeners.remove(_listener);
+    wasRemoved = true;
   }
 
   return wasRemoved;

+ 3 - 7
source/ls-std/event/serialization/SerializableJsonEvent.cpp

@@ -3,11 +3,11 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-12-07
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
+#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
 #include <ls-std/event/serialization/SerializableJsonEvent.hpp>
 
 ls::std::event::SerializableJsonEvent::SerializableJsonEvent(const ::std::shared_ptr<ls::std::event::Event> &_value) : ls::std::core::Class("SerializableJsonEvent")
@@ -43,11 +43,7 @@ void ls::std::event::SerializableJsonEvent::setValue(const ::std::shared_ptr<ls:
 
 void ls::std::event::SerializableJsonEvent::_assignValue(const ::std::shared_ptr<ls::std::event::Event> &_value)
 {
-  if (_value == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_value is null"};
-  }
-
+  ls::std::core::NullPointerArgumentEvaluator{_value, "event reference for serialization attempt is null!"}.evaluate();
   this->value = _value;
 }
 

+ 3 - 6
source/ls-std/io/kv/KvFileReader.cpp

@@ -3,10 +3,11 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-12-25
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
+#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
 #include <ls-std/core/exception/IllegalArgumentException.hpp>
 #include <ls-std/io/FileReader.hpp>
 #include <ls-std/io/kv/KvFileReader.hpp>
@@ -45,11 +46,7 @@ void ls::std::io::KvFileReader::setFile(const ls::std::io::File &_kvFile)
 
 void ls::std::io::KvFileReader::_assignDocument(const ::std::shared_ptr<ls::std::io::KvDocument> &_document)
 {
-  if (_document == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_document is null"};
-  }
-
+  ls::std::core::NullPointerArgumentEvaluator{_document, "passed document reference is null!"}.evaluate();
   this->document = _document;
 }
 

+ 3 - 7
source/ls-std/io/kv/KvPair.cpp

@@ -3,11 +3,11 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-12-25
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
+#include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp>
 #include <ls-std/io/kv/KvPair.hpp>
 
 ls::std::io::KvPair::KvPair(const ls::std::core::type::kv_key &_key, ls::std::core::type::kv_value _value) : ls::std::core::Class("KvPair"), value(::std::move(_value))
@@ -34,10 +34,6 @@ void ls::std::io::KvPair::setValue(const ls::std::core::type::kv_value &_value)
 
 void ls::std::io::KvPair::_assignKey(const ls::std::core::type::kv_key &_key)
 {
-  if (_key.empty())
-  {
-    throw ls::std::core::IllegalArgumentException{"_key is empty"};
-  }
-
+  ls::std::core::EmptyStringArgumentEvaluator{_key, "key is empty!"}.evaluate();
   this->key = _key;
 }

+ 3 - 7
source/ls-std/io/kv/KvParser.cpp

@@ -3,11 +3,11 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-12-25
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
+#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
 #include <ls-std/io/NewLine.hpp>
 #include <ls-std/io/kv/KvParser.hpp>
 
@@ -35,11 +35,7 @@ void ls::std::io::KvParser::setDocument(const ::std::shared_ptr<ls::std::io::KvD
 
 void ls::std::io::KvParser::_assignDocument(const ::std::shared_ptr<ls::std::io::KvDocument> &_document)
 {
-  if (_document == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_document is null"};
-  }
-
+  ls::std::core::NullPointerArgumentEvaluator{_document, "reference to document is null!"}.evaluate();
   this->document = _document;
 }
 

+ 3 - 7
source/ls-std/io/logging/Logger.cpp

@@ -3,13 +3,13 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-20
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
 #include <ctime>
 #include <iomanip>
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
+#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
 #include <ls-std/io/NewLine.hpp>
 #include <ls-std/io/logging/Logger.hpp>
 #if defined(_MSC_VER) || defined(__APPLE__)
@@ -83,11 +83,7 @@ void ls::std::io::Logger::warn(const ls::std::core::type::byte *_data)
 
 void ls::std::io::Logger::_assignWriter(const ::std::shared_ptr<ls::std::core::interface_type::IWriter> &_writer)
 {
-  if (_writer == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_writer is null"};
-  }
-
+  ls::std::core::NullPointerArgumentEvaluator{_writer, "writer reference is null!"}.evaluate();
   this->writer = _writer;
 }
 

+ 4 - 12
source/ls-std/io/xml/XmlAttribute.cpp

@@ -3,11 +3,11 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-23
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
+#include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp>
 #include <ls-std/io/xml/XmlAttribute.hpp>
 
 ls::std::io::XmlAttribute::XmlAttribute(const ::std::string &_name) : ls::std::core::Class("XmlAttribute")
@@ -44,20 +44,12 @@ void ls::std::io::XmlAttribute::setValue(const ::std::string &_value)
 
 void ls::std::io::XmlAttribute::_assignName(const ::std::string &_name)
 {
-  if (_name.empty())
-  {
-    throw ls::std::core::IllegalArgumentException{"_name is empty"};
-  }
-
+  ls::std::core::EmptyStringArgumentEvaluator{_name, "xml attribute name is empty!"}.evaluate();
   this->name = _name;
 }
 
 void ls::std::io::XmlAttribute::_assignValue(const ::std::string &_value)
 {
-  if (_value.empty())
-  {
-    throw ls::std::core::IllegalArgumentException{"_value is empty"};
-  }
-
+  ls::std::core::EmptyStringArgumentEvaluator{_value, "xml attribute value is empty!"}.evaluate();
   this->value = _value;
 }

+ 4 - 12
source/ls-std/io/xml/XmlDocument.cpp

@@ -3,11 +3,11 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-30
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
+#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
 #include <ls-std/io/xml/XmlDocument.hpp>
 
 ls::std::io::XmlDocument::XmlDocument() : ls::std::core::Class("XmlDocument")
@@ -54,20 +54,12 @@ void ls::std::io::XmlDocument::setRootElement(const ::std::shared_ptr<ls::std::i
 
 void ls::std::io::XmlDocument::_assignDeclaration(const ::std::shared_ptr<ls::std::io::XmlDeclaration> &_declaration)
 {
-  if (_declaration == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_declaration is null"};
-  }
-
+  ls::std::core::NullPointerArgumentEvaluator{_declaration, "xml declaration reference is null!"}.evaluate();
   this->declaration = _declaration;
 }
 
 void ls::std::io::XmlDocument::_assignRootElement(const ::std::shared_ptr<ls::std::io::XmlNode> &_rootElement)
 {
-  if (_rootElement == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_rootElement is null"};
-  }
-
+  ls::std::core::NullPointerArgumentEvaluator{_rootElement, "xml root node reference is null!"}.evaluate();
   this->rootElement = _rootElement;
 }

+ 29 - 71
source/ls-std/io/xml/XmlNode.cpp

@@ -3,12 +3,13 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-24
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
 #include <algorithm>
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
+#include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp>
+#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
 #include <ls-std/io/xml/XmlNode.hpp>
 
 ls::std::io::XmlNode::XmlNode(::std::string _name) : ls::std::core::Class("XmlNode"), name(::std::move(_name))
@@ -20,8 +21,8 @@ bool ls::std::io::XmlNode::addAttributeAfter(const ::std::shared_ptr<ls::std::io
 {
   bool added{};
   auto iterator = this->attributes.begin();
-  _checkIfAttributeReferenceIsValid(_attribute);
-  _checkIfNameIsNotEmpty(_name);
+  ls::std::core::NullPointerArgumentEvaluator{_attribute, "passed attribute reference for add attempt is null!"}.evaluate();
+  ls::std::core::EmptyStringArgumentEvaluator{_name, "xml node name is empty!"}.evaluate();
 
   if (!this->_hasAttribute(_attribute->getName()))
   {
@@ -46,8 +47,8 @@ bool ls::std::io::XmlNode::addAttributeBefore(const ::std::shared_ptr<ls::std::i
 {
   bool added{};
   auto iterator = this->attributes.begin();
-  _checkIfAttributeReferenceIsValid(_attribute);
-  _checkIfNameIsNotEmpty(_name);
+  ls::std::core::NullPointerArgumentEvaluator{_attribute, "passed attribute reference for add attempt is null!"}.evaluate();
+  ls::std::core::EmptyStringArgumentEvaluator{_name, "xml node name is empty!"}.evaluate();
 
   if (!this->_hasAttribute(_attribute->getName()))
   {
@@ -70,7 +71,8 @@ bool ls::std::io::XmlNode::addAttributeBefore(const ::std::shared_ptr<ls::std::i
 bool ls::std::io::XmlNode::addAttributeToBeginning(const ::std::shared_ptr<ls::std::io::XmlAttribute> &_attribute)
 {
   bool added{};
-  _checkIfAttributeReferenceIsValid(_attribute);
+  ls::std::core::NullPointerArgumentEvaluator{_attribute, "passed attribute reference for add attempt is null!"}.evaluate();
+  ;
 
   if (!_hasAttribute(_attribute->getName()))
   {
@@ -84,7 +86,7 @@ bool ls::std::io::XmlNode::addAttributeToBeginning(const ::std::shared_ptr<ls::s
 bool ls::std::io::XmlNode::addAttributeToEnd(const ::std::shared_ptr<ls::std::io::XmlAttribute> &_attribute)
 {
   bool added{};
-  _checkIfAttributeReferenceIsValid(_attribute);
+  ls::std::core::NullPointerArgumentEvaluator{_attribute, "passed attribute reference for add attempt is null!"}.evaluate();
 
   if (!_hasAttribute(_attribute->getName()))
   {
@@ -99,8 +101,8 @@ bool ls::std::io::XmlNode::addChildAfter(const ::std::shared_ptr<ls::std::io::Xm
 {
   bool added{};
   auto iterator = this->children.begin();
-  _checkIfNodeReferenceIsValid(_child);
-  _checkIfNodeReferenceIsValid(_search);
+  ls::std::core::NullPointerArgumentEvaluator{_child, "passed child node reference for add attempt is null!"}.evaluate();
+  ls::std::core::NullPointerArgumentEvaluator{_search, "passed search node reference for add attempt is null!"}.evaluate();
 
   if (!this->_hasChild(_child))
   {
@@ -125,8 +127,8 @@ bool ls::std::io::XmlNode::addChildBefore(const ::std::shared_ptr<ls::std::io::X
 {
   bool added{};
   auto iterator = this->children.begin();
-  _checkIfNodeReferenceIsValid(_child);
-  _checkIfNodeReferenceIsValid(_search);
+  ls::std::core::NullPointerArgumentEvaluator{_child, "passed child node reference for add attempt is null!"}.evaluate();
+  ls::std::core::NullPointerArgumentEvaluator{_search, "passed search node reference for add attempt is null!"}.evaluate();
 
   if (!this->_hasChild(_child))
   {
@@ -149,7 +151,7 @@ bool ls::std::io::XmlNode::addChildBefore(const ::std::shared_ptr<ls::std::io::X
 bool ls::std::io::XmlNode::addChildToBeginning(const ::std::shared_ptr<ls::std::io::XmlNode> &_child)
 {
   bool added{};
-  _checkIfNodeReferenceIsValid(_child);
+  ls::std::core::NullPointerArgumentEvaluator{_child, "passed child node reference for add attempt is null!"}.evaluate();
 
   if (!this->_hasChild(_child))
   {
@@ -163,7 +165,7 @@ bool ls::std::io::XmlNode::addChildToBeginning(const ::std::shared_ptr<ls::std::
 bool ls::std::io::XmlNode::addChildToEnd(const ::std::shared_ptr<ls::std::io::XmlNode> &_child)
 {
   bool added{};
-  _checkIfNodeReferenceIsValid(_child);
+  ls::std::core::NullPointerArgumentEvaluator{_child, "passed child node reference for add attempt is null!"}.evaluate();
 
   if (!this->_hasChild(_child))
   {
@@ -310,48 +312,16 @@ std::string ls::std::io::XmlNode::_toXml_(uint8_t _tabSize)
 
 void ls::std::io::XmlNode::_assignName(const ::std::string &_name)
 {
-  if (_name.empty())
-  {
-    throw ls::std::core::IllegalArgumentException{"_name is empty"};
-  }
-
+  ls::std::core::EmptyStringArgumentEvaluator{_name, "xml node name is empty!"}.evaluate();
   this->name = _name;
 }
 
 void ls::std::io::XmlNode::_assignValue(const ::std::string &_value)
 {
-  if (_value.empty())
-  {
-    throw ls::std::core::IllegalArgumentException{"_value is empty"};
-  }
-
+  ls::std::core::EmptyStringArgumentEvaluator{_value, "xml node value is empty!"}.evaluate();
   this->value = _value;
 }
 
-void ls::std::io::XmlNode::_checkIfAttributeReferenceIsValid(const ::std::shared_ptr<ls::std::io::XmlAttribute> &_attribute)
-{
-  if (_attribute == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_attribute is null"};
-  }
-}
-
-void ls::std::io::XmlNode::_checkIfNameIsNotEmpty(const ::std::string &_name)
-{
-  if (_name.empty())
-  {
-    throw ls::std::core::IllegalArgumentException{"_name is empty"};
-  }
-}
-
-void ls::std::io::XmlNode::_checkIfNodeReferenceIsValid(const ::std::shared_ptr<ls::std::io::XmlNode> &_child)
-{
-  if (_child == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_child is null"};
-  }
-}
-
 std::string ls::std::io::XmlNode::_getTab(uint8_t _tabSize)
 {
   ::std::string tab{};
@@ -367,20 +337,14 @@ std::string ls::std::io::XmlNode::_getTab(uint8_t _tabSize)
 bool ls::std::io::XmlNode::_hasAttribute(const ::std::string &_name)
 {
   bool exists{};
+  ls::std::core::EmptyStringArgumentEvaluator{_name, "xml attribute name is empty!"}.evaluate();
 
-  if (_name.empty())
+  for (const auto &attribute : this->attributes)
   {
-    throw ls::std::core::IllegalArgumentException{"_name is empty"};
-  }
-  else
-  {
-    for (const auto &attribute : this->attributes)
+    if (attribute->getName() == _name)
     {
-      if (attribute->getName() == _name)
-      {
-        exists = true;
-        break;
-      }
+      exists = true;
+      break;
     }
   }
 
@@ -389,27 +353,21 @@ bool ls::std::io::XmlNode::_hasAttribute(const ::std::string &_name)
 
 bool ls::std::io::XmlNode::_hasChild(const ::std::shared_ptr<ls::std::io::XmlNode> &_child)
 {
-  _checkIfNodeReferenceIsValid(_child);
+  ls::std::core::NullPointerArgumentEvaluator{_child, "passed child node reference for check attempt is null!"}.evaluate();
   return ::std::find(this->children.begin(), this->children.end(), _child) != this->children.end();
 }
 
 bool ls::std::io::XmlNode::_hasChild(const ::std::string &_name)
 {
   bool exists{};
+  ls::std::core::EmptyStringArgumentEvaluator{_name, "xml child node name is empty!"}.evaluate();
 
-  if (_name.empty())
-  {
-    throw ls::std::core::IllegalArgumentException{"_name is empty"};
-  }
-  else
+  for (const auto &attribute : this->children)
   {
-    for (const auto &attribute : this->children)
+    if (attribute->getName() == _name)
     {
-      if (attribute->getName() == _name)
-      {
-        exists = true;
-        break;
-      }
+      exists = true;
+      break;
     }
   }
 

+ 3 - 7
source/ls-std/io/xml/XmlParseParameter.cpp

@@ -3,11 +3,11 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-02-05
-* Changed:         2023-02-07
+* Changed:         2023-02-08
 *
 * */
 
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
+#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
 #include <ls-std/io/xml/XmlParseParameter.hpp>
 
 ls::std::io::XmlParseParameter::XmlParseParameter() = default;
@@ -36,10 +36,6 @@ void ls::std::io::XmlParseParameter::setNode(const ::std::shared_ptr<ls::std::io
 
 void ls::std::io::XmlParseParameter::_setNode(const ::std::shared_ptr<ls::std::io::XmlNode> &_node)
 {
-  if (_node == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_node is null"};
-  }
-
+  ls::std::core::NullPointerArgumentEvaluator{_node, "passed node reference is null!"}.evaluate();
   this->node = _node;
 }

+ 3 - 7
source/ls-std/io/xml/XmlParser.cpp

@@ -3,11 +3,11 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-26
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
-#include <ls-std/core/exception/IllegalArgumentException.hpp>
+#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
 #include <ls-std/io/xml/XmlParser.hpp>
 
 ls::std::io::XmlParser::XmlParser(const ::std::shared_ptr<ls::std::io::XmlDocument> &_document) : ls::std::core::Class("XmlParser")
@@ -55,11 +55,7 @@ void ls::std::io::XmlParser::_analyze(const ls::std::core::type::byte_field &_da
 
 void ls::std::io::XmlParser::_assignDocument(const ::std::shared_ptr<ls::std::io::XmlDocument> &_document)
 {
-  if (_document == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_document is null"};
-  }
-
+  ls::std::core::NullPointerArgumentEvaluator{_document, "passed document reference is null!"}.evaluate();
   this->document = _document;
 }
 

+ 3 - 6
source/ls-std/io/xml/XmlReader.cpp

@@ -3,10 +3,11 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-10-10
- * Changed:         2023-02-07
+ * Changed:         2023-02-08
  *
  * */
 
+#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
 #include <ls-std/core/exception/IllegalArgumentException.hpp>
 #include <ls-std/io/FileReader.hpp>
 #include <ls-std/io/xml/XmlParser.hpp>
@@ -45,11 +46,7 @@ void ls::std::io::XmlReader::setFile(const ls::std::io::File &_xmlFile)
 
 void ls::std::io::XmlReader::_assignDocument(const ::std::shared_ptr<ls::std::io::XmlDocument> &_document)
 {
-  if (_document == nullptr)
-  {
-    throw ls::std::core::IllegalArgumentException{"_document is null"};
-  }
-
+  ls::std::core::NullPointerArgumentEvaluator{_document, "xml document reference is null!"}.evaluate();
   this->document = _document;
 }
 

+ 68 - 0
test/cases/core/evaluator/EmptyStringArgumentEvaluatorTest.cpp

@@ -0,0 +1,68 @@
+/*
+* Author:          Patrick-Christopher Mattulat
+* Company:         Lynar Studios
+* E-Mail:          webmaster@lynarstudios.com
+* Created:         2023-02-08
+* Changed:         2023-02-08
+*
+* */
+
+#include <gtest/gtest.h>
+#include <ls-std/ls-std-core.hpp>
+#include <string>
+
+using namespace ls::std::core;
+using namespace ::std;
+
+namespace
+{
+  class EmptyStringArgumentEvaluatorTest : public ::testing::Test
+  {
+    protected:
+
+      EmptyStringArgumentEvaluatorTest() = default;
+      ~EmptyStringArgumentEvaluatorTest() override = default;
+
+      void SetUp() override
+      {}
+
+      void TearDown() override
+      {}
+  };
+
+  TEST_F(EmptyStringArgumentEvaluatorTest, evaluate)
+  {
+    EXPECT_THROW(
+        {
+          try
+          {
+            EmptyStringArgumentEvaluator{""}.evaluate();
+          }
+          catch (const IllegalArgumentException &_exception)
+          {
+            string message = _exception.what();
+            ASSERT_STREQ("IllegalArgumentException thrown - passed argument is empty!", message.c_str());
+            throw;
+          }
+        },
+        IllegalArgumentException);
+  }
+
+  TEST_F(EmptyStringArgumentEvaluatorTest, evaluate_dedicated_message)
+  {
+    EXPECT_THROW(
+        {
+          try
+          {
+            EmptyStringArgumentEvaluator("", "this id is empty!").evaluate();
+          }
+          catch (const IllegalArgumentException &_exception)
+          {
+            string message = _exception.what();
+            ASSERT_STREQ("IllegalArgumentException thrown - this id is empty!", message.c_str());
+            throw;
+          }
+        },
+        IllegalArgumentException);
+  }
+}

+ 68 - 0
test/cases/core/evaluator/NullPointerArgumentEvaluatorTest.cpp

@@ -0,0 +1,68 @@
+/*
+* Author:          Patrick-Christopher Mattulat
+* Company:         Lynar Studios
+* E-Mail:          webmaster@lynarstudios.com
+* Created:         2023-02-08
+* Changed:         2023-02-08
+*
+* */
+
+#include <gtest/gtest.h>
+#include <ls-std/ls-std-core.hpp>
+#include <string>
+
+using namespace ls::std::core;
+using namespace ::std;
+
+namespace
+{
+  class NullPointerArgumentEvaluatorTest : public ::testing::Test
+  {
+    protected:
+
+      NullPointerArgumentEvaluatorTest() = default;
+      ~NullPointerArgumentEvaluatorTest() override = default;
+
+      void SetUp() override
+      {}
+
+      void TearDown() override
+      {}
+  };
+
+  TEST_F(NullPointerArgumentEvaluatorTest, evaluate)
+  {
+    EXPECT_THROW(
+        {
+          try
+          {
+            NullPointerArgumentEvaluator{nullptr}.evaluate();
+          }
+          catch (const IllegalArgumentException &_exception)
+          {
+            string message = _exception.what();
+            ASSERT_STREQ("IllegalArgumentException thrown - passed argument is null!", message.c_str());
+            throw;
+          }
+        },
+        IllegalArgumentException);
+  }
+
+  TEST_F(NullPointerArgumentEvaluatorTest, evaluate_dedicated_message)
+  {
+    EXPECT_THROW(
+        {
+          try
+          {
+            NullPointerArgumentEvaluator(nullptr, "this reference is null!").evaluate();
+          }
+          catch (const IllegalArgumentException &_exception)
+          {
+            string message = _exception.what();
+            ASSERT_STREQ("IllegalArgumentException thrown - this reference is null!", message.c_str());
+            throw;
+          }
+        },
+        IllegalArgumentException);
+  }
+}

+ 68 - 0
test/cases/core/evaluator/NullPointerEvaluatorTest.cpp

@@ -0,0 +1,68 @@
+/*
+* Author:          Patrick-Christopher Mattulat
+* Company:         Lynar Studios
+* E-Mail:          webmaster@lynarstudios.com
+* Created:         2023-02-08
+* Changed:         2023-02-08
+*
+* */
+
+#include <gtest/gtest.h>
+#include <ls-std/ls-std-core.hpp>
+#include <string>
+
+using namespace ls::std::core;
+using namespace ::std;
+
+namespace
+{
+  class NullPointerArgumentTest : public ::testing::Test
+  {
+    protected:
+
+      NullPointerArgumentTest() = default;
+      ~NullPointerArgumentTest() override = default;
+
+      void SetUp() override
+      {}
+
+      void TearDown() override
+      {}
+  };
+
+  TEST_F(NullPointerArgumentTest, evaluate)
+  {
+    EXPECT_THROW(
+        {
+          try
+          {
+            NullPointerEvaluator{nullptr}.evaluate();
+          }
+          catch (const NullPointerException &_exception)
+          {
+            string message = _exception.what();
+            ASSERT_STREQ("NullPointerException thrown - reference in use is null!", message.c_str());
+            throw;
+          }
+        },
+        NullPointerException);
+  }
+
+  TEST_F(NullPointerArgumentTest, evaluate_dedicated_message)
+  {
+    EXPECT_THROW(
+        {
+          try
+          {
+            NullPointerEvaluator(nullptr, "this reference is not set and causes this exception!").evaluate();
+          }
+          catch (const NullPointerException &_exception)
+          {
+            string message = _exception.what();
+            ASSERT_STREQ("NullPointerException thrown - this reference is not set and causes this exception!", message.c_str());
+            throw;
+          }
+        },
+        NullPointerException);
+  }
+}