XMLDocument.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-30
  6. * Changed: 2021-04-23
  7. *
  8. * */
  9. #include <ls_std/io/xml/XMLDocument.hpp>
  10. ls_std::XMLDocument::XMLDocument() : ls_std::Class("XMLDocument")
  11. {}
  12. std::shared_ptr<ls_std::XMLDeclaration> ls_std::XMLDocument::getDeclaration()
  13. {
  14. return this->declaration;
  15. }
  16. std::shared_ptr<ls_std::XMLNode> ls_std::XMLDocument::getRootElement()
  17. {
  18. return this->rootElement;
  19. }
  20. void ls_std::XMLDocument::setDeclaration(const std::shared_ptr<ls_std::XMLDeclaration> &_declaration)
  21. {
  22. this->declaration = _declaration;
  23. }
  24. void ls_std::XMLDocument::setRootElement(const std::shared_ptr<ls_std::XMLNode> &_root)
  25. {
  26. this->rootElement = _root;
  27. }
  28. std::string ls_std::XMLDocument::toXML()
  29. {
  30. std::string xmlString{};
  31. if (this->declaration != nullptr)
  32. {
  33. xmlString = this->declaration->toXML();
  34. if (!xmlString.empty())
  35. {
  36. xmlString += "\n";
  37. }
  38. }
  39. return xmlString + this->rootElement->toXML();
  40. }