mirror of https://github.com/qpdf/qpdf.git
QPDFJob: add checkConfiguration to Config
This commit is contained in:
parent
0c8e9e5912
commit
8a9100f674
|
@ -35,7 +35,8 @@ int main(int argc, char* argv[])
|
|||
->pages()
|
||||
->pageSpec(".", "1-z")
|
||||
->endPages()
|
||||
->qdf();
|
||||
->qdf()
|
||||
->checkConfiguration();
|
||||
j.run();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
#include <qpdf/QTC.hh>
|
||||
#include <cstring>
|
||||
|
||||
void
|
||||
QPDFJob::Config::checkConfiguration()
|
||||
{
|
||||
o.checkConfiguration();
|
||||
}
|
||||
|
||||
QPDFJob::Config*
|
||||
QPDFJob::Config::inputFile(char const* filename)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue