Introduce a XmlSubNode class that automatically adds itself into its parent

This commit is contained in:
louiz’
2016-12-14 18:28:44 +01:00
parent f512c9c666
commit 5a5bb7f632
7 changed files with 509 additions and 595 deletions
+14
View File
@@ -143,4 +143,18 @@ std::ostream& operator<<(std::ostream& os, const XmlNode& node);
*/
using Stanza = XmlNode;
class XmlSubNode: public XmlNode
{
public:
XmlSubNode(XmlNode& parent_ref, const std::string& name):
XmlNode(name),
parent_to_add(parent_ref)
{}
~XmlSubNode()
{
this->parent_to_add.add_child(std::move(*this));
}
private:
XmlNode& parent_to_add;
};