aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/JSONHandler.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2023-05-21 19:35:09 +0200
committerJay Berkenbilt <ejb@ql.org>2023-05-21 19:35:09 +0200
commit60965d5f4d608bdccc2ffd4e8753e12cbbbd71d2 (patch)
treea707602da466c02ff1a54b3263c3a881cd7204a4 /libqpdf/JSONHandler.cc
parent6b077332d38c093de2618d5e1481b42222106065 (diff)
downloadqpdf-60965d5f4d608bdccc2ffd4e8753e12cbbbd71d2.tar.zst
Rerun clang-format
Diffstat (limited to 'libqpdf/JSONHandler.cc')
-rw-r--r--libqpdf/JSONHandler.cc35
1 files changed, 14 insertions, 21 deletions
diff --git a/libqpdf/JSONHandler.cc b/libqpdf/JSONHandler.cc
index d169780d..f4360a2d 100644
--- a/libqpdf/JSONHandler.cc
+++ b/libqpdf/JSONHandler.cc
@@ -53,8 +53,7 @@ JSONHandler::addDictHandlers(json_handler_t start_fn, void_handler_t end_fn)
}
void
-JSONHandler::addDictKeyHandler(
- std::string const& key, std::shared_ptr<JSONHandler> dkh)
+JSONHandler::addDictKeyHandler(std::string const& key, std::shared_ptr<JSONHandler> dkh)
{
m->h.dict_handlers[key] = dkh;
}
@@ -67,9 +66,7 @@ JSONHandler::addFallbackDictHandler(std::shared_ptr<JSONHandler> fdh)
void
JSONHandler::addArrayHandlers(
- json_handler_t start_fn,
- void_handler_t end_fn,
- std::shared_ptr<JSONHandler> ah)
+ json_handler_t start_fn, void_handler_t end_fn, std::shared_ptr<JSONHandler> ah)
{
m->h.array_start_handler = start_fn;
m->h.array_end_handler = end_fn;
@@ -108,22 +105,19 @@ JSONHandler::handle(std::string const& path, JSON j)
if (path_base != ".") {
path_base += ".";
}
- j.forEachDictItem(
- [&path, &path_base, this](std::string const& k, JSON v) {
- auto i = m->h.dict_handlers.find(k);
- if (i == m->h.dict_handlers.end()) {
- if (m->h.fallback_dict_handler.get()) {
- m->h.fallback_dict_handler->handle(path_base + k, v);
- } else {
- QTC::TC("libtests", "JSONHandler unexpected key");
- usage(
- "JSON handler found unexpected key " + k +
- " in object at " + path);
- }
+ j.forEachDictItem([&path, &path_base, this](std::string const& k, JSON v) {
+ auto i = m->h.dict_handlers.find(k);
+ if (i == m->h.dict_handlers.end()) {
+ if (m->h.fallback_dict_handler.get()) {
+ m->h.fallback_dict_handler->handle(path_base + k, v);
} else {
- i->second->handle(path_base + k, v);
+ QTC::TC("libtests", "JSONHandler unexpected key");
+ usage("JSON handler found unexpected key " + k + " in object at " + path);
}
- });
+ } else {
+ i->second->handle(path_base + k, v);
+ }
+ });
m->h.dict_end_handler(path);
handled = true;
}
@@ -131,8 +125,7 @@ JSONHandler::handle(std::string const& path, JSON j)
m->h.array_start_handler(path, j);
size_t i = 0;
j.forEachArrayItem([&i, &path, this](JSON v) {
- m->h.array_item_handler->handle(
- path + "[" + std::to_string(i) + "]", v);
+ m->h.array_item_handler->handle(path + "[" + std::to_string(i) + "]", v);
++i;
});
m->h.array_end_handler(path);