Commit f07e3370f029d1e4ab0df676ec1fb9ccfbeb708a

Authored by Tobias Hoffmann
Committed by Jay Berkenbilt
1 parent 43c404b4

Add Pl_Concatenate filter

include/qpdf/Pl_Concatenate.hh 0 → 100644
  1 +#ifndef __PL_CONCATENATE_HH__
  2 +#define __PL_CONCATENATE_HH__
  3 +
  4 +// This pipeline will drop all regular finished calls rather than
  5 +// passing them onto next. To finish downstream streams, call
  6 +// manualFinish. This makes it possible to pipe multiple streams
  7 +// (e.g. with QPDFObjectHandle::pipeStreamData) to a downstream like
  8 +// Pl_Flate that can't handle multiple calls to finish().
  9 +
  10 +#include <qpdf/Pipeline.hh>
  11 +
  12 +class Pl_Concatenate: public Pipeline
  13 +{
  14 + public:
  15 + QPDF_DLL
  16 + Pl_Concatenate(char const* identifier, Pipeline* next);
  17 + QPDF_DLL
  18 + virtual ~Pl_Concatenate();
  19 +
  20 + QPDF_DLL
  21 + virtual void write(unsigned char* data, size_t len);
  22 +
  23 + QPDF_DLL
  24 + virtual void finish();
  25 +
  26 + // At the very end, call manualFinish actually finish the rest of
  27 + // the pipeline.
  28 + QPDF_DLL
  29 + void manualFinish();
  30 +};
  31 +
  32 +#endif // __PL_CONCATENATE_HH__
libqpdf/Pl_Concatenate.cc 0 → 100644
  1 +#include <qpdf/Pl_Concatenate.hh>
  2 +
  3 +Pl_Concatenate::Pl_Concatenate(char const* identifier, Pipeline* next) :
  4 + Pipeline(identifier, next)
  5 +{
  6 +}
  7 +
  8 +Pl_Concatenate::~Pl_Concatenate()
  9 +{
  10 +}
  11 +
  12 +void
  13 +Pl_Concatenate::write(unsigned char* data, size_t len)
  14 +{
  15 + getNext()->write(data, len);
  16 +}
  17 +
  18 +void
  19 +Pl_Concatenate::finish()
  20 +{
  21 +}
  22 +
  23 +void
  24 +Pl_Concatenate::manualFinish()
  25 +{
  26 + getNext()->finish();
  27 +}
  28 +
libqpdf/build.mk
@@ -15,6 +15,7 @@ SRCS_libqpdf = \ @@ -15,6 +15,7 @@ SRCS_libqpdf = \
15 libqpdf/Pl_ASCII85Decoder.cc \ 15 libqpdf/Pl_ASCII85Decoder.cc \
16 libqpdf/Pl_ASCIIHexDecoder.cc \ 16 libqpdf/Pl_ASCIIHexDecoder.cc \
17 libqpdf/Pl_Buffer.cc \ 17 libqpdf/Pl_Buffer.cc \
  18 + libqpdf/Pl_Concatenate.cc \
18 libqpdf/Pl_Count.cc \ 19 libqpdf/Pl_Count.cc \
19 libqpdf/Pl_Discard.cc \ 20 libqpdf/Pl_Discard.cc \
20 libqpdf/Pl_Flate.cc \ 21 libqpdf/Pl_Flate.cc \