diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-09-08 22:38:36 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-09-08 23:35:27 +0200 |
commit | b0f054e600bd07f540ac0a081dd8b5a8cc561617 (patch) | |
tree | 5e539e77e5b2fc3f54e1380eb2b9877662bc43ef /include | |
parent | 5911a348a5ae9065610be5fe5f251cab399a52b8 (diff) | |
download | qpdf-b0f054e600bd07f540ac0a081dd8b5a8cc561617.tar.zst |
Add ability to initialize Pl_Function with a C-style function
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/Pl_Function.hh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/qpdf/Pl_Function.hh b/include/qpdf/Pl_Function.hh index dd700e80..41c56a98 100644 --- a/include/qpdf/Pl_Function.hh +++ b/include/qpdf/Pl_Function.hh @@ -31,6 +31,9 @@ // // It is okay to not call finish() on this pipeline if it has no // "next". +// +// It is okay to keep calling write() after a previous write throws an +// exception as long as the delegated function allows it. #include <qpdf/Pipeline.hh> @@ -41,8 +44,26 @@ class QPDF_DLL_CLASS Pl_Function: public Pipeline public: typedef std::function<void(unsigned char const*, size_t)> writer_t; + // The supplied function is called every time write is called. QPDF_DLL Pl_Function(char const* identifier, Pipeline* next, writer_t fn); + + // The supplied C-style function is called every time write is + // called. The udata option is passed into the function with each + // call. If the function returns a non-zero value, a runtime error + // is thrown. + typedef int (*writer_c_t)(unsigned char const*, size_t, void*); + QPDF_DLL + Pl_Function( + char const* identifier, Pipeline* next, writer_c_t fn, void* udata); + typedef int (*writer_c_char_t)(char const*, size_t, void*); + QPDF_DLL + Pl_Function( + char const* identifier, + Pipeline* next, + writer_c_char_t fn, + void* udata); + QPDF_DLL virtual ~Pl_Function(); |