Commit a3c99803954ad0f3762d986c953666c6517cad0c
1 parent
b361c5ce
Add next to Pl_String and fix comments
Showing
4 changed files
with
25 additions
and
7 deletions
include/qpdf/Pl_String.hh
| ... | ... | @@ -19,11 +19,23 @@ |
| 19 | 19 | // continue to consider qpdf to be licensed under those terms. Please |
| 20 | 20 | // see the manual for additional information. |
| 21 | 21 | |
| 22 | -// End-of-line pipeline that simply writes its data to a stdio FILE* object. | |
| 23 | - | |
| 24 | 22 | #ifndef PL_STRING_HH |
| 25 | 23 | #define PL_STRING_HH |
| 26 | 24 | |
| 25 | +// This pipeline accumulates the data passed to it into a std::string, | |
| 26 | +// a reference to which is passed in at construction. Each subsequent | |
| 27 | +// use of this pipeline appends to the data accumulated so far. | |
| 28 | +// | |
| 29 | +// For this pipeline, "next" may be null. If a next pointer is | |
| 30 | +// provided, this pipeline will also pass the data through to it and | |
| 31 | +// will forward finish() to it. | |
| 32 | +// | |
| 33 | +// It is okay to not call finish() on this pipeline. This makes it | |
| 34 | +// easy to stick this in front of another pipeline to capture data | |
| 35 | +// that is written to the other pipeline without interfering with when | |
| 36 | +// finish is called on the other pipeline and without having to put a | |
| 37 | +// Pl_Concatenate after it. | |
| 38 | + | |
| 27 | 39 | #include <qpdf/Pipeline.hh> |
| 28 | 40 | |
| 29 | 41 | #include <string> |
| ... | ... | @@ -32,7 +44,7 @@ class QPDF_DLL_CLASS Pl_String: public Pipeline |
| 32 | 44 | { |
| 33 | 45 | public: |
| 34 | 46 | QPDF_DLL |
| 35 | - Pl_String(char const* identifier, std::string& s); | |
| 47 | + Pl_String(char const* identifier, Pipeline* next, std::string& s); | |
| 36 | 48 | QPDF_DLL |
| 37 | 49 | virtual ~Pl_String(); |
| 38 | 50 | ... | ... |
libqpdf/JSON.cc
libqpdf/Pl_String.cc
| ... | ... | @@ -9,8 +9,8 @@ Pl_String::Members::Members(std::string& s) : |
| 9 | 9 | { |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -Pl_String::Pl_String(char const* identifier, std::string& s) : | |
| 13 | - Pipeline(identifier, 0), | |
| 12 | +Pl_String::Pl_String(char const* identifier, Pipeline* next, std::string& s) : | |
| 13 | + Pipeline(identifier, next), | |
| 14 | 14 | m(new Members(s)) |
| 15 | 15 | { |
| 16 | 16 | } |
| ... | ... | @@ -25,9 +25,15 @@ void |
| 25 | 25 | Pl_String::write(unsigned char const* buf, size_t len) |
| 26 | 26 | { |
| 27 | 27 | this->m->s.append(reinterpret_cast<char const*>(buf), len); |
| 28 | + if (getNext(true)) { | |
| 29 | + getNext()->write(buf, len); | |
| 30 | + } | |
| 28 | 31 | } |
| 29 | 32 | |
| 30 | 33 | void |
| 31 | 34 | Pl_String::finish() |
| 32 | 35 | { |
| 36 | + if (getNext(true)) { | |
| 37 | + getNext()->finish(); | |
| 38 | + } | |
| 33 | 39 | } | ... | ... |
qpdf/test_driver.cc
| ... | ... | @@ -437,7 +437,7 @@ test_6(QPDF& pdf, char const* arg2) |
| 437 | 437 | throw std::logic_error("test 6 run on file with no metadata"); |
| 438 | 438 | } |
| 439 | 439 | std::string buf; |
| 440 | - Pl_String bufpl("buffer", buf); | |
| 440 | + Pl_String bufpl("buffer", nullptr, buf); | |
| 441 | 441 | metadata.pipeStreamData(&bufpl, 0, qpdf_dl_none); |
| 442 | 442 | bool cleartext = false; |
| 443 | 443 | if (buf.substr(0, 9) == "<?xpacket") { | ... | ... |