diff options
author | Andreas Kling <kling@serenityos.org> | 2023-02-20 18:59:53 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-21 00:54:04 +0100 |
commit | dbcf2f2dd40e101ea2c90c965c68302b6ea287cd (patch) | |
tree | a180e20f49fc3eaa840bfdf8f9fecaa77b1c734a | |
parent | f11899f885c18390fa17aebe1ef77b733a81fcaf (diff) | |
download | serenity-dbcf2f2dd40e101ea2c90c965c68302b6ea287cd.zip |
LibManual: Fix const-correctness issues
-rw-r--r-- | Userland/Libraries/LibManual/Node.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibManual/Node.h | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibManual/PageNode.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibManual/PageNode.h | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibManual/SectionNode.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibManual/SectionNode.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibManual/SubsectionNode.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibManual/SubsectionNode.h | 4 |
8 files changed, 18 insertions, 18 deletions
diff --git a/Userland/Libraries/LibManual/Node.cpp b/Userland/Libraries/LibManual/Node.cpp index a3c3805623..bfc11d55b4 100644 --- a/Userland/Libraries/LibManual/Node.cpp +++ b/Userland/Libraries/LibManual/Node.cpp @@ -17,7 +17,7 @@ namespace Manual { -ErrorOr<NonnullRefPtr<PageNode>> Node::try_create_from_query(Vector<StringView, 2> const& query_parameters) +ErrorOr<NonnullRefPtr<PageNode const>> Node::try_create_from_query(Vector<StringView, 2> const& query_parameters) { if (query_parameters.size() > 2) return Error::from_string_literal("Queries longer than 2 strings are not supported yet"); @@ -66,7 +66,7 @@ ErrorOr<NonnullRefPtr<PageNode>> Node::try_create_from_query(Vector<StringView, return Error::from_string_literal("Page doesn't exist in section"); } -ErrorOr<NonnullRefPtr<Node>> Node::try_find_from_help_url(URL const& url) +ErrorOr<NonnullRefPtr<Node const>> Node::try_find_from_help_url(URL const& url) { if (url.host() != "man") return Error::from_string_view("Bad help operation"sv); @@ -82,7 +82,7 @@ ErrorOr<NonnullRefPtr<Node>> Node::try_find_from_help_url(URL const& url) if (section_number > number_of_sections) return Error::from_string_view("Section number out of bounds"sv); - NonnullRefPtr<Node> current_node = sections[section_number - 1]; + NonnullRefPtr<Node const> current_node = sections[section_number - 1]; while (!paths.is_empty()) { auto next_path_segment = TRY(String::from_deprecated_string(paths.take_first())); diff --git a/Userland/Libraries/LibManual/Node.h b/Userland/Libraries/LibManual/Node.h index 9e1c2aeda1..4b6ee56c35 100644 --- a/Userland/Libraries/LibManual/Node.h +++ b/Userland/Libraries/LibManual/Node.h @@ -20,7 +20,7 @@ class Node : public RefCounted<Node> { public: virtual ~Node() = default; - virtual ErrorOr<Span<NonnullRefPtr<Node>>> children() const = 0; + virtual ErrorOr<Span<NonnullRefPtr<Node const>>> children() const = 0; virtual Node const* parent() const = 0; virtual ErrorOr<String> name() const = 0; virtual bool is_page() const { return false; } @@ -33,11 +33,11 @@ public: // [page] (no second argument) - will find first section with that page // [section] [page] // Help can also (externally) handle search queries, which is not possible (yet) in man. - static ErrorOr<NonnullRefPtr<PageNode>> try_create_from_query(Vector<StringView, 2> const& query_parameters); + static ErrorOr<NonnullRefPtr<PageNode const>> try_create_from_query(Vector<StringView, 2> const& query_parameters); // Finds a page via the help://man/<number>/<subsections...>/page URLs. // This will automatically start discovering pages by inspecting the filesystem. - static ErrorOr<NonnullRefPtr<Node>> try_find_from_help_url(URL const&); + static ErrorOr<NonnullRefPtr<Node const>> try_find_from_help_url(URL const&); }; } diff --git a/Userland/Libraries/LibManual/PageNode.cpp b/Userland/Libraries/LibManual/PageNode.cpp index 398eedb53c..ceb2ee04bb 100644 --- a/Userland/Libraries/LibManual/PageNode.cpp +++ b/Userland/Libraries/LibManual/PageNode.cpp @@ -16,9 +16,9 @@ Node const* PageNode::parent() const return m_section.ptr(); } -ErrorOr<Span<NonnullRefPtr<Node>>> PageNode::children() const +ErrorOr<Span<NonnullRefPtr<Node const>>> PageNode::children() const { - static NonnullRefPtrVector<Node> empty_vector; + static NonnullRefPtrVector<Node const> empty_vector; return empty_vector.span(); } diff --git a/Userland/Libraries/LibManual/PageNode.h b/Userland/Libraries/LibManual/PageNode.h index 7c48a7dc8d..3f9c1589a5 100644 --- a/Userland/Libraries/LibManual/PageNode.h +++ b/Userland/Libraries/LibManual/PageNode.h @@ -17,13 +17,13 @@ class PageNode : public Node { public: virtual ~PageNode() override = default; - PageNode(NonnullRefPtr<SectionNode> section, String page) + PageNode(NonnullRefPtr<SectionNode const> section, String page) : m_section(move(section)) , m_page(move(page)) { } - virtual ErrorOr<Span<NonnullRefPtr<Node>>> children() const override; + virtual ErrorOr<Span<NonnullRefPtr<Node const>>> children() const override; virtual Node const* parent() const override; virtual ErrorOr<String> name() const override { return m_page; }; virtual bool is_page() const override { return true; } @@ -34,7 +34,7 @@ public: static ErrorOr<NonnullRefPtr<PageNode>> help_index_page(); private: - NonnullRefPtr<SectionNode> m_section; + NonnullRefPtr<SectionNode const> m_section; String m_page; }; diff --git a/Userland/Libraries/LibManual/SectionNode.cpp b/Userland/Libraries/LibManual/SectionNode.cpp index a4077a134d..75db61043b 100644 --- a/Userland/Libraries/LibManual/SectionNode.cpp +++ b/Userland/Libraries/LibManual/SectionNode.cpp @@ -46,7 +46,7 @@ ErrorOr<void> SectionNode::reify_if_needed() const Core::DirIterator dir_iter { own_path.to_deprecated_string(), Core::DirIterator::Flags::SkipDots }; struct Child { - NonnullRefPtr<Node> node; + NonnullRefPtr<Node const> node; String name_for_sorting; }; Vector<Child> children; diff --git a/Userland/Libraries/LibManual/SectionNode.h b/Userland/Libraries/LibManual/SectionNode.h index 4e228799f9..4f405dae31 100644 --- a/Userland/Libraries/LibManual/SectionNode.h +++ b/Userland/Libraries/LibManual/SectionNode.h @@ -23,7 +23,7 @@ public: { } - virtual ErrorOr<Span<NonnullRefPtr<Node>>> children() const override + virtual ErrorOr<Span<NonnullRefPtr<Node const>>> children() const override { TRY(reify_if_needed()); return m_children.span(); @@ -48,7 +48,7 @@ protected: private: ErrorOr<void> reify_if_needed() const; - mutable NonnullRefPtrVector<Node> m_children; + mutable NonnullRefPtrVector<Node const> m_children; mutable bool m_reified { false }; bool m_open { false }; }; diff --git a/Userland/Libraries/LibManual/SubsectionNode.cpp b/Userland/Libraries/LibManual/SubsectionNode.cpp index 18f81d54fe..cb1e6d44fb 100644 --- a/Userland/Libraries/LibManual/SubsectionNode.cpp +++ b/Userland/Libraries/LibManual/SubsectionNode.cpp @@ -10,7 +10,7 @@ namespace Manual { -SubsectionNode::SubsectionNode(NonnullRefPtr<SectionNode> parent, StringView name) +SubsectionNode::SubsectionNode(NonnullRefPtr<SectionNode const> parent, StringView name) : SectionNode(name, name) , m_parent(move(parent)) { @@ -31,7 +31,7 @@ PageNode const* SubsectionNode::document() const if (sibling_name.is_error()) continue; if (sibling_name.value() == m_name && is<PageNode>(*sibling)) - return static_cast<PageNode*>(&*sibling); + return static_cast<PageNode const*>(&*sibling); } return nullptr; } diff --git a/Userland/Libraries/LibManual/SubsectionNode.h b/Userland/Libraries/LibManual/SubsectionNode.h index fec53604dc..93a4334f97 100644 --- a/Userland/Libraries/LibManual/SubsectionNode.h +++ b/Userland/Libraries/LibManual/SubsectionNode.h @@ -13,7 +13,7 @@ namespace Manual { // A non-toplevel (i.e. not numbered) manual section. class SubsectionNode : public SectionNode { public: - SubsectionNode(NonnullRefPtr<SectionNode> parent, StringView name); + SubsectionNode(NonnullRefPtr<SectionNode const> parent, StringView name); virtual ~SubsectionNode() = default; virtual Node const* parent() const override; @@ -22,7 +22,7 @@ public: virtual PageNode const* document() const override; protected: - NonnullRefPtr<SectionNode> m_parent; + NonnullRefPtr<SectionNode const> m_parent; }; } |