#pragma once
#include
class ParentNode : public Node {
public:
void append_child(Retained);
Node* first_child() { return m_first_child; }
Node* last_child() { return m_last_child; }
const Node* first_child() const { return m_first_child; }
const Node* last_child() const { return m_last_child; }
template void for_each_child(F) const;
template void for_each_child(F);
protected:
explicit ParentNode(NodeType type)
: Node(type)
{
}
private:
Node* m_first_child { nullptr };
Node* m_last_child { nullptr };
};
template
inline void ParentNode::for_each_child(Callback callback) const
{
for (auto* node = first_child(); node; node = node->next_sibling())
callback(*node);
}
template
inline void ParentNode::for_each_child(Callback callback)
{
for (auto* node = first_child(); node; node = node->next_sibling())
callback(*node);
}