aboutsummaryrefslogtreecommitdiffstats
path: root/include/qpdf/QPDFWriter.hh
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-06-18 20:56:58 +0200
committerJay Berkenbilt <ejb@ql.org>2022-06-19 14:46:58 +0200
commit3a7ee7e93847d41cae414ff77cc75fd6394751ef (patch)
tree4d28778c0b1fe2c9f8feaad5adaab4b1ff29693a /include/qpdf/QPDFWriter.hh
parent8e361d98f0bb23d58cbc773367ba76dffced7bdb (diff)
downloadqpdf-3a7ee7e93847d41cae414ff77cc75fd6394751ef.tar.zst
Move C-based ProgressReporter helper into QPDFWriter
Diffstat (limited to 'include/qpdf/QPDFWriter.hh')
-rw-r--r--include/qpdf/QPDFWriter.hh17
1 files changed, 16 insertions, 1 deletions
diff --git a/include/qpdf/QPDFWriter.hh b/include/qpdf/QPDFWriter.hh
index e44839d4..245e11f3 100644
--- a/include/qpdf/QPDFWriter.hh
+++ b/include/qpdf/QPDFWriter.hh
@@ -29,6 +29,7 @@
#include <qpdf/DLL.h>
#include <qpdf/Types.h>
+#include <functional>
#include <list>
#include <map>
#include <memory>
@@ -80,7 +81,7 @@ class QPDFWriter
class QPDF_DLL_CLASS ProgressReporter
{
public:
- virtual ~ProgressReporter() = default;
+ virtual ~ProgressReporter();
// This method is called with a value from 0 to 100 to
// indicate approximate progress through the write process.
@@ -88,6 +89,20 @@ class QPDFWriter
virtual void reportProgress(int) = 0;
};
+ // This is a progress reporter that takes a function. It is used
+ // by the C APIs, but it is available if you want to just register
+ // a C function as a handler.
+ class QPDF_DLL_CLASS FunctionProgressReporter: public ProgressReporter
+ {
+ public:
+ FunctionProgressReporter(std::function<void(int)>);
+ virtual ~FunctionProgressReporter();
+ virtual void reportProgress(int) override;
+
+ private:
+ std::function<void(int)> handler;
+ };
+
// Setting Output. Output may be set only one time. If you don't
// use the filename version of the QPDFWriter constructor, you
// must call exactly one of these methods.