Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-20 08:14:34

0001 #pragma once
0002 
0003 #include <H5Dpublic.h>
0004 #include <H5Ipublic.h>
0005 
0006 namespace HighFive {
0007 namespace detail {
0008 
0009 
0010 #if !H5_VERSION_GE(1, 12, 0)
0011 inline herr_t h5d_vlen_reclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void* buf) {
0012     herr_t err = H5Dvlen_reclaim(type_id, space_id, dxpl_id, buf);
0013     if (err < 0) {
0014         throw DataSetException("Failed to reclaim HDF5 internal memory");
0015     }
0016 
0017     return err;
0018 }
0019 #endif
0020 
0021 inline hsize_t h5d_get_storage_size(hid_t dset_id) {
0022     // Docs:
0023     //    H5Dget_storage_size() does not differentiate between 0 (zero), the
0024     //    value returned for the storage size of a dataset with no stored values,
0025     //    and 0 (zero), the value returned to indicate an error.
0026     return H5Dget_storage_size(dset_id);
0027 }
0028 
0029 inline hid_t h5d_get_space(hid_t dset_id) {
0030     hid_t dset = H5Dget_space(dset_id);
0031     if (dset == H5I_INVALID_HID) {
0032         HDF5ErrMapper::ToException<DataSetException>(
0033             std::string("Unable to get dataspace of the dataset"));
0034     }
0035 
0036     return dset;
0037 }
0038 
0039 inline hid_t h5d_get_type(hid_t dset_id) {
0040     hid_t type_id = H5Dget_type(dset_id);
0041     if (type_id == H5I_INVALID_HID) {
0042         HDF5ErrMapper::ToException<DataSetException>(
0043             std::string("Unable to get datatype of the dataset"));
0044     }
0045 
0046     return type_id;
0047 }
0048 
0049 inline herr_t h5d_read(hid_t dset_id,
0050                        hid_t mem_type_id,
0051                        hid_t mem_space_id,
0052                        hid_t file_space_id,
0053                        hid_t dxpl_id,
0054                        void* buf) {
0055     herr_t err = H5Dread(dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf);
0056     if (err < 0) {
0057         HDF5ErrMapper::ToException<DataSetException>(std::string("Unable to read the dataset"));
0058     }
0059 
0060     return err;
0061 }
0062 
0063 inline herr_t h5d_write(hid_t dset_id,
0064                         hid_t mem_type_id,
0065                         hid_t mem_space_id,
0066                         hid_t file_space_id,
0067                         hid_t dxpl_id,
0068                         const void* buf) {
0069     herr_t err = H5Dwrite(dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf);
0070     if (err < 0) {
0071         HDF5ErrMapper::ToException<DataSetException>(std::string("Unable to write the dataset"));
0072     }
0073 
0074     return err;
0075 }
0076 
0077 #if H5_VERSION_GE(1, 10, 0)
0078 inline herr_t h5d_flush(hid_t dset_id) {
0079     herr_t err = H5Dflush(dset_id);
0080     if (err < 0) {
0081         HDF5ErrMapper::ToException<DataSetException>("Unable to flush the dataset.");
0082     }
0083 
0084     return err;
0085 }
0086 #endif
0087 
0088 #if H5_VERSION_GE(1, 10, 2)
0089 inline herr_t h5d_refresh(hid_t dset_id) {
0090     herr_t err = H5Drefresh(dset_id);
0091     if (err < 0) {
0092         HDF5ErrMapper::ToException<DataSetException>("Unable to refresh the dataset.");
0093     }
0094 
0095     return err;
0096 }
0097 #endif
0098 
0099 inline haddr_t h5d_get_offset(hid_t dset_id) {
0100     uint64_t addr = H5Dget_offset(dset_id);
0101     if (addr == HADDR_UNDEF) {
0102         HDF5ErrMapper::ToException<DataSetException>("Cannot get offset of DataSet.");
0103     }
0104     return addr;
0105 }
0106 
0107 
0108 inline herr_t h5d_set_extent(hid_t dset_id, const hsize_t size[]) {
0109     herr_t err = H5Dset_extent(dset_id, size);
0110     if (err < 0) {
0111         HDF5ErrMapper::ToException<DataSetException>("Could not resize dataset.");
0112     }
0113 
0114     return err;
0115 }
0116 
0117 inline hid_t h5d_create2(hid_t loc_id,
0118                          const char* name,
0119                          hid_t type_id,
0120                          hid_t space_id,
0121                          hid_t lcpl_id,
0122                          hid_t dcpl_id,
0123                          hid_t dapl_id) {
0124     hid_t dataset_id = H5Dcreate2(loc_id, name, type_id, space_id, lcpl_id, dcpl_id, dapl_id);
0125 
0126     if (dataset_id == H5I_INVALID_HID) {
0127         HDF5ErrMapper::ToException<DataSetException>(
0128             std::string("Failed to create the dataset \"") + name + "\":");
0129     }
0130 
0131     return dataset_id;
0132 }
0133 
0134 inline hid_t h5d_open2(hid_t loc_id, const char* name, hid_t dapl_id) {
0135     hid_t dataset_id = H5Dopen2(loc_id, name, dapl_id);
0136 
0137     if (dataset_id == H5I_INVALID_HID) {
0138         HDF5ErrMapper::ToException<DataSetException>(std::string("Unable to open the dataset \"") +
0139                                                      name + "\":");
0140     }
0141 
0142     return dataset_id;
0143 }
0144 
0145 
0146 }  // namespace detail
0147 }  // namespace HighFive