Document.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/HashMap.h>
  8. #include <AK/NonnullOwnPtr.h>
  9. #include <LibXML/DOM/DocumentTypeDeclaration.h>
  10. #include <LibXML/DOM/Node.h>
  11. #include <LibXML/Forward.h>
  12. namespace XML {
  13. enum class Version {
  14. Version10,
  15. Version11,
  16. };
  17. struct Doctype {
  18. ByteString type;
  19. Vector<MarkupDeclaration> markup_declarations;
  20. Optional<ExternalID> external_id;
  21. };
  22. class Document {
  23. public:
  24. explicit Document(NonnullOwnPtr<Node> root, Optional<Doctype> doctype, HashMap<Name, ByteString> processing_instructions, Version version)
  25. : m_root(move(root))
  26. , m_processing_instructions(move(processing_instructions))
  27. , m_version(version)
  28. , m_explicit_doctype(move(doctype))
  29. {
  30. }
  31. Node& root() { return *m_root; }
  32. Node const& root() const { return *m_root; }
  33. HashMap<Name, ByteString> const& processing_instructions() const { return m_processing_instructions; }
  34. Version version() const { return m_version; }
  35. Optional<Doctype> const& doctype() const { return m_explicit_doctype; }
  36. private:
  37. NonnullOwnPtr<Node> m_root;
  38. HashMap<Name, ByteString> m_processing_instructions;
  39. Version m_version;
  40. Optional<Doctype> m_explicit_doctype;
  41. };
  42. }