From 3d85e9f90fe8f23dd4e809ac189a41548925c860 Mon Sep 17 00:00:00 2001 From: Christian Hovy Date: Tue, 6 Mar 2018 10:08:31 +0100 Subject: [PATCH] [C] Added getter for savepoint meta-infos to FortranWrapper --- src/serialbox-c/FortranWrapper.cpp | 36 ++++++++++++++++++++++++++++++ src/serialbox-c/FortranWrapper.h | 18 +++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/src/serialbox-c/FortranWrapper.cpp b/src/serialbox-c/FortranWrapper.cpp index 2e5a51f4..311edba1 100644 --- a/src/serialbox-c/FortranWrapper.cpp +++ b/src/serialbox-c/FortranWrapper.cpp @@ -420,3 +420,39 @@ void serialboxFortranSavepointAddMetainfoString(void* savepoint, const char* key serialboxFatalError(e.what()); } } + +void serialboxFortranSavepointGetMetainfoBoolean(void* savepoint, const char* key, int* value) { + Savepoint* sp = toSavepoint(static_cast(savepoint)); + try { + *value = (int) sp->template getMetainfoAs(key); + } catch(std::exception& e) { + serialboxFatalError(e.what()); + } +} + +void serialboxFortranSavepointGetMetainfoInt32(void* savepoint, const char* key, int* value) { + Savepoint* sp = toSavepoint(static_cast(savepoint)); + try { + *value = sp->template getMetainfoAs(key); + } catch(std::exception& e) { + serialboxFatalError(e.what()); + } +} + +void serialboxFortranSavepointGetMetainfoFloat32(void* savepoint, const char* key, float* value) { + Savepoint* sp = toSavepoint(static_cast(savepoint)); + try { + *value = sp->template getMetainfoAs(key); + } catch(std::exception& e) { + serialboxFatalError(e.what()); + } +} + +void serialboxFortranSavepointGetMetainfoFloat64(void* savepoint, const char* key, double* value) { + Savepoint* sp = toSavepoint(static_cast(savepoint)); + try { + *value = sp->template getMetainfoAs(key); + } catch(std::exception& e) { + serialboxFatalError(e.what()); + } +} diff --git a/src/serialbox-c/FortranWrapper.h b/src/serialbox-c/FortranWrapper.h index de58c527..deb3e4f8 100644 --- a/src/serialbox-c/FortranWrapper.h +++ b/src/serialbox-c/FortranWrapper.h @@ -204,6 +204,24 @@ void serialboxFortranSavepointAddMetainfoString(void* savepoint, const char* key const char* value); /** @} */ +/** + * \brief Get a meta-information `key=value` pair from the `savepoint` + * + * This function corresponds to `fs_get_savepoint_metainfo_X` + * + * \param savepoint Savepoint to use + * \param key Key of the new element + * \param value Destination object for the value of the existing element + * @{ + */ +void serialboxFortranSavepointGetMetainfoBoolean(void* savepoint, const char* key, int* value); +void serialboxFortranSavepointGetMetainfoInt32(void* savepoint, const char* key, int* value); +void serialboxFortranSavepointGetMetainfoFloat32(void* savepoint, const char* key, float* value); +void serialboxFortranSavepointGetMetainfoFloat64(void* savepoint, const char* key, double* value); +//void serialboxFortranSavepointGetMetainfoString(void* savepoint, const char* key, +// const char** value); +/** @} */ + /** @} @} */ #ifdef __cplusplus