From 3a7ee7e93847d41cae414ff77cc75fd6394751ef Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 18 Jun 2022 14:56:58 -0400 Subject: Move C-based ProgressReporter helper into QPDFWriter --- include/qpdf/QPDFWriter.hh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'include') 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 #include +#include #include #include #include @@ -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); + virtual ~FunctionProgressReporter(); + virtual void reportProgress(int) override; + + private: + std::function 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. -- cgit v1.2.3-70-g09d2