aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/pdf-job.cc3
-rw-r--r--include/qpdf/QPDFJob.hh9
-rw-r--r--libqpdf/QPDFJob_argv.cc3
-rw-r--r--libqpdf/QPDFJob_config.cc6
-rw-r--r--libqpdf/QPDFJob_json.cc13
5 files changed, 21 insertions, 13 deletions
diff --git a/examples/pdf-job.cc b/examples/pdf-job.cc
index 238f44c0..41ee8603 100644
--- a/examples/pdf-job.cc
+++ b/examples/pdf-job.cc
@@ -35,7 +35,8 @@ int main(int argc, char* argv[])
->pages()
->pageSpec(".", "1-z")
->endPages()
- ->qdf();
+ ->qdf()
+ ->checkConfiguration();
j.run();
}
catch (std::exception& e)
diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh
index e56626a7..5178c4c1 100644
--- a/include/qpdf/QPDFJob.hh
+++ b/include/qpdf/QPDFJob.hh
@@ -90,8 +90,9 @@ class QPDFJob
// Check to make sure no contradictory options have been
// specified. This is called automatically after initializing from
// argv or json and is also called by run, but you can call it
- // manually as well. It throws a Usage exception if there are any
- // errors.
+ // manually as well. It throws a QPDFUsage exception if there are
+ // any errors. This Config object (see CONFIGURATION) also has a
+ // checkConfiguration method which calls this one.
QPDF_DLL
void checkConfiguration();
@@ -272,6 +273,10 @@ class QPDFJob
{
friend class QPDFJob;
public:
+ // Proxy to QPDFJob::checkConfiguration()
+ QPDF_DLL
+ void checkConfiguration();
+
QPDF_DLL
Config* inputFile(char const* filename);
QPDF_DLL
diff --git a/libqpdf/QPDFJob_argv.cc b/libqpdf/QPDFJob_argv.cc
index 619c5a58..73d1ec21 100644
--- a/libqpdf/QPDFJob_argv.cc
+++ b/libqpdf/QPDFJob_argv.cc
@@ -64,6 +64,7 @@ ArgParser::initOptionTables()
{
# include <qpdf/auto_job_init.hh>
+ this->ap.addFinalCheck([this](){c_main->checkConfiguration();});
// add_help is defined in auto_job_help.hh
add_help(this->ap);
}
@@ -496,7 +497,5 @@ QPDFJob::initializeFromArgv(int argc, char* argv[], char const* progname_env)
QPDFArgParser qap(argc, argv, progname_env);
setMessagePrefix(qap.getProgname());
ArgParser ap(qap, config());
- qap.addFinalCheck(
- QPDFArgParser::bindBare(&QPDFJob::checkConfiguration, this));
ap.parseOptions();
}
diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc
index 53032cea..81d7d09b 100644
--- a/libqpdf/QPDFJob_config.cc
+++ b/libqpdf/QPDFJob_config.cc
@@ -3,6 +3,12 @@
#include <qpdf/QTC.hh>
#include <cstring>
+void
+QPDFJob::Config::checkConfiguration()
+{
+ o.checkConfiguration();
+}
+
QPDFJob::Config*
QPDFJob::Config::inputFile(char const* filename)
{
diff --git a/libqpdf/QPDFJob_json.cc b/libqpdf/QPDFJob_json.cc
index 2d6b265e..ddd63dcd 100644
--- a/libqpdf/QPDFJob_json.cc
+++ b/libqpdf/QPDFJob_json.cc
@@ -12,7 +12,7 @@ namespace
class Handlers
{
public:
- Handlers(JSONHandler& jh, std::shared_ptr<QPDFJob::Config> c_main);
+ Handlers(std::shared_ptr<QPDFJob::Config> c_main);
void handle(JSON&);
private:
@@ -21,7 +21,7 @@ namespace
void usage(std::string const& message);
void initHandlers();
- JSONHandler& jh;
+ JSONHandler jh;
std::shared_ptr<QPDFJob::Config> c_main;
std::shared_ptr<QPDFJob::CopyAttConfig> c_copy_att;
std::shared_ptr<QPDFJob::AttConfig> c_att;
@@ -31,8 +31,7 @@ namespace
};
}
-Handlers::Handlers(JSONHandler& jh, std::shared_ptr<QPDFJob::Config> c_main) :
- jh(jh),
+Handlers::Handlers(std::shared_ptr<QPDFJob::Config> c_main) :
c_main(c_main)
{
initHandlers();
@@ -44,7 +43,7 @@ Handlers::initHandlers()
//# include <qpdf/auto_job_json_init.hh>
jh.addDictHandlers(
[](std::string const&){},
- [](std::string const&){});
+ [this](std::string const&){c_main->checkConfiguration();});
auto input = std::make_shared<JSONHandler>();
auto input_file = std::make_shared<JSONHandler>();
@@ -118,7 +117,5 @@ QPDFJob::initializeFromJson(std::string const& json)
throw std::runtime_error(msg.str());
}
- JSONHandler jh;
- Handlers h(jh, config());
- h.handle(j);
+ Handlers(config()).handle(j);
}