HighFive 2.10.0
HighFive - Header-only C++ HDF5 interface
Loading...
Searching...
No Matches
h5i_wrapper.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <H5Ipublic.h>
4
5namespace HighFive {
6namespace detail {
7inline int h5i_inc_ref(hid_t id) {
8 auto count = H5Iinc_ref(id);
9
10 if (count < 0) {
11 throw ObjectException("Failed to increase reference count of HID");
12 }
13
14 return count;
15}
16
17namespace nothrow {
18
19inline int h5i_dec_ref(hid_t id) {
20 return H5Idec_ref(id);
21}
22
23} // namespace nothrow
24
25inline int h5i_dec_ref(hid_t id) {
26 int count = H5Idec_ref(id);
27 if (count < 0) {
28 throw ObjectException("Failed to decrease reference count of HID");
29 }
30
31 return count;
32}
33
34namespace nothrow {
35inline htri_t h5i_is_valid(hid_t id) {
36 return H5Iis_valid(id);
37}
38
39} // namespace nothrow
40
41inline htri_t h5i_is_valid(hid_t id) {
42 htri_t tri = H5Iis_valid(id);
43 if (tri < 0) {
44 throw ObjectException("Failed to check if HID is valid");
45 }
46
47 return tri;
48}
49
50inline H5I_type_t h5i_get_type(hid_t id) {
51 H5I_type_t type = H5Iget_type(id);
52 if (type == H5I_BADID) {
53 HDF5ErrMapper::ToException<ObjectException>("Failed to get type of HID");
54 }
55
56 return type;
57}
58
59template <class Exception>
60inline hid_t h5i_get_file_id(hid_t id) {
61 hid_t file_id = H5Iget_file_id(id);
62 if (file_id < 0) {
63 HDF5ErrMapper::ToException<Exception>("Failed not obtain file HID of object");
64 }
65
66 return file_id;
67}
68
69inline ssize_t h5i_get_name(hid_t id, char* name, size_t size) {
70 ssize_t n_chars = H5Iget_name(id, name, size);
71 if (n_chars < 0) {
72 HDF5ErrMapper::ToException<ObjectException>("Failed to get name of HID.");
73 }
74
75 return n_chars;
76}
77
78} // namespace detail
79} // namespace HighFive
Definition H5_definitions.hpp:22
static void ToException(const std::string &prefix_msg)
Definition H5Exception_misc.hpp:43