aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Hoffmann <thobi@worker>2012-06-27 07:00:18 +0200
committerJay Berkenbilt <ejb@ql.org>2012-06-27 16:20:38 +0200
commitf07e3370f029d1e4ab0df676ec1fb9ccfbeb708a (patch)
treefae43001f9a9f6f5c68d730f15956140ab6c4031
parent43c404b45ab54583a33492adc93f54fa349c2f94 (diff)
downloadqpdf-f07e3370f029d1e4ab0df676ec1fb9ccfbeb708a.tar.zst
Add Pl_Concatenate filter
-rw-r--r--include/qpdf/Pl_Concatenate.hh32
-rw-r--r--libqpdf/Pl_Concatenate.cc28
-rw-r--r--libqpdf/build.mk1
3 files changed, 61 insertions, 0 deletions
diff --git a/include/qpdf/Pl_Concatenate.hh b/include/qpdf/Pl_Concatenate.hh
new file mode 100644
index 00000000..1b0cb1a9
--- /dev/null
+++ b/include/qpdf/Pl_Concatenate.hh
@@ -0,0 +1,32 @@
+#ifndef __PL_CONCATENATE_HH__
+#define __PL_CONCATENATE_HH__
+
+// This pipeline will drop all regular finished calls rather than
+// passing them onto next. To finish downstream streams, call
+// manualFinish. This makes it possible to pipe multiple streams
+// (e.g. with QPDFObjectHandle::pipeStreamData) to a downstream like
+// Pl_Flate that can't handle multiple calls to finish().
+
+#include <qpdf/Pipeline.hh>
+
+class Pl_Concatenate: public Pipeline
+{
+ public:
+ QPDF_DLL
+ Pl_Concatenate(char const* identifier, Pipeline* next);
+ QPDF_DLL
+ virtual ~Pl_Concatenate();
+
+ QPDF_DLL
+ virtual void write(unsigned char* data, size_t len);
+
+ QPDF_DLL
+ virtual void finish();
+
+ // At the very end, call manualFinish actually finish the rest of
+ // the pipeline.
+ QPDF_DLL
+ void manualFinish();
+};
+
+#endif // __PL_CONCATENATE_HH__
diff --git a/libqpdf/Pl_Concatenate.cc b/libqpdf/Pl_Concatenate.cc
new file mode 100644
index 00000000..8d48de60
--- /dev/null
+++ b/libqpdf/Pl_Concatenate.cc
@@ -0,0 +1,28 @@
+#include <qpdf/Pl_Concatenate.hh>
+
+Pl_Concatenate::Pl_Concatenate(char const* identifier, Pipeline* next) :
+ Pipeline(identifier, next)
+{
+}
+
+Pl_Concatenate::~Pl_Concatenate()
+{
+}
+
+void
+Pl_Concatenate::write(unsigned char* data, size_t len)
+{
+ getNext()->write(data, len);
+}
+
+void
+Pl_Concatenate::finish()
+{
+}
+
+void
+Pl_Concatenate::manualFinish()
+{
+ getNext()->finish();
+}
+
diff --git a/libqpdf/build.mk b/libqpdf/build.mk
index ebd534b3..7efbbd85 100644
--- a/libqpdf/build.mk
+++ b/libqpdf/build.mk
@@ -15,6 +15,7 @@ SRCS_libqpdf = \
libqpdf/Pl_ASCII85Decoder.cc \
libqpdf/Pl_ASCIIHexDecoder.cc \
libqpdf/Pl_Buffer.cc \
+ libqpdf/Pl_Concatenate.cc \
libqpdf/Pl_Count.cc \
libqpdf/Pl_Discard.cc \
libqpdf/Pl_Flate.cc \