Skip to content

Commit

Permalink
[C] Added getter for savepoint meta-infos to FortranWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Hovy committed Mar 6, 2018
1 parent 5d801ba commit 3d85e9f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/serialbox-c/FortranWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<serialboxSavepoint_t*>(savepoint));
try {
*value = (int) sp->template getMetainfoAs<bool, const char*&>(key);
} catch(std::exception& e) {
serialboxFatalError(e.what());
}
}

void serialboxFortranSavepointGetMetainfoInt32(void* savepoint, const char* key, int* value) {
Savepoint* sp = toSavepoint(static_cast<serialboxSavepoint_t*>(savepoint));
try {
*value = sp->template getMetainfoAs<int, const char*&>(key);
} catch(std::exception& e) {
serialboxFatalError(e.what());
}
}

void serialboxFortranSavepointGetMetainfoFloat32(void* savepoint, const char* key, float* value) {
Savepoint* sp = toSavepoint(static_cast<serialboxSavepoint_t*>(savepoint));
try {
*value = sp->template getMetainfoAs<float, const char*&>(key);
} catch(std::exception& e) {
serialboxFatalError(e.what());
}
}

void serialboxFortranSavepointGetMetainfoFloat64(void* savepoint, const char* key, double* value) {
Savepoint* sp = toSavepoint(static_cast<serialboxSavepoint_t*>(savepoint));
try {
*value = sp->template getMetainfoAs<double, const char*&>(key);
} catch(std::exception& e) {
serialboxFatalError(e.what());
}
}
18 changes: 18 additions & 0 deletions src/serialbox-c/FortranWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3d85e9f

Please sign in to comment.