Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 08:55:34

0001 #pragma once
0002 
0003 #include <H5Ipublic.h>
0004 #include <H5Spublic.h>
0005 namespace HighFive {
0006 namespace detail {
0007 
0008 inline hid_t h5s_create_simple(int rank, const hsize_t dims[], const hsize_t maxdims[]) {
0009     hid_t space_id = H5Screate_simple(rank, dims, maxdims);
0010     if (space_id == H5I_INVALID_HID) {
0011         throw DataSpaceException("Unable to create simple dataspace");
0012     }
0013 
0014     return space_id;
0015 }
0016 
0017 inline hid_t h5s_create(H5S_class_t type) {
0018     hid_t space_id = H5Screate(type);
0019 
0020     if (space_id == H5I_INVALID_HID) {
0021         throw DataSpaceException("Unable to create dataspace");
0022     }
0023 
0024     return space_id;
0025 }
0026 
0027 inline hid_t h5s_copy(hid_t space_id) {
0028     hid_t copy_id = H5Scopy(space_id);
0029 
0030     if (copy_id < 0) {
0031         throw DataSpaceException("Unable to copy dataspace");
0032     }
0033 
0034     return copy_id;
0035 }
0036 
0037 inline herr_t h5s_select_none(hid_t spaceid) {
0038     herr_t err = H5Sselect_none(spaceid);
0039     if (err < 0) {
0040         HDF5ErrMapper::ToException<DataSpaceException>("Unable to select None space");
0041     }
0042     return err;
0043 }
0044 
0045 inline herr_t h5s_select_hyperslab(hid_t space_id,
0046                                    H5S_seloper_t op,
0047                                    const hsize_t start[],
0048                                    const hsize_t stride[],
0049                                    const hsize_t count[],
0050                                    const hsize_t block[]) {
0051     herr_t err = H5Sselect_hyperslab(space_id, op, start, stride, count, block);
0052     if (err < 0) {
0053         HDF5ErrMapper::ToException<DataSpaceException>("Unable to select hyperslab");
0054     }
0055     return err;
0056 }
0057 
0058 inline hssize_t h5s_get_select_npoints(hid_t spaceid) {
0059     hssize_t n_points = H5Sget_select_npoints(spaceid);
0060     if (n_points < 0) {
0061         HDF5ErrMapper::ToException<DataSpaceException>(
0062             "Unable to get number of points in selection");
0063     }
0064     return n_points;
0065 }
0066 
0067 inline herr_t h5s_select_elements(hid_t space_id,
0068                                   H5S_seloper_t op,
0069                                   size_t num_elem,
0070                                   const hsize_t* coord) {
0071     herr_t err = H5Sselect_elements(space_id, op, num_elem, coord);
0072     if (err < 0) {
0073         HDF5ErrMapper::ToException<DataSpaceException>("Unable to select elements");
0074     }
0075     return err;
0076 }
0077 
0078 inline int h5s_get_simple_extent_ndims(hid_t space_id) {
0079     int ndim = H5Sget_simple_extent_ndims(space_id);
0080     if (ndim < 0) {
0081         HDF5ErrMapper::ToException<DataSetException>(
0082             "Unable to get number of dimensions of dataspace");
0083     }
0084     return ndim;
0085 }
0086 
0087 inline herr_t h5s_get_simple_extent_dims(hid_t space_id, hsize_t dims[], hsize_t maxdims[]) {
0088     herr_t err = H5Sget_simple_extent_dims(space_id, dims, maxdims);
0089     if (err < 0) {
0090         HDF5ErrMapper::ToException<DataSetException>("Unable to get dimensions of dataspace");
0091     }
0092     return err;
0093 }
0094 
0095 inline hssize_t h5s_get_simple_extent_npoints(hid_t space_id) {
0096     hssize_t nelements = H5Sget_simple_extent_npoints(space_id);
0097     if (nelements < 0) {
0098         HDF5ErrMapper::ToException<DataSetException>(
0099             "Unable to get number of elements in dataspace");
0100     }
0101 
0102     return nelements;
0103 }
0104 
0105 inline H5S_class_t h5s_get_simple_extent_type(hid_t space_id) {
0106     H5S_class_t cls = H5Sget_simple_extent_type(space_id);
0107     if (cls == H5S_NO_CLASS) {
0108         HDF5ErrMapper::ToException<DataSpaceException>("Unable to get class of simple dataspace.");
0109     }
0110 
0111     return cls;
0112 }
0113 
0114 inline H5S_sel_type h5s_get_select_type(hid_t space_id) {
0115     H5S_sel_type type = H5Sget_select_type(space_id);
0116     if (type < 0) {
0117         HDF5ErrMapper::ToException<DataSpaceException>("Unable to get type of selection.");
0118     }
0119 
0120     return type;
0121 }
0122 
0123 #if H5_VERSION_GE(1, 10, 6)
0124 inline hid_t h5s_combine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) {
0125     auto space_id = H5Scombine_select(space1_id, op, space2_id);
0126     if (space_id == H5I_INVALID_HID) {
0127         HDF5ErrMapper::ToException<DataSpaceException>("Unable to combine two selections.");
0128     }
0129 
0130     return space_id;
0131 }
0132 #endif
0133 
0134 
0135 }  // namespace detail
0136 }  // namespace HighFive