]> git.sesse.net Git - xml-template/blobdiff - c++0x/clone.cpp
Tweak C++0x API a bit, to prepare for include. Also, output to stdout instead of...
[xml-template] / c++0x / clone.cpp
index 5bdfbc66849771e40f876916a48df7a06d2e4446..6911a7dbbd6d77789332ceb5b619b44a5e89ab22 100644 (file)
@@ -6,33 +6,17 @@ using namespace std;
 
 int main(int argc, char **argv)
 {
-       vector<Directive *> things;
+       Substitute master_directive = {
+               make_pair("color", new Replace("blue")),
+               make_pair("#things", new Clone {
+                       new Substitute { make_pair("li", new Replace("Raindrops on roses")) },
+                       new Substitute { make_pair("li", new Replace("Whiskers on kittens")) },
+                       new Substitute { make_pair("li", new Replace("Bright copper kettles")) },
+                       new Substitute { make_pair("li", new Replace("Warm, woolen mittens")) },
+               }),
+       };
 
-       {
-               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));
+       xmlDocPtr doc = process_file("../xml/clone.xml", &master_directive);
+       output_to_fd_and_free(doc, 1);
        return(0);
 }