|
@@ -3,11 +3,12 @@
|
|
|
* Company: Lynar Studios
|
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
|
* Created: 2020-09-30
|
|
|
- * Changed: 2021-05-02
|
|
|
+ * Changed: 2021-07-16
|
|
|
*
|
|
|
* */
|
|
|
|
|
|
#include <ls_std/io/xml/XmlDocument.hpp>
|
|
|
+#include <ls_std/exception/IllegalArgumentException.hpp>
|
|
|
|
|
|
ls_std::XmlDocument::XmlDocument() : ls_std::Class("XmlDocument")
|
|
|
{}
|
|
@@ -24,12 +25,12 @@ std::shared_ptr<ls_std::XmlNode> ls_std::XmlDocument::getRootElement()
|
|
|
|
|
|
void ls_std::XmlDocument::setDeclaration(const std::shared_ptr<ls_std::XmlDeclaration> &_declaration)
|
|
|
{
|
|
|
- this->declaration = _declaration;
|
|
|
+ this->_assignDeclaration(_declaration);
|
|
|
}
|
|
|
|
|
|
-void ls_std::XmlDocument::setRootElement(const std::shared_ptr<ls_std::XmlNode> &_root)
|
|
|
+void ls_std::XmlDocument::setRootElement(const std::shared_ptr<ls_std::XmlNode> &_rootElement)
|
|
|
{
|
|
|
- this->rootElement = _root;
|
|
|
+ this->_assignRootElement(_rootElement);
|
|
|
}
|
|
|
|
|
|
std::string ls_std::XmlDocument::toXml()
|
|
@@ -48,3 +49,23 @@ std::string ls_std::XmlDocument::toXml()
|
|
|
|
|
|
return xmlString + this->rootElement->toXml();
|
|
|
}
|
|
|
+
|
|
|
+void ls_std::XmlDocument::_assignDeclaration(const std::shared_ptr<ls_std::XmlDeclaration> &_declaration)
|
|
|
+{
|
|
|
+ if (_declaration == nullptr)
|
|
|
+ {
|
|
|
+ throw ls_std::IllegalArgumentException{};
|
|
|
+ }
|
|
|
+
|
|
|
+ this->declaration = _declaration;
|
|
|
+}
|
|
|
+
|
|
|
+void ls_std::XmlDocument::_assignRootElement(const std::shared_ptr<ls_std::XmlNode> &_rootElement)
|
|
|
+{
|
|
|
+ if (_rootElement == nullptr)
|
|
|
+ {
|
|
|
+ throw ls_std::IllegalArgumentException{};
|
|
|
+ }
|
|
|
+
|
|
|
+ this->rootElement = _rootElement;
|
|
|
+}
|