From eae75dbe448b0395aee7e49c2a9cca9f82680782 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 19 Jun 2022 08:56:36 -0400 Subject: Add Pl_Function -- a generic function pipeline --- libqpdf/Pl_Function.cc | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 libqpdf/Pl_Function.cc (limited to 'libqpdf/Pl_Function.cc') diff --git a/libqpdf/Pl_Function.cc b/libqpdf/Pl_Function.cc new file mode 100644 index 00000000..32fcccf1 --- /dev/null +++ b/libqpdf/Pl_Function.cc @@ -0,0 +1,39 @@ +#include + +#include +#include +#include + +Pl_Function::Members::Members(writer_t fn) : + fn(fn) +{ +} + +Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_t fn) : + Pipeline(identifier, next), + m(new Members(fn)) +{ +} + +Pl_Function::~Pl_Function() +{ + // Must be explicit and not inline -- see QPDF_DLL_CLASS in + // README-maintainer +} + +void +Pl_Function::write(unsigned char const* buf, size_t len) +{ + this->m->fn(buf, len); + if (getNext(true)) { + getNext()->write(buf, len); + } +} + +void +Pl_Function::finish() +{ + if (getNext(true)) { + getNext()->finish(); + } +} -- cgit v1.2.3-54-g00ecf