From 1355d95d0811942758036e23d64ed6b9fb7c8317 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 30 Jan 2022 14:39:38 -0500 Subject: QPDFJob: partial mode for initializeFromJson --- libqpdf/QPDFJob_json.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'libqpdf/QPDFJob_json.cc') diff --git a/libqpdf/QPDFJob_json.cc b/libqpdf/QPDFJob_json.cc index 02e851b0..6525b761 100644 --- a/libqpdf/QPDFJob_json.cc +++ b/libqpdf/QPDFJob_json.cc @@ -15,7 +15,7 @@ namespace class Handlers { public: - Handlers(std::shared_ptr c_main); + Handlers(bool partial, std::shared_ptr c_main); void handle(JSON&); private: @@ -47,6 +47,7 @@ namespace setup_handler_t bindSetup(void (Handlers::*f)(std::string const&)); std::list> json_handlers; + bool partial; JSONHandler* jh; // points to last of json_handlers std::shared_ptr c_main; std::shared_ptr c_copy_att; @@ -57,7 +58,8 @@ namespace }; } -Handlers::Handlers(std::shared_ptr c_main) : +Handlers::Handlers(bool partial, std::shared_ptr c_main) : + partial(partial), jh(nullptr), c_main(c_main) { @@ -95,7 +97,12 @@ Handlers::initHandlers() this->jh = this->json_handlers.back().get(); jh->addDictHandlers( [](std::string const&, JSON){}, - [this](std::string const&){c_main->checkConfiguration();}); + [this](std::string const&){ + if (! this->partial) + { + c_main->checkConfiguration(); + } + }); # include @@ -623,7 +630,7 @@ Handlers::setupOptionsUnderlayPassword(std::string const& key) } void -QPDFJob::initializeFromJson(std::string const& json) +QPDFJob::initializeFromJson(std::string const& json, bool partial) { std::list errors; JSON j = JSON::parse(json); @@ -639,5 +646,5 @@ QPDFJob::initializeFromJson(std::string const& json) throw std::runtime_error(msg.str()); } - Handlers(config()).handle(j); + Handlers(partial, config()).handle(j); } -- cgit v1.2.3-54-g00ecf