XMLDocument.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-30
  6. * Changed: 2020-11-26
  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. xmlString = this->declaration->toXML();
  33. if(!xmlString.empty()) {
  34. xmlString += "\n";
  35. }
  36. }
  37. return xmlString + this->rootElement->toXML();
  38. }