Commit c78f44798a0b07e7a585c85c7b8bcc1907542cd4
1 parent
a2edf27b
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
Showing
2 changed files
with
48 additions
and
36 deletions
libqpdf/qpdf-c.cc
| @@ -12,6 +12,7 @@ | @@ -12,6 +12,7 @@ | ||
| 12 | #include <qpdf/QPDFWriter.hh> | 12 | #include <qpdf/QPDFWriter.hh> |
| 13 | #include <qpdf/QTC.hh> | 13 | #include <qpdf/QTC.hh> |
| 14 | #include <qpdf/QUtil.hh> | 14 | #include <qpdf/QUtil.hh> |
| 15 | +#include <qpdf/qpdf-c_impl.hh> | ||
| 15 | #include <qpdf/qpdflogger-c_impl.hh> | 16 | #include <qpdf/qpdflogger-c_impl.hh> |
| 16 | 17 | ||
| 17 | #include <cstring> | 18 | #include <cstring> |
| @@ -20,42 +21,6 @@ | @@ -20,42 +21,6 @@ | ||
| 20 | #include <stdexcept> | 21 | #include <stdexcept> |
| 21 | #include <string> | 22 | #include <string> |
| 22 | 23 | ||
| 23 | -struct _qpdf_error | ||
| 24 | -{ | ||
| 25 | - std::shared_ptr<QPDFExc> exc; | ||
| 26 | -}; | ||
| 27 | - | ||
| 28 | -struct _qpdf_data | ||
| 29 | -{ | ||
| 30 | - _qpdf_data() = default; | ||
| 31 | - ~_qpdf_data() = default; | ||
| 32 | - | ||
| 33 | - std::shared_ptr<QPDF> qpdf; | ||
| 34 | - std::shared_ptr<QPDFWriter> qpdf_writer; | ||
| 35 | - | ||
| 36 | - std::shared_ptr<QPDFExc> error; | ||
| 37 | - _qpdf_error tmp_error; | ||
| 38 | - std::list<QPDFExc> warnings; | ||
| 39 | - std::string tmp_string; | ||
| 40 | - | ||
| 41 | - // Parameters for functions we call | ||
| 42 | - char const* filename{nullptr}; // or description | ||
| 43 | - char const* buffer{nullptr}; | ||
| 44 | - unsigned long long size{0}; | ||
| 45 | - char const* password{nullptr}; | ||
| 46 | - bool write_memory{false}; | ||
| 47 | - std::shared_ptr<Buffer> output_buffer; | ||
| 48 | - | ||
| 49 | - // QPDFObjectHandle support | ||
| 50 | - bool silence_errors{false}; | ||
| 51 | - bool oh_error_occurred{false}; | ||
| 52 | - std::map<qpdf_oh, std::shared_ptr<QPDFObjectHandle>> oh_cache; | ||
| 53 | - qpdf_oh next_oh{0}; | ||
| 54 | - std::set<std::string> cur_iter_dict_keys; | ||
| 55 | - std::set<std::string>::const_iterator dict_iter; | ||
| 56 | - std::string cur_dict_key; | ||
| 57 | -}; | ||
| 58 | - | ||
| 59 | // must set qpdf->filename and qpdf->password | 24 | // must set qpdf->filename and qpdf->password |
| 60 | static void | 25 | static void |
| 61 | call_read(qpdf_data qpdf) | 26 | call_read(qpdf_data qpdf) |
libqpdf/qpdf/qpdf-c_impl.hh
0 → 100644
| 1 | +#include <qpdf/qpdf-c.h> | ||
| 2 | + | ||
| 3 | +#include <memory> | ||
| 4 | + | ||
| 5 | +#include <qpdf/QPDF.hh> | ||
| 6 | +#include <qpdf/QPDFExc.hh> | ||
| 7 | +#include <qpdf/QPDFWriter.hh> | ||
| 8 | + | ||
| 9 | +struct _qpdf_error | ||
| 10 | +{ | ||
| 11 | + std::shared_ptr<QPDFExc> exc; | ||
| 12 | +}; | ||
| 13 | + | ||
| 14 | +struct _qpdf_data | ||
| 15 | +{ | ||
| 16 | + _qpdf_data() = default; | ||
| 17 | + | ||
| 18 | + _qpdf_data(std::unique_ptr<QPDF>&& qpdf) : | ||
| 19 | + qpdf(std::move(qpdf)){}; | ||
| 20 | + | ||
| 21 | + ~_qpdf_data() = default; | ||
| 22 | + | ||
| 23 | + std::shared_ptr<QPDF> qpdf; | ||
| 24 | + std::shared_ptr<QPDFWriter> qpdf_writer; | ||
| 25 | + | ||
| 26 | + std::shared_ptr<QPDFExc> error; | ||
| 27 | + _qpdf_error tmp_error; | ||
| 28 | + std::list<QPDFExc> warnings; | ||
| 29 | + std::string tmp_string; | ||
| 30 | + | ||
| 31 | + // Parameters for functions we call | ||
| 32 | + char const* filename{nullptr}; // or description | ||
| 33 | + char const* buffer{nullptr}; | ||
| 34 | + unsigned long long size{0}; | ||
| 35 | + char const* password{nullptr}; | ||
| 36 | + bool write_memory{false}; | ||
| 37 | + std::shared_ptr<Buffer> output_buffer; | ||
| 38 | + | ||
| 39 | + // QPDFObjectHandle support | ||
| 40 | + bool silence_errors{false}; | ||
| 41 | + bool oh_error_occurred{false}; | ||
| 42 | + std::map<qpdf_oh, std::shared_ptr<QPDFObjectHandle>> oh_cache; | ||
| 43 | + qpdf_oh next_oh{0}; | ||
| 44 | + std::set<std::string> cur_iter_dict_keys; | ||
| 45 | + std::set<std::string>::const_iterator dict_iter; | ||
| 46 | + std::string cur_dict_key; | ||
| 47 | +}; |