Commit 7604ac5cb2a4756337ed562d2e3284de3e6a8159

Authored by Jay Berkenbilt
1 parent 2a92b1b0

QPDFJob: have doJSON write to a pipeline

include/qpdf/QPDFJob.hh
@@ -39,6 +39,7 @@ @@ -39,6 +39,7 @@
39 #include <vector> 39 #include <vector>
40 40
41 class QPDFWriter; 41 class QPDFWriter;
  42 +class Pipeline;
42 43
43 class QPDFJob 44 class QPDFJob
44 { 45 {
@@ -509,7 +510,7 @@ class QPDFJob @@ -509,7 +510,7 @@ class QPDFJob
509 void writeOutfile(QPDF& pdf); 510 void writeOutfile(QPDF& pdf);
510 511
511 // JSON 512 // JSON
512 - void doJSON(QPDF& pdf); 513 + void doJSON(QPDF& pdf, Pipeline*);
513 std::set<QPDFObjGen> getWantedJSONObjects(); 514 std::set<QPDFObjGen> getWantedJSONObjects();
514 void doJSONObjects(QPDF& pdf, JSON& j); 515 void doJSONObjects(QPDF& pdf, JSON& j);
515 void doJSONObjectinfo(QPDF& pdf, JSON& j); 516 void doJSONObjectinfo(QPDF& pdf, JSON& j);
libqpdf/QPDFJob.cc
@@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
14 #include <qpdf/Pl_DCT.hh> 14 #include <qpdf/Pl_DCT.hh>
15 #include <qpdf/Pl_Discard.hh> 15 #include <qpdf/Pl_Discard.hh>
16 #include <qpdf/Pl_Flate.hh> 16 #include <qpdf/Pl_Flate.hh>
  17 +#include <qpdf/Pl_OStream.hh>
17 #include <qpdf/Pl_StdioFile.hh> 18 #include <qpdf/Pl_StdioFile.hh>
18 #include <qpdf/QTC.hh> 19 #include <qpdf/QTC.hh>
19 #include <qpdf/QUtil.hh> 20 #include <qpdf/QUtil.hh>
@@ -1588,7 +1589,7 @@ QPDFJob::json_out_schema_v1() @@ -1588,7 +1589,7 @@ QPDFJob::json_out_schema_v1()
1588 } 1589 }
1589 1590
1590 void 1591 void
1591 -QPDFJob::doJSON(QPDF& pdf) 1592 +QPDFJob::doJSON(QPDF& pdf, Pipeline* p)
1592 { 1593 {
1593 JSON j = JSON::makeDictionary(); 1594 JSON j = JSON::makeDictionary();
1594 // This version is updated every time a non-backward-compatible 1595 // This version is updated every time a non-backward-compatible
@@ -1665,7 +1666,7 @@ ideally with the file that caused the error and the output below. Thanks!\n\ @@ -1665,7 +1666,7 @@ ideally with the file that caused the error and the output below. Thanks!\n\
1665 } 1666 }
1666 } 1667 }
1667 1668
1668 - *(this->m->cout) << j.unparse() << std::endl; 1669 + *p << j.unparse() << "\n";
1669 } 1670 }
1670 1671
1671 void 1672 void
@@ -1675,7 +1676,9 @@ QPDFJob::doInspection(QPDF&amp; pdf) @@ -1675,7 +1676,9 @@ QPDFJob::doInspection(QPDF&amp; pdf)
1675 doCheck(pdf); 1676 doCheck(pdf);
1676 } 1677 }
1677 if (m->json_version) { 1678 if (m->json_version) {
1678 - doJSON(pdf); 1679 + Pl_OStream os("stdout", *(this->m->cout));
  1680 + doJSON(pdf, &os);
  1681 + os.finish();
1679 } 1682 }
1680 if (m->show_npages) { 1683 if (m->show_npages) {
1681 QTC::TC("qpdf", "QPDFJob npages"); 1684 QTC::TC("qpdf", "QPDFJob npages");