int main(int argc, char **argv)
{
- LIBXML_TEST_VERSION
-
unordered_map<string, Directive*> master_map;
-
- xmlDocPtr doc = xmlParseFile("../xml/passthru.xml");
- Substitute(master_map).process(xmlDocGetRootElement(doc), false);
- xmlSaveFile(argv[1], doc);
-
- xmlCleanupParser();
- xmlMemoryDump();
+ process_file("../xml/passthru.xml", argv[1], new Substitute(master_map));
return(0);
}
#include <stdio.h>
-#include <string.h>
-#include <libxml/parser.h>
#include "xml-template.h"
int main(int argc, char **argv)
{
- LIBXML_TEST_VERSION
-
unordered_map<string, Directive*> master_map;
master_map.insert(make_pair("title", new Replace("A very basic example")));
master_map.insert(make_pair("#hello", new Replace("Hello world!")));
- xmlDocPtr doc = xmlParseFile("../xml/simple.xml");
- Substitute(master_map).process(xmlDocGetRootElement(doc), false);
- xmlSaveFile(argv[1], doc);
-
- xmlCleanupParser();
- xmlMemoryDump();
+ process_file("../xml/simple.xml", argv[1], new Substitute(master_map));
return(0);
}
#include "xml-template.h"
#include <string.h>
+#include <libxml/parser.h>
using namespace std;
}
}
}
+
+void process_file(const string &input_filename,
+ const string &output_filename,
+ Directive *root_directive)
+{
+ LIBXML_TEST_VERSION
+
+ xmlDocPtr doc = xmlParseFile(input_filename.c_str());
+ root_directive->process(xmlDocGetRootElement(doc), false);
+ xmlSaveFile(output_filename.c_str(), doc);
+
+ xmlCleanupParser();
+ xmlMemoryDump();
+}
const std::unordered_map<std::string, Directive*> &substitution_map;
};
+void process_file(const std::string &input_filename,
+ const std::string &output_filename,
+ Directive *root_directive);
+
#endif // !defined(_XML_TEMPLATE_H)