From 4fe2e06b4787ffb639f965ac840b51018308ec07 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 8 May 2022 13:42:16 -0400 Subject: Add --create-from-json and --update-from-json arguments Also add stubs for top-level QPDF methods (createFromJSON, updateFromJSON) --- libqpdf/QPDFJob_config.cc | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'libqpdf/QPDFJob_config.cc') diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc index f69a8137..1aa680e8 100644 --- a/libqpdf/QPDFJob_config.cc +++ b/libqpdf/QPDFJob_config.cc @@ -25,12 +25,14 @@ QPDFJob::Config::emptyInput() { if (o.m->infilename == 0) { // Various places in QPDFJob.cc know that the empty string for - // infile means empty. This means that passing "" as the - // argument to inputFile, or equivalently using "" as a - // positional command-line argument would be the same as - // --empty. This probably isn't worth blocking or coding - // around, but it would be better if we had a tighter way of - // knowing that the input file is empty. + // infile means empty. We set it to something other than a + // null pointer as an indication that some input source has + // been specified. The --create-from-json option also sets + // infilename to empty. This approach means that passing "" as + // the argument to inputFile in job JSON, or equivalently + // using "" as a positional command-line argument would be the + // same as --empty. This probably isn't worth blocking or + // coding around. o.m->infilename = QUtil::make_shared_cstr(""); } else { usage("empty input can't be used" @@ -293,6 +295,23 @@ QPDFJob::Config::toJson() return this; } +QPDFJob::Config* +QPDFJob::Config::createFromJson(std::string const& parameter) +{ + // See comments in emptyInput() about setting infilename to the + // empty string. + o.m->infilename = QUtil::make_shared_cstr(""); + o.m->create_from_json = parameter; + return this; +} + +QPDFJob::Config* +QPDFJob::Config::updateFromJson(std::string const& parameter) +{ + o.m->update_from_json = parameter; + return this; +} + QPDFJob::Config* QPDFJob::Config::testJsonSchema() { -- cgit v1.2.3-70-g09d2