]> git.sesse.net Git - xml-template/commitdiff
Tweak C++0x API a bit, to prepare for include. Also, output to stdout instead of...
authorsgunderson@bigfoot.com <>
Wed, 21 Sep 2011 23:43:38 +0000 (01:43 +0200)
committersgunderson@bigfoot.com <>
Wed, 21 Sep 2011 23:43:38 +0000 (01:43 +0200)
13 files changed:
c++0x/attribute-empty.cpp
c++0x/attribute.cpp
c++0x/attribute2.cpp
c++0x/attribute3.cpp
c++0x/clone.cpp
c++0x/namespace.cpp
c++0x/namespace2.cpp
c++0x/passthru.cpp
c++0x/simple.cpp
c++0x/structure.cpp
c++0x/xml-template.cpp
c++0x/xml-template.h
tests/test.sh

index b79836bbc4ed52623f1ea56cee320368926a0a30..96c587db686e14a4da212140d9b0b702cbbfd7f5 100644 (file)
@@ -11,6 +11,7 @@ int main(int argc, char **argv)
                make_pair("#things", new Clone { }),
        };
 
-       process_file("../xml/clone.xml", argv[1], &master_directive);
+       xmlDocPtr doc = process_file("../xml/clone.xml", &master_directive);
+       output_to_fd_and_free(doc, 1);
        return(0);
 }
index 6c341bd9019b419d9c9647d9e43203d283b6af20..e6513230be4b083d8910af28edd7da87dad85429 100644 (file)
@@ -28,6 +28,7 @@ int main(int argc, char **argv)
                }),
        };
 
-       process_file("../xml/clone.xml", argv[1], &master_directive);
+       xmlDocPtr doc = process_file("../xml/clone.xml", &master_directive);
+       output_to_fd_and_free(doc, 1);
        return(0);
 }
index 94cf17d24f56277c00d70420529101e16a118650..478dd51d0150e4f3aec7271cd78f6db954fd3b2a 100644 (file)
@@ -16,6 +16,7 @@ int main(int argc, char **argv)
                }, { "odd", "even" } }),
        };
 
-       process_file("../xml/clone.xml", argv[1], &master_directive);
+       xmlDocPtr doc = process_file("../xml/clone.xml", &master_directive);
+       output_to_fd_and_free(doc, 1);
        return(0);
 }
index a3f8b6eca5dcfdf5712955a422bdd7245caa618d..d2746e80c0a166284c4ff769571b36e6676d2908 100644 (file)
@@ -17,6 +17,7 @@ int main(int argc, char **argv)
                }, { "odd", "even" } }),
        };
 
-       process_file("../xml/clone.xml", argv[1], &master_directive);
+       xmlDocPtr doc = process_file("../xml/clone.xml", &master_directive);
+       output_to_fd_and_free(doc, 1);
        return(0);
 }
index 81b6d11051790b307827ad10c7a2a56ffab695bc..6911a7dbbd6d77789332ceb5b619b44a5e89ab22 100644 (file)
@@ -16,6 +16,7 @@ int main(int argc, char **argv)
                }),
        };
 
-       process_file("../xml/clone.xml", argv[1], &master_directive);
+       xmlDocPtr doc = process_file("../xml/clone.xml", &master_directive);
+       output_to_fd_and_free(doc, 1);
        return(0);
 }
index 72985767303f19472dae8701c693584768163c52..3399957fd41255c55f6604dc0c4031f2741c7923 100644 (file)
@@ -14,6 +14,7 @@ int main(int argc, char **argv)
                make_pair("#moretest", new Replace("bar")),
        };
 
-       process_file("../xml/namespace.xml", argv[1], &master_directive);
+       xmlDocPtr doc = process_file("../xml/namespace.xml", &master_directive);
+       output_to_fd_and_free(doc, 1);
        return(0);
 }
index 2b438d337ec35920fa93fbbcd105ade8ea6654cd..060eb0e512983218727c970b284b03e122ba634f 100644 (file)
@@ -11,6 +11,7 @@ int main(int argc, char **argv)
                make_pair("#hello", new Replace("Replaced.")),
        };
 
-       process_file("../xml/namespace2.xml", argv[1], &master_directive);
+       xmlDocPtr doc = process_file("../xml/namespace2.xml", &master_directive);
+       output_to_fd_and_free(doc, 1);
        return(0);
 }
index f4fc63692a83a7d873b6552ac0ee390f65cb830b..28cc2f4873311705e0e2a7192eb20514bb5736a2 100644 (file)
@@ -9,6 +9,7 @@ using namespace std;
 int main(int argc, char **argv)
 {
        Substitute master_directive = {};
-       process_file("../xml/passthru.xml", argv[1], &master_directive);
+       xmlDocPtr doc = process_file("../xml/passthru.xml", &master_directive);
+       output_to_fd_and_free(doc, 1);
        return(0);
 }
index 5ac223d09f72eda03769dd1d1bef78b964cf8de3..0c895426383497494e362f9f8ddadd90d4827989 100644 (file)
@@ -11,6 +11,7 @@ int main(int argc, char **argv)
                make_pair("#hello", new Replace("Hello world!")),
        };
 
-       process_file("../xml/simple.xml", argv[1], &master_directive);
+       xmlDocPtr doc = process_file("../xml/simple.xml", &master_directive);
+       output_to_fd_and_free(doc, 1);
        return(0);
 }
index 2447febd734854f533e51b123938a262dad37da3..facaadef08b75708b8289c2283bf79c723558f71 100644 (file)
@@ -14,6 +14,7 @@ int main(int argc, char **argv)
                }),
        };
 
-       process_file("../xml/structure.xml", argv[1], &master_directive);
+       xmlDocPtr doc = process_file("../xml/structure.xml", &master_directive);
+       output_to_fd_and_free(doc, 1);
        return(0);
 }
index 30e5a7e1e3f96a6d740ebefdb68ea1c2d1c6bfb4..e8fc0edb086678d12ebea5eddc04fe355478d7e9 100644 (file)
@@ -196,17 +196,21 @@ void Substitute::process(xmlNode *node, bool clean)
        }
 }
        
-void process_file(const string &input_filename,
-                  const string &output_filename,
-                  Directive *root_directive)
+xmlDocPtr process_file(const string &input_filename,
+                       Directive *root_directive)
 {
        LIBXML_TEST_VERSION
 
        xmlDocPtr doc = xmlParseFile(input_filename.c_str());
        root_directive->process(xmlDocGetRootElement(doc), true);
-       xmlSaveFile(output_filename.c_str(), doc);
-       xmlFreeDoc(doc);
-
        xmlCleanupParser();
        xmlMemoryDump();
+       return doc;
+}
+
+void output_to_fd_and_free(xmlDocPtr doc, int fd)
+{
+       xmlOutputBufferPtr buf = xmlOutputBufferCreateFd(fd, NULL);
+       xmlSaveFileTo(buf, doc, NULL);
+       xmlFreeDoc(doc);
 }
index d29cbaeeb5b17594a5e5db7fd5ea80fcab4fae60..35671869868cb35d662250b9c0a5546df6373f5b 100644 (file)
@@ -59,8 +59,9 @@ class Alternate : public Clone {
                  const std::vector<std::string> &alternatives);
 };
 
-void process_file(const std::string &input_filename,
-                  const std::string &output_filename,
-                  Directive *root_directive);
+xmlDocPtr process_file(const std::string &input_filename,
+                       Directive *root_directive);
+       
+void output_to_fd_and_free(xmlDocPtr doc, int fd);
 
 #endif  // !defined(_XML_TEMPLATE_H)
index 43ccadcb1b73ca627066bdb2ec27ba6fe61bda3b..600f0955d3a9d0e47e4f87cc1f5ba457ede73d99 100755 (executable)
@@ -31,7 +31,7 @@ for L in $LANGUAGES; do
                        ruby -I../ruby ../ruby/$T.rb > $TEMPFILE
                fi
                if [ "$L" = "c++0x" ]; then
-                       ( cd ../c++0x && make -s $T ) && ../c++0x/$T $TEMPFILE
+                       ( cd ../c++0x && make -s $T ) && ../c++0x/$T $TEMPFILE
                fi
 
                perl ./xml-diff.pl $TEMPFILE reference/$T.xml