From efbb21673c59cfbf6a74de6866a59cb2dbb8e59f Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 14 Feb 2021 14:04:40 -0500 Subject: Add functional versions of QPDFObjectHandle::replaceStreamData Also fix a bug in checking consistency of length for stream data providers. Length should not be checked or recorded if the provider says it failed to generate the data. --- include/qpdf/QPDFObjectHandle.hh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include') diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index 41646b79..cb4c5be6 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -986,6 +987,26 @@ class QPDFObjectHandle QPDFObjectHandle const& filter, QPDFObjectHandle const& decode_parms); + // Starting in qpdf 10.2, you can use C++-11 function objects + // instead of StreamDataProvider. + + // The provider should write the stream data to the pipeline. For + // a one-liner to replace stream data with the contents of a file, + // pass QUtil::file_provider(filename) as provider. + QPDF_DLL + void replaceStreamData(std::function provider, + QPDFObjectHandle const& filter, + QPDFObjectHandle const& decode_parms); + // The provider should write the stream data to the pipeline, + // returning true if it succeeded without errors. + QPDF_DLL + void replaceStreamData( + std::function provider, + QPDFObjectHandle const& filter, + QPDFObjectHandle const& decode_parms); + // Access object ID and generation. For direct objects, return // object ID 0. -- cgit v1.2.3-54-g00ecf