Skip to content

Commit

Permalink
Implement openPMD_Attributable_attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Oct 28, 2023
1 parent 76ed527 commit 3326bb6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/binding/c/Iteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void openPMD_Iteration_setTime(openPMD_Iteration *iteration, double newTime)
cxx_iteration->setTime(newTime);
}

double dt(const openPMD_Iteration *iteration)
double openPMD_Iteration_dt(const openPMD_Iteration *iteration)
{
const auto cxx_iteration = (const openPMD::Iteration *)iteration;
return cxx_iteration->dt<double>();
Expand Down
12 changes: 12 additions & 0 deletions src/binding/c/backend/Attributable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ bool openPMD_Attributable_deleteAttribute(
return cxx_attributable->deleteAttribute(std::string(key));
}

char **openPMD_Attributable_attributes(const openPMD_Attributable *attributable)
{
const auto cxx_attributable = (const openPMD::Attributable *)attributable;
const auto cxx_attributes = cxx_attributable->attributes();
const std::size_t num_attributes = cxx_attributes.size();
char **const attributes =
(char **)malloc(num_attributes * sizeof *attributes);
for (std::size_t n = 0; n < num_attributes; ++n)
attributes[n] = strdup(cxx_attributes[n].c_str());
return attributes;
}

size_t
openPMD_Attributable_numAttributes(const openPMD_Attributable *attributable)
{
Expand Down

0 comments on commit 3326bb6

Please sign in to comment.