From f27e94ab4e60190e00520f169f72b03a9aa8e021 Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Fri, 8 Sep 2023 10:09:49 +0200 Subject: [PATCH] Move `h5t_*` to separate file. --- include/highfive/bits/H5DataType_misc.hpp | 59 +-------------------- include/highfive/bits/h5t_wrapper.hpp | 63 +++++++++++++++++++++++ 2 files changed, 64 insertions(+), 58 deletions(-) create mode 100644 include/highfive/bits/h5t_wrapper.hpp diff --git a/include/highfive/bits/H5DataType_misc.hpp b/include/highfive/bits/H5DataType_misc.hpp index 8535d617a..27f863d3d 100644 --- a/include/highfive/bits/H5DataType_misc.hpp +++ b/include/highfive/bits/H5DataType_misc.hpp @@ -23,67 +23,10 @@ #endif #include "H5Inspector_misc.hpp" +#include "h5t_wrapper.hpp" namespace HighFive { -namespace detail { - -inline hid_t h5t_copy(hid_t original) { - auto copy = H5Tcopy(original); - if (copy == H5I_INVALID_HID) { - HDF5ErrMapper::ToException("Error copying datatype."); - } - - return copy; -} - -inline hsize_t h5t_get_size(hid_t hid) { - hsize_t size = H5Tget_size(hid); - if (size == 0) { - HDF5ErrMapper::ToException("Error getting size of datatype."); - } - - return size; -} - -inline H5T_cset_t h5t_get_cset(hid_t hid) { - auto cset = H5Tget_cset(hid); - if (cset == H5T_CSET_ERROR) { - HDF5ErrMapper::ToException("Error getting cset of datatype."); - } - - return cset; -} - -inline H5T_str_t h5t_get_strpad(hid_t hid) { - auto strpad = H5Tget_strpad(hid); - if (strpad == H5T_STR_ERROR) { - HDF5ErrMapper::ToException("Error getting strpad of datatype."); - } - - return strpad; -} - -inline void h5t_set_size(hid_t hid, hsize_t size) { - if (H5Tset_size(hid, size) < 0) { - HDF5ErrMapper::ToException("Error setting size of datatype."); - } -} - -inline void h5t_set_cset(hid_t hid, H5T_cset_t cset) { - if (H5Tset_cset(hid, cset) < 0) { - HDF5ErrMapper::ToException("Error setting cset of datatype."); - } -} - -inline void h5t_set_strpad(hid_t hid, H5T_str_t strpad) { - if (H5Tset_strpad(hid, strpad) < 0) { - HDF5ErrMapper::ToException("Error setting strpad of datatype."); - } -} -} // namespace detail - - namespace { // unnamed inline DataTypeClass convert_type_class(const H5T_class_t& tclass); inline std::string type_class_string(DataTypeClass); diff --git a/include/highfive/bits/h5t_wrapper.hpp b/include/highfive/bits/h5t_wrapper.hpp new file mode 100644 index 000000000..debf626bf --- /dev/null +++ b/include/highfive/bits/h5t_wrapper.hpp @@ -0,0 +1,63 @@ +#pragma once + +#include + +namespace HighFive { +namespace detail { + +inline hid_t h5t_copy(hid_t original) { + auto copy = H5Tcopy(original); + if (copy == H5I_INVALID_HID) { + HDF5ErrMapper::ToException("Error copying datatype."); + } + + return copy; +} + +inline hsize_t h5t_get_size(hid_t hid) { + hsize_t size = H5Tget_size(hid); + if (size == 0) { + HDF5ErrMapper::ToException("Error getting size of datatype."); + } + + return size; +} + +inline H5T_cset_t h5t_get_cset(hid_t hid) { + auto cset = H5Tget_cset(hid); + if (cset == H5T_CSET_ERROR) { + HDF5ErrMapper::ToException("Error getting cset of datatype."); + } + + return cset; +} + +inline H5T_str_t h5t_get_strpad(hid_t hid) { + auto strpad = H5Tget_strpad(hid); + if (strpad == H5T_STR_ERROR) { + HDF5ErrMapper::ToException("Error getting strpad of datatype."); + } + + return strpad; +} + +inline void h5t_set_size(hid_t hid, hsize_t size) { + if (H5Tset_size(hid, size) < 0) { + HDF5ErrMapper::ToException("Error setting size of datatype."); + } +} + +inline void h5t_set_cset(hid_t hid, H5T_cset_t cset) { + if (H5Tset_cset(hid, cset) < 0) { + HDF5ErrMapper::ToException("Error setting cset of datatype."); + } +} + +inline void h5t_set_strpad(hid_t hid, H5T_str_t strpad) { + if (H5Tset_strpad(hid, strpad) < 0) { + HDF5ErrMapper::ToException("Error setting strpad of datatype."); + } +} + +} // namespace detail +} // namespace HighFive