summaryrefslogtreecommitdiff
path: root/project2/xml/mutators/rename.cpp
blob: c8a03b9e177c2404ee879415d0ce1bb1b4d807c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "../pch.hpp"
#include "../xmlPresenter.h"
#include <boost/foreach.hpp>
#include <libxml++/document.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);