aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFJob_json.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libqpdf/QPDFJob_json.cc')
-rw-r--r--libqpdf/QPDFJob_json.cc24
1 files changed, 6 insertions, 18 deletions
diff --git a/libqpdf/QPDFJob_json.cc b/libqpdf/QPDFJob_json.cc
index fefe8fff..83bc856c 100644
--- a/libqpdf/QPDFJob_json.cc
+++ b/libqpdf/QPDFJob_json.cc
@@ -59,7 +59,7 @@ namespace
void beginUnderOverlay(JSON const& j);
- std::list<std::shared_ptr<JSONHandler>> json_handlers;
+ std::vector<std::shared_ptr<JSONHandler>> json_handlers;
bool partial;
JSONHandler* jh{nullptr}; // points to last of json_handlers
std::shared_ptr<QPDFJob::Config> c_main;
@@ -100,7 +100,7 @@ Handlers::bindJSON(void (Handlers::*f)(JSON))
void
Handlers::initHandlers()
{
- this->json_handlers.push_back(std::make_shared<JSONHandler>());
+ this->json_handlers.emplace_back(std::make_shared<JSONHandler>());
this->jh = this->json_handlers.back().get();
jh->addDictHandlers(
[](std::string const&, JSON) {},
@@ -184,8 +184,8 @@ Handlers::pushKey(std::string const& key)
{
auto new_jh = std::make_shared<JSONHandler>();
this->jh->addDictKeyHandler(key, new_jh);
- this->json_handlers.push_back(new_jh);
this->jh = new_jh.get();
+ this->json_handlers.emplace_back(std::move(new_jh));
}
void
@@ -205,8 +205,8 @@ Handlers::beginArray(json_handler_t start_fn, bare_handler_t end_fn)
[end_fn](std::string const&) { end_fn(); },
item_jh);
jh->addFallbackHandler(item_jh);
- this->json_handlers.push_back(item_jh);
this->jh = item_jh.get();
+ this->json_handlers.emplace_back(std::move(item_jh));
}
void
@@ -232,14 +232,8 @@ void
Handlers::beginUnderOverlay(JSON const& j)
{
// File has to be processed before items, so handle it here.
- bool file_seen = false;
std::string file;
- j.forEachDictItem([&](std::string const& key, JSON const& value) {
- if (key == "file") {
- file_seen = value.getString(file);
- }
- });
- if (!file_seen) {
+ if (!j.getDictItem("file").getString(file)) {
QTC::TC("qpdf", "QPDFJob json over/under no file");
usage("file is required in underlay/overlay specification");
}
@@ -488,14 +482,8 @@ Handlers::endPagesArray()
void
Handlers::beginPages(JSON j)
{
- bool file_seen = false;
std::string file;
- j.forEachDictItem([&](std::string const& key, JSON const& value) {
- if (key == "file") {
- file_seen = value.getString(file);
- }
- });
- if (!file_seen) {
+ if (!j.getDictItem("file").getString(file)) {
QTC::TC("qpdf", "QPDFJob json pages no file");
usage("file is required in page specification");
}