SubsectionNode.cpp 750 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "SubsectionNode.h"
  7. #include "PageNode.h"
  8. #include <AK/TypeCasts.h>
  9. namespace Manual {
  10. SubsectionNode::SubsectionNode(NonnullRefPtr<SectionNode const> parent, StringView name, RefPtr<PageNode> page)
  11. : SectionNode(name, name)
  12. , m_parent(move(parent))
  13. , m_page(move(page))
  14. {
  15. }
  16. Node const* SubsectionNode::parent() const { return m_parent; }
  17. PageNode const* SubsectionNode::document() const { return m_page; }
  18. ErrorOr<String> SubsectionNode::name() const { return m_name; }
  19. ErrorOr<String> SubsectionNode::path() const
  20. {
  21. return String::formatted("{}/{}", TRY(m_parent->path()), m_section);
  22. }
  23. }