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

This commit is contained in:
Florent Le Coz
2013-11-27 00:37:23 +01:00
parent 12a18ca748
commit 959291afe6
2 changed files with 14 additions and 5 deletions
+5 -3
View File
@@ -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;
this->children.push_back(child);
return child;
}
void XmlNode::add_child(XmlNode&& child)
XmlNode* XmlNode::add_child(XmlNode&& child)
{
XmlNode* new_node = new XmlNode(std::move(child));
this->add_child(new_node);
return this->add_child(new_node);
}
XmlNode* XmlNode::get_last_child() const