diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-01-26 19:56:13 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-01-30 19:11:03 +0100 |
commit | 2c7b583b3aaed1902ca3cca2387414391fc3fe65 (patch) | |
tree | fd69a4d3095b0d40a5c9377e6d23f301f08cd8b0 /libqpdf/QPDFJob_config.cc | |
parent | ac56e013d6fb55df85216261228226849fcbab02 (diff) | |
download | qpdf-2c7b583b3aaed1902ca3cca2387414391fc3fe65.tar.zst |
QPDFJob: move input/output handling into config
Diffstat (limited to 'libqpdf/QPDFJob_config.cc')
-rw-r--r-- | libqpdf/QPDFJob_config.cc | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc index 9eb03ae3..ad578130 100644 --- a/libqpdf/QPDFJob_config.cc +++ b/libqpdf/QPDFJob_config.cc @@ -9,6 +9,72 @@ static void usage(std::string const& msg) } QPDFJob::Config& +QPDFJob::Config::inputFile(char const* filename) +{ + if (o.infilename == 0) + { + o.infilename = QUtil::make_shared_cstr(filename); + } + else + { + usage("input file has already been given"); + } + return *this; +} + +QPDFJob::Config& +QPDFJob::Config::emptyInput() +{ + if (o.infilename == 0) + { + // QXXXQ decide whether to fix this or just leave the comment: + // 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. + o.infilename = QUtil::make_shared_cstr(""); + } + else + { + usage("empty input can't be used" + " since input file has already been given"); + } + return *this; +} + +QPDFJob::Config& +QPDFJob::Config::outputFile(char const* filename) +{ + if ((o.outfilename == 0) && (! o.replace_input)) + { + o.outfilename = QUtil::make_shared_cstr(filename); + } + else + { + usage("output file has already been given"); + } + return *this; +} + +QPDFJob::Config& +QPDFJob::Config::replaceInput() +{ + if ((o.outfilename == 0) && (! o.replace_input)) + { + o.replace_input = true; + } + else + { + usage("replace-input can't be used" + " since output file has already been given"); + } + return *this; +} + +QPDFJob::Config& QPDFJob::Config::allowWeakCrypto() { o.allow_weak_crypto = true; |