summaryrefslogtreecommitdiff
path: root/project2/xml/mutators/rename.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/xml/mutators/rename.cpp')
-rw-r--r--project2/xml/mutators/rename.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/project2/xml/mutators/rename.cpp b/project2/xml/mutators/rename.cpp
new file mode 100644
index 0000000..ceb7627
--- /dev/null
+++ b/project2/xml/mutators/rename.cpp
@@ -0,0 +1,25 @@
+#include "../pch.hpp"
+#include "../xmlPresenter.h"
+
+class Rename : public XmlDocMutator {
+ public:
+ Rename(ScriptNodePtr s) :
+ XmlDocMutator(s),
+ xpath(s, "xpath"),
+ newname(s, "newname")
+ {
+ }
+ void mutateElement(xmlpp::Element * root) const
+ {
+ BOOST_FOREACH(xmlpp::Node * e, root->find(xpath())) {
+ e->set_name(newname());
+ }
+ }
+ Variable xpath;
+ Variable newname;
+};
+
+DECLARE_GENERIC_LOADER("rename", XmlDocMutatorLoader, Rename);
+
+
+