Commit 959291af authored by louiz’'s avatar louiz’

Set the parent of a node passed to add_child, and return it for conveniance

parent 12a18ca7
......@@ -152,15 +152,17 @@ XmlNode* XmlNode::get_child(const std::string& name) const
return nullptr;
void XmlNode::add_child(XmlNode* child)
XmlNode* XmlNode::add_child(XmlNode* child)
child->parent = this;
return child;
void XmlNode::add_child(XmlNode&& child)
XmlNode* XmlNode::add_child(XmlNode&& child)
XmlNode* new_node = new XmlNode(std::move(child));
return this->add_child(new_node);
XmlNode* XmlNode::get_last_child() const
......@@ -77,8 +77,15 @@ public:
* Get a pointer to the first child element with that name
XmlNode* get_child(const std::string& name) const;
void add_child(XmlNode* child);
void add_child(XmlNode&& child);
* Add a node child to this node. Assign this node to the child’s parent.
* Returns a pointer to the newly added child.
XmlNode* add_child(XmlNode* child);
XmlNode* add_child(XmlNode&& child);
* Returns the last of the children
XmlNode* get_last_child() const;
* Mark this node as closed, nothing else
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment