From 3326bb6823dcd03f0a4d6ff64f426a40f51f9ef3 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sat, 28 Oct 2023 17:06:59 -0400 Subject: [PATCH] Implement openPMD_Attributable_attributes --- src/binding/c/Iteration.cpp | 2 +- src/binding/c/backend/Attributable.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/binding/c/Iteration.cpp b/src/binding/c/Iteration.cpp index f662162e13..8dcf5f39fe 100644 --- a/src/binding/c/Iteration.cpp +++ b/src/binding/c/Iteration.cpp @@ -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(); diff --git a/src/binding/c/backend/Attributable.cpp b/src/binding/c/backend/Attributable.cpp index b913a7ae5d..3b47740b07 100644 --- a/src/binding/c/backend/Attributable.cpp +++ b/src/binding/c/backend/Attributable.cpp @@ -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) {