File indexing completed on 2025-04-19 08:55:33
0001 #pragma once
0002
0003 #include <H5Ipublic.h>
0004
0005 namespace HighFive {
0006 namespace detail {
0007 inline int h5i_inc_ref(hid_t id) {
0008 auto count = H5Iinc_ref(id);
0009
0010 if (count < 0) {
0011 throw ObjectException("Failed to increase reference count of HID");
0012 }
0013
0014 return count;
0015 }
0016
0017 namespace nothrow {
0018
0019 inline int h5i_dec_ref(hid_t id) {
0020 return H5Idec_ref(id);
0021 }
0022
0023 }
0024
0025 inline int h5i_dec_ref(hid_t id) {
0026 int count = H5Idec_ref(id);
0027 if (count < 0) {
0028 throw ObjectException("Failed to decrease reference count of HID");
0029 }
0030
0031 return count;
0032 }
0033
0034 namespace nothrow {
0035 inline htri_t h5i_is_valid(hid_t id) {
0036 return H5Iis_valid(id);
0037 }
0038
0039 }
0040
0041 inline htri_t h5i_is_valid(hid_t id) {
0042 htri_t tri = H5Iis_valid(id);
0043 if (tri < 0) {
0044 throw ObjectException("Failed to check if HID is valid");
0045 }
0046
0047 return tri;
0048 }
0049
0050 inline H5I_type_t h5i_get_type(hid_t id) {
0051 H5I_type_t type = H5Iget_type(id);
0052 if (type == H5I_BADID) {
0053 HDF5ErrMapper::ToException<ObjectException>("Failed to get type of HID");
0054 }
0055
0056 return type;
0057 }
0058
0059 template <class Exception>
0060 inline hid_t h5i_get_file_id(hid_t id) {
0061 hid_t file_id = H5Iget_file_id(id);
0062 if (file_id < 0) {
0063 HDF5ErrMapper::ToException<Exception>("Failed not obtain file HID of object");
0064 }
0065
0066 return file_id;
0067 }
0068
0069 inline ssize_t h5i_get_name(hid_t id, char* name, size_t size) {
0070 ssize_t n_chars = H5Iget_name(id, name, size);
0071 if (n_chars < 0) {
0072 HDF5ErrMapper::ToException<ObjectException>("Failed to get name of HID.");
0073 }
0074
0075 return n_chars;
0076 }
0077
0078 }
0079 }