aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFJob_config.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-05-08 19:42:16 +0200
committerJay Berkenbilt <ejb@ql.org>2022-05-16 19:41:40 +0200
commit4fe2e06b4787ffb639f965ac840b51018308ec07 (patch)
tree667474624e264384d544cbed4324b909478f3450 /libqpdf/QPDFJob_config.cc
parented6130036c65124cb236e709201330404a4b1d72 (diff)
downloadqpdf-4fe2e06b4787ffb639f965ac840b51018308ec07.tar.zst
Add --create-from-json and --update-from-json arguments
Also add stubs for top-level QPDF methods (createFromJSON, updateFromJSON)
Diffstat (limited to 'libqpdf/QPDFJob_config.cc')
-rw-r--r--libqpdf/QPDFJob_config.cc31
1 files changed, 25 insertions, 6 deletions
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"
@@ -294,6 +296,23 @@ QPDFJob::Config::toJson()
}
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()
{
o.m->test_json_schema = true;