/*
 * Author:          Patrick-Christopher Mattulat
 * Co-Author:       Claude Sonnet 4.6 (LLM)
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2020-09-27
 * Changed:         2026-06-23
 *
 * */

#ifndef LS_STD_XML_DOCUMENT_HPP
#define LS_STD_XML_DOCUMENT_HPP

#include "XmlDeclaration.hpp"
#include "XmlNode.hpp"
#include <ls-std/core/Class.hpp>
#include <ls-std/os/dynamic-goal.hpp>
#include <memory>

/*
 * @doc: class(name: 'XmlDocument', package: 'io')
 * @doc: io.XmlDocument.description('This class represents a whole XML document and can be serialized to a whole XML tree.')
 * */

namespace ls::standard::io
{
  class LS_STD_DYNAMIC_GOAL XmlDocument : public ls::standard::core::Class
  {
    public:

      XmlDocument();
      ~XmlDocument() noexcept override;

      [[nodiscard]] ::std::shared_ptr<ls::standard::io::XmlDeclaration> getDeclaration() const;
      [[nodiscard]] ::std::shared_ptr<ls::standard::io::XmlNode> getRootElement() const;
      void setDeclaration(const ::std::shared_ptr<ls::standard::io::XmlDeclaration> &_declaration);
      void setRootElement(const ::std::shared_ptr<ls::standard::io::XmlNode> &_rootElement);
      [[nodiscard]] ::std::string toXml() const;

    private:

      ::std::shared_ptr<ls::standard::io::XmlDeclaration> declaration{};
      ::std::shared_ptr<ls::standard::io::XmlNode> rootElement{};

      void _assignDeclaration(const ::std::shared_ptr<ls::standard::io::XmlDeclaration> &_declaration);
      void _assignRootElement(const ::std::shared_ptr<ls::standard::io::XmlNode> &_rootElement);
  };
}

#endif
