From 34f013c1be56abac1104812938eb0af568df99e1 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 9 Jan 2024 11:41:18 -0500 Subject: Allow --file and --range with --pages Accept --file and --range as named parameters in additional to allowing positional arguments. This is in preparation for adding additional flags. --- libqpdf/QPDFJob_config.cc | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'libqpdf/QPDFJob_config.cc') diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc index db6c5948..c43cc82f 100644 --- a/libqpdf/QPDFJob_config.cc +++ b/libqpdf/QPDFJob_config.cc @@ -968,6 +968,45 @@ QPDFJob::PagesConfig::pageSpec( return this; } +QPDFJob::PagesConfig* +QPDFJob::PagesConfig::file(std::string const& arg) +{ + this->config->o.m->page_specs.emplace_back(arg, nullptr, ""); + return this; +} + +QPDFJob::PagesConfig* +QPDFJob::PagesConfig::range(std::string const& arg) +{ + if (config->o.m->page_specs.empty()) { + QTC::TC("qpdf", "QPDFJob misplaced page range"); + usage("in --range must follow a file name"); + } + auto& last = config->o.m->page_specs.back(); + if (!last.range.empty()) { + QTC::TC("qpdf", "QPDFJob duplicated range"); + usage("--range already specified for this file"); + } + last.range = arg; + return this; +} + +QPDFJob::PagesConfig* +QPDFJob::PagesConfig::password(std::string const& arg) +{ + if (config->o.m->page_specs.empty()) { + QTC::TC("qpdf", "QPDFJob misplaced pages password"); + usage("in --pages, --password must follow a file name"); + } + auto& last = config->o.m->page_specs.back(); + if (last.password) { + QTC::TC("qpdf", "QPDFJob duplicated pages password"); + usage("--password already specified for this file"); + } + last.password = QUtil::make_shared_cstr(arg); + return this; +} + std::shared_ptr QPDFJob::Config::overlay() { -- cgit v1.2.3-54-g00ecf