summaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2023-03-21 17:28:07 +0100
committerm-holger <m-holger@kubitscheck.org>2023-04-02 10:24:08 +0200
commitc78f44798a0b07e7a585c85c7b8bcc1907542cd4 (patch)
tree31b49cc0dd932da5d3eb495262d236d894e6aa63 /libqpdf
parenta2edf27b76cf68474190229dad904ca661e9bb42 (diff)
downloadqpdf-c78f44798a0b07e7a585c85c7b8bcc1907542cd4.tar.zst
Add new _qpdf_data constructor taking a std::unique_ptr<QPDF>
Also, move _qpdf_data and to new header filer _qpdf_error to new header file qpdf-c_impl.hh
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/qpdf-c.cc37
-rw-r--r--libqpdf/qpdf/qpdf-c_impl.hh47
2 files changed, 48 insertions, 36 deletions
diff --git a/libqpdf/qpdf-c.cc b/libqpdf/qpdf-c.cc
index 7feabd1c..01987365 100644
--- a/libqpdf/qpdf-c.cc
+++ b/libqpdf/qpdf-c.cc
@@ -12,6 +12,7 @@
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
+#include <qpdf/qpdf-c_impl.hh>
#include <qpdf/qpdflogger-c_impl.hh>
#include <cstring>
@@ -20,42 +21,6 @@
#include <stdexcept>
#include <string>
-struct _qpdf_error
-{
- std::shared_ptr<QPDFExc> exc;
-};
-
-struct _qpdf_data
-{
- _qpdf_data() = default;
- ~_qpdf_data() = default;
-
- std::shared_ptr<QPDF> qpdf;
- std::shared_ptr<QPDFWriter> qpdf_writer;
-
- std::shared_ptr<QPDFExc> error;
- _qpdf_error tmp_error;
- std::list<QPDFExc> warnings;
- std::string tmp_string;
-
- // Parameters for functions we call
- char const* filename{nullptr}; // or description
- char const* buffer{nullptr};
- unsigned long long size{0};
- char const* password{nullptr};
- bool write_memory{false};
- std::shared_ptr<Buffer> output_buffer;
-
- // QPDFObjectHandle support
- bool silence_errors{false};
- bool oh_error_occurred{false};
- std::map<qpdf_oh, std::shared_ptr<QPDFObjectHandle>> oh_cache;
- qpdf_oh next_oh{0};
- std::set<std::string> cur_iter_dict_keys;
- std::set<std::string>::const_iterator dict_iter;
- std::string cur_dict_key;
-};
-
// must set qpdf->filename and qpdf->password
static void
call_read(qpdf_data qpdf)
diff --git a/libqpdf/qpdf/qpdf-c_impl.hh b/libqpdf/qpdf/qpdf-c_impl.hh
new file mode 100644
index 00000000..0d52cf10
--- /dev/null
+++ b/libqpdf/qpdf/qpdf-c_impl.hh
@@ -0,0 +1,47 @@
+#include <qpdf/qpdf-c.h>
+
+#include <memory>
+
+#include <qpdf/QPDF.hh>
+#include <qpdf/QPDFExc.hh>
+#include <qpdf/QPDFWriter.hh>
+
+struct _qpdf_error
+{
+ std::shared_ptr<QPDFExc> exc;
+};
+
+struct _qpdf_data
+{
+ _qpdf_data() = default;
+
+ _qpdf_data(std::unique_ptr<QPDF>&& qpdf) :
+ qpdf(std::move(qpdf)){};
+
+ ~_qpdf_data() = default;
+
+ std::shared_ptr<QPDF> qpdf;
+ std::shared_ptr<QPDFWriter> qpdf_writer;
+
+ std::shared_ptr<QPDFExc> error;
+ _qpdf_error tmp_error;
+ std::list<QPDFExc> warnings;
+ std::string tmp_string;
+
+ // Parameters for functions we call
+ char const* filename{nullptr}; // or description
+ char const* buffer{nullptr};
+ unsigned long long size{0};
+ char const* password{nullptr};
+ bool write_memory{false};
+ std::shared_ptr<Buffer> output_buffer;
+
+ // QPDFObjectHandle support
+ bool silence_errors{false};
+ bool oh_error_occurred{false};
+ std::map<qpdf_oh, std::shared_ptr<QPDFObjectHandle>> oh_cache;
+ qpdf_oh next_oh{0};
+ std::set<std::string> cur_iter_dict_keys;
+ std::set<std::string>::const_iterator dict_iter;
+ std::string cur_dict_key;
+};