xmlNode *frag = xmlNewDocFragment(node->doc);
xmlReplaceNode(node, frag);
frag->children = node->children;
xmlNode *frag = xmlNewDocFragment(node->doc);
xmlReplaceNode(node, frag);
frag->children = node->children;
Replace::Replace(const string &str)
: str(str) {}
void Replace::process(xmlNode *node, bool clean) {
Replace::Replace(const string &str)
: str(str) {}
void Replace::process(xmlNode *node, bool clean) {
// We can't use xmlNewDocFragment, since xmlDOMWrapCloneNode only knows
// how to clone elements.
vector<xmlNode *> new_nodes;
// We can't use xmlNewDocFragment, since xmlDOMWrapCloneNode only knows
// how to clone elements.
vector<xmlNode *> new_nodes;
for (auto child : new_nodes) {
xmlAddChild(node, child);
}
for (auto child : new_nodes) {
xmlAddChild(node, child);
}
Substitute::Substitute(const unordered_map<string, Directive*> &substitution_map)
: substitution_map(substitution_map) {}
Substitute::Substitute(const unordered_map<string, Directive*> &substitution_map)
: substitution_map(substitution_map) {}
-void Substitute::process(xmlNode *node, bool clean) {
+Substitute::~Substitute()
+{
+ for (auto it : substitution_map) {
+ delete it.second;
+ }
+}
+
+void Substitute::process(xmlNode *node, bool clean)
+{
xmlDocPtr doc = xmlParseFile(input_filename.c_str());
root_directive->process(xmlDocGetRootElement(doc), true);
xmlSaveFile(output_filename.c_str(), doc);
xmlDocPtr doc = xmlParseFile(input_filename.c_str());
root_directive->process(xmlDocGetRootElement(doc), true);
xmlSaveFile(output_filename.c_str(), doc);