--- /dev/null
+#include <stdio.h>
+
+#include "xml-template.h"
+
+using namespace std;
+
+int main(int argc, char **argv)
+{
+ vector<Directive *> things;
+
+ {
+ unordered_map<string, Directive *> submap;
+ submap.insert(make_pair("li", new Replace("Raindrops on roses")));
+ things.push_back(new Substitute(submap));
+ }
+ {
+ unordered_map<string, Directive *> submap;
+ submap.insert(make_pair("li", new Replace("Whiskers on kittens")));
+ things.push_back(new Substitute(submap));
+ }
+ {
+ unordered_map<string, Directive *> submap;
+ submap.insert(make_pair("li", new Replace("Bright copper kettles")));
+ things.push_back(new Substitute(submap));
+ }
+ {
+ unordered_map<string, Directive *> submap;
+ submap.insert(make_pair("li", new Replace("Warm, woolen mittens")));
+ things.push_back(new Substitute(submap));
+ }
+
+ unordered_map<string, Directive *> master_map;
+ master_map.insert(make_pair("color", new Replace("blue")));
+ master_map.insert(make_pair("#things", new Clone(things)));
+
+ process_file("../xml/clone.xml", argv[1], new Substitute(master_map));
+ return(0);
+}
node->children = xmlNewTextLen(reinterpret_cast<const xmlChar *>(str.data()), str.size());
}
+Clone::Clone(const std::vector<Directive *> &subdirectives)
+ : subdirectives(subdirectives) {}
+
+void Clone::process(xmlNode *node, bool clean) {
+}
+
Substitute::Substitute(const unordered_map<string, Directive*> &substitution_map)
: substitution_map(substitution_map) {}
#include <string>
#include <utility>
#include <unordered_map>
+#include <vector>
class Directive {
public:
const std::string str;
};
+class Clone : public Directive {
+ public:
+ Clone(const std::vector<Directive *> &subdirectives);
+ virtual void process(xmlNode *node, bool clean);
+
+ private:
+ const std::vector<Directive *> subdirectives;
+};
+
class Substitute : public Directive {
public:
Substitute(const std::unordered_map<std::string, Directive*> &substitution_map);