Skip to content

Commit

Permalink
readers: simplify jgf reader unpack logic
Browse files Browse the repository at this point in the history
Problem: the JGF reader's vertex-unpacking logic is unnecessarily
complicated.

Simplify it.
  • Loading branch information
jameshcorbett committed Sep 18, 2024
1 parent b0018b3 commit 269ac34
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions resource/readers/resource_reader_jgf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ int resource_reader_jgf_t::fill_fetcher (json_t *element,
json_t **properties)
{
int rc = -1;
json_t *p = NULL;
json_t *metadata = NULL;

if ((json_unpack (element, "{ s:s }", "id", &f.vertex_id) < 0)) {
Expand All @@ -364,7 +363,7 @@ int resource_reader_jgf_t::fill_fetcher (json_t *element,
goto done;
}
if ((json_unpack (metadata,
"{ s:s s:s s:s s:I s:I s:I s?:i s:b s:s s:I }",
"{ s:s s:s s:s s:I s:I s:I s?:i s:b s:s s:I s:o s?o }",
"type",
&f.type,
"basename",
Expand All @@ -384,23 +383,18 @@ int resource_reader_jgf_t::fill_fetcher (json_t *element,
"unit",
&f.unit,
"size",
&f.size))
&f.size,
"paths",
paths,
"properties",
properties))
< 0) {
errno = EINVAL;
m_err_msg += __FUNCTION__;
m_err_msg += ": malformed metadata in an JGF node for ";
m_err_msg += std::string (f.vertex_id) + "\n";
goto done;
}
if ((p = json_object_get (metadata, "paths")) == NULL) {
errno = EINVAL;
m_err_msg += __FUNCTION__;
m_err_msg += ": key (paths) does not exist in an JGF node for ";
m_err_msg += std::string (f.vertex_id) + ".\n";
goto done;
}
*properties = json_object_get (metadata, "properties");
*paths = p;
if (*properties && !json_is_object (*properties)) {
errno = EINVAL;
m_err_msg += __FUNCTION__;
Expand Down

0 comments on commit 269ac34

Please sign in to comment.