diff options
author | Jay Berkenbilt <ejb@ql.org> | 2024-01-09 17:41:18 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2024-01-10 22:44:17 +0100 |
commit | 34f013c1be56abac1104812938eb0af568df99e1 (patch) | |
tree | d3778a78539b58013b36ede9260e5a5efc86d093 /libqpdf/QPDFJob_config.cc | |
parent | 20a134826c6f33fab81b0cdb9ba2d75fb03d1b59 (diff) | |
download | qpdf-34f013c1be56abac1104812938eb0af568df99e1.tar.zst |
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.
Diffstat (limited to 'libqpdf/QPDFJob_config.cc')
-rw-r--r-- | libqpdf/QPDFJob_config.cc | 39 |
1 files changed, 39 insertions, 0 deletions
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::UOConfig> QPDFJob::Config::overlay() { |