mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 05:35:07 +00:00
LibManual: Fix const-correctness issues
This commit is contained in:
parent
f11899f885
commit
dbcf2f2dd4
8 changed files with 18 additions and 18 deletions
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace Manual {
|
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)
|
if (query_parameters.size() > 2)
|
||||||
return Error::from_string_literal("Queries longer than 2 strings are not supported yet");
|
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");
|
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")
|
if (url.host() != "man")
|
||||||
return Error::from_string_view("Bad help operation"sv);
|
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)
|
if (section_number > number_of_sections)
|
||||||
return Error::from_string_view("Section number out of bounds"sv);
|
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()) {
|
while (!paths.is_empty()) {
|
||||||
auto next_path_segment = TRY(String::from_deprecated_string(paths.take_first()));
|
auto next_path_segment = TRY(String::from_deprecated_string(paths.take_first()));
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Node : public RefCounted<Node> {
|
||||||
public:
|
public:
|
||||||
virtual ~Node() = default;
|
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 Node const* parent() const = 0;
|
||||||
virtual ErrorOr<String> name() const = 0;
|
virtual ErrorOr<String> name() const = 0;
|
||||||
virtual bool is_page() const { return false; }
|
virtual bool is_page() const { return false; }
|
||||||
|
@ -33,11 +33,11 @@ public:
|
||||||
// [page] (no second argument) - will find first section with that page
|
// [page] (no second argument) - will find first section with that page
|
||||||
// [section] [page]
|
// [section] [page]
|
||||||
// Help can also (externally) handle search queries, which is not possible (yet) in man.
|
// 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.
|
// Finds a page via the help://man/<number>/<subsections...>/page URLs.
|
||||||
// This will automatically start discovering pages by inspecting the filesystem.
|
// 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&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,9 @@ Node const* PageNode::parent() const
|
||||||
return m_section.ptr();
|
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();
|
return empty_vector.span();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,13 @@ class PageNode : public Node {
|
||||||
public:
|
public:
|
||||||
virtual ~PageNode() override = default;
|
virtual ~PageNode() override = default;
|
||||||
|
|
||||||
PageNode(NonnullRefPtr<SectionNode> section, String page)
|
PageNode(NonnullRefPtr<SectionNode const> section, String page)
|
||||||
: m_section(move(section))
|
: m_section(move(section))
|
||||||
, m_page(move(page))
|
, 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 Node const* parent() const override;
|
||||||
virtual ErrorOr<String> name() const override { return m_page; };
|
virtual ErrorOr<String> name() const override { return m_page; };
|
||||||
virtual bool is_page() const override { return true; }
|
virtual bool is_page() const override { return true; }
|
||||||
|
@ -34,7 +34,7 @@ public:
|
||||||
static ErrorOr<NonnullRefPtr<PageNode>> help_index_page();
|
static ErrorOr<NonnullRefPtr<PageNode>> help_index_page();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NonnullRefPtr<SectionNode> m_section;
|
NonnullRefPtr<SectionNode const> m_section;
|
||||||
String m_page;
|
String m_page;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ ErrorOr<void> SectionNode::reify_if_needed() const
|
||||||
Core::DirIterator dir_iter { own_path.to_deprecated_string(), Core::DirIterator::Flags::SkipDots };
|
Core::DirIterator dir_iter { own_path.to_deprecated_string(), Core::DirIterator::Flags::SkipDots };
|
||||||
|
|
||||||
struct Child {
|
struct Child {
|
||||||
NonnullRefPtr<Node> node;
|
NonnullRefPtr<Node const> node;
|
||||||
String name_for_sorting;
|
String name_for_sorting;
|
||||||
};
|
};
|
||||||
Vector<Child> children;
|
Vector<Child> children;
|
||||||
|
|
|
@ -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());
|
TRY(reify_if_needed());
|
||||||
return m_children.span();
|
return m_children.span();
|
||||||
|
@ -48,7 +48,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
ErrorOr<void> reify_if_needed() const;
|
ErrorOr<void> reify_if_needed() const;
|
||||||
|
|
||||||
mutable NonnullRefPtrVector<Node> m_children;
|
mutable NonnullRefPtrVector<Node const> m_children;
|
||||||
mutable bool m_reified { false };
|
mutable bool m_reified { false };
|
||||||
bool m_open { false };
|
bool m_open { false };
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
namespace Manual {
|
namespace Manual {
|
||||||
|
|
||||||
SubsectionNode::SubsectionNode(NonnullRefPtr<SectionNode> parent, StringView name)
|
SubsectionNode::SubsectionNode(NonnullRefPtr<SectionNode const> parent, StringView name)
|
||||||
: SectionNode(name, name)
|
: SectionNode(name, name)
|
||||||
, m_parent(move(parent))
|
, m_parent(move(parent))
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ PageNode const* SubsectionNode::document() const
|
||||||
if (sibling_name.is_error())
|
if (sibling_name.is_error())
|
||||||
continue;
|
continue;
|
||||||
if (sibling_name.value() == m_name && is<PageNode>(*sibling))
|
if (sibling_name.value() == m_name && is<PageNode>(*sibling))
|
||||||
return static_cast<PageNode*>(&*sibling);
|
return static_cast<PageNode const*>(&*sibling);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Manual {
|
||||||
// A non-toplevel (i.e. not numbered) manual section.
|
// A non-toplevel (i.e. not numbered) manual section.
|
||||||
class SubsectionNode : public SectionNode {
|
class SubsectionNode : public SectionNode {
|
||||||
public:
|
public:
|
||||||
SubsectionNode(NonnullRefPtr<SectionNode> parent, StringView name);
|
SubsectionNode(NonnullRefPtr<SectionNode const> parent, StringView name);
|
||||||
virtual ~SubsectionNode() = default;
|
virtual ~SubsectionNode() = default;
|
||||||
|
|
||||||
virtual Node const* parent() const override;
|
virtual Node const* parent() const override;
|
||||||
|
@ -22,7 +22,7 @@ public:
|
||||||
virtual PageNode const* document() const override;
|
virtual PageNode const* document() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NonnullRefPtr<SectionNode> m_parent;
|
NonnullRefPtr<SectionNode const> m_parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue