Commit e48bfce93069d4bb720649bef3e9328f1e783e1e
1 parent
e4905983
QPDFJob: convert PageSpec to used shared pointer
Showing
2 changed files
with
19 additions
and
12 deletions
include/qpdf/QPDFJob.hh
| @@ -123,16 +123,11 @@ class QPDFJob | @@ -123,16 +123,11 @@ class QPDFJob | ||
| 123 | { | 123 | { |
| 124 | PageSpec(std::string const& filename, | 124 | PageSpec(std::string const& filename, |
| 125 | char const* password, | 125 | char const* password, |
| 126 | - char const* range) : | ||
| 127 | - filename(filename), | ||
| 128 | - password(password), | ||
| 129 | - range(range) | ||
| 130 | - { | ||
| 131 | - } | 126 | + std::string const& range); |
| 132 | 127 | ||
| 133 | std::string filename; | 128 | std::string filename; |
| 134 | - char const* password; | ||
| 135 | - char const* range; | 129 | + std::shared_ptr<char> password; |
| 130 | + std::string range; | ||
| 136 | }; | 131 | }; |
| 137 | 132 | ||
| 138 | struct RotationSpec | 133 | struct RotationSpec |
libqpdf/QPDFJob.cc
| @@ -64,7 +64,7 @@ namespace | @@ -64,7 +64,7 @@ namespace | ||
| 64 | struct QPDFPageData | 64 | struct QPDFPageData |
| 65 | { | 65 | { |
| 66 | QPDFPageData(std::string const& filename, | 66 | QPDFPageData(std::string const& filename, |
| 67 | - QPDF* qpdf, char const* range); | 67 | + QPDF* qpdf, std::string const& range); |
| 68 | QPDFPageData(QPDFPageData const& other, int page); | 68 | QPDFPageData(QPDFPageData const& other, int page); |
| 69 | 69 | ||
| 70 | std::string filename; | 70 | std::string filename; |
| @@ -272,9 +272,21 @@ ImageOptimizer::provideStreamData(int, int, Pipeline* pipeline) | @@ -272,9 +272,21 @@ ImageOptimizer::provideStreamData(int, int, Pipeline* pipeline) | ||
| 272 | false, false); | 272 | false, false); |
| 273 | } | 273 | } |
| 274 | 274 | ||
| 275 | +QPDFJob::PageSpec::PageSpec(std::string const& filename, | ||
| 276 | + char const* password, | ||
| 277 | + std::string const& range) : | ||
| 278 | + filename(filename), | ||
| 279 | + range(range) | ||
| 280 | +{ | ||
| 281 | + if (password) | ||
| 282 | + { | ||
| 283 | + this->password = QUtil::make_shared_cstr(password); | ||
| 284 | + } | ||
| 285 | +} | ||
| 286 | + | ||
| 275 | QPDFPageData::QPDFPageData(std::string const& filename, | 287 | QPDFPageData::QPDFPageData(std::string const& filename, |
| 276 | QPDF* qpdf, | 288 | QPDF* qpdf, |
| 277 | - char const* range) : | 289 | + std::string const& range) : |
| 278 | filename(filename), | 290 | filename(filename), |
| 279 | qpdf(qpdf), | 291 | qpdf(qpdf), |
| 280 | orig_pages(qpdf->getAllPages()) | 292 | orig_pages(qpdf->getAllPages()) |
| @@ -282,7 +294,7 @@ QPDFPageData::QPDFPageData(std::string const& filename, | @@ -282,7 +294,7 @@ QPDFPageData::QPDFPageData(std::string const& filename, | ||
| 282 | try | 294 | try |
| 283 | { | 295 | { |
| 284 | this->selected_pages = | 296 | this->selected_pages = |
| 285 | - QUtil::parse_numrange(range, | 297 | + QUtil::parse_numrange(range.c_str(), |
| 286 | QIntC::to_int(this->orig_pages.size())); | 298 | QIntC::to_int(this->orig_pages.size())); |
| 287 | } | 299 | } |
| 288 | catch (std::runtime_error& e) | 300 | catch (std::runtime_error& e) |
| @@ -2599,7 +2611,7 @@ QPDFJob::handlePageSpecs( | @@ -2599,7 +2611,7 @@ QPDFJob::handlePageSpecs( | ||
| 2599 | // the API, you can just create two different QPDF objects | 2611 | // the API, you can just create two different QPDF objects |
| 2600 | // to the same underlying file with the same path to | 2612 | // to the same underlying file with the same path to |
| 2601 | // achieve the same affect. | 2613 | // achieve the same affect. |
| 2602 | - char const* password = page_spec.password; | 2614 | + char const* password = page_spec.password.get(); |
| 2603 | if ((! o.encryption_file.empty()) && (password == 0) && | 2615 | if ((! o.encryption_file.empty()) && (password == 0) && |
| 2604 | (page_spec.filename == o.encryption_file)) | 2616 | (page_spec.filename == o.encryption_file)) |
| 2605 | { | 2617 | { |