From 98fe35ff0cc0403314b28a18437826dc49db52f5 Mon Sep 17 00:00:00 2001 From: d-led Date: Wed, 3 Oct 2012 18:25:10 +0200 Subject: [PATCH] prototype attribute addition --- contrib/pugilua/pugilua_lib.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/contrib/pugilua/pugilua_lib.cpp b/contrib/pugilua/pugilua_lib.cpp index c058f4a..609e57b 100644 --- a/contrib/pugilua/pugilua_lib.cpp +++ b/contrib/pugilua/pugilua_lib.cpp @@ -42,7 +42,7 @@ namespace pugi { } public: // non-lua interface - pugi::xml_attribute const& get() { + pugi::xml_attribute const& get() const { return att; } @@ -123,6 +123,11 @@ namespace pugi { RefCountedPtr insert_attribute_after(const char* name, RefCountedPtr attr); RefCountedPtr insert_attribute_before(const char* name, RefCountedPtr attr); + RefCountedPtr append_copy(RefCountedPtr proto); + RefCountedPtr prepend_copy(RefCountedPtr proto); + RefCountedPtr insert_copy_after(RefCountedPtr proto, RefCountedPtr attr); + RefCountedPtr insert_copy_before(RefCountedPtr proto, RefCountedPtr attr); + //todo: text() @@ -312,6 +317,22 @@ namespace pugi { return RefCountedPtr(new lxml_attribute(node.insert_attribute_before(name,attr->get()))); } + RefCountedPtr lxml_node::append_copy(RefCountedPtr proto) { + return RefCountedPtr(new lxml_attribute(node.append_copy(proto->get()))); + } + + RefCountedPtr lxml_node::prepend_copy(RefCountedPtr proto) { + return RefCountedPtr(new lxml_attribute(node.prepend_copy(proto->get()))); + } + + RefCountedPtr lxml_node::insert_copy_after(RefCountedPtr proto, RefCountedPtr attr) { + return RefCountedPtr(new lxml_attribute(node.insert_copy_after(proto->get(),attr->get()))); + } + + RefCountedPtr lxml_node::insert_copy_before(RefCountedPtr proto, RefCountedPtr attr) { + return RefCountedPtr(new lxml_attribute(node.insert_copy_before(proto->get(),attr->get()))); + } + /////////////////// RefCountedPtr lxml_document::load_file(char const* path) { return RefCountedPtr(new lxml_parse_result(doc.load_file(path))); @@ -420,6 +441,10 @@ void register_pugilua (lua_State* L) { .addFunction("prepend_attribute",&lxml_node::prepend_attribute) .addFunction("insert_attribute_after",&lxml_node::insert_attribute_after) .addFunction("insert_attribute_before",&lxml_node::insert_attribute_before) + .addFunction("append_copy",&lxml_node::append_copy) + .addFunction("prepend_copy",&lxml_node::prepend_copy) + .addFunction("insert_copy_after",&lxml_node::insert_copy_after) + .addFunction("insert_copy_before",&lxml_node::insert_copy_before) .endClass() .beginClass("xml_document")