Skip to content

Commit

Permalink
Move h5t_* to separate file. (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc authored Nov 24, 2023
1 parent 61fa102 commit 9314815
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 58 deletions.
59 changes: 1 addition & 58 deletions include/highfive/bits/H5DataType_misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<DataTypeException>("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<DataTypeException>("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<DataTypeException>("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<DataTypeException>("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<DataTypeException>("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<DataTypeException>("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<DataTypeException>("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);
Expand Down
63 changes: 63 additions & 0 deletions include/highfive/bits/h5t_wrapper.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#pragma once

#include <H5Tpublic.h>

namespace HighFive {
namespace detail {

inline hid_t h5t_copy(hid_t original) {
auto copy = H5Tcopy(original);
if (copy == H5I_INVALID_HID) {
HDF5ErrMapper::ToException<DataTypeException>("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<DataTypeException>("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<DataTypeException>("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<DataTypeException>("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<DataTypeException>("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<DataTypeException>("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<DataTypeException>("Error setting strpad of datatype.");
}
}

} // namespace detail
} // namespace HighFive

0 comments on commit 9314815

Please sign in to comment.