HighFive 2.10.1
HighFive - Header-only C++ HDF5 interface
Loading...
Searching...
No Matches
h5l_wrapper.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <H5Lpublic.h>
4
5namespace HighFive {
6namespace detail {
7
8inline herr_t h5l_create_external(const char* file_name,
9 const char* obj_name,
10 hid_t link_loc_id,
11 const char* link_name,
12 hid_t lcpl_id,
13 hid_t lapl_id) {
14 herr_t err = H5Lcreate_external(file_name, obj_name, link_loc_id, link_name, lcpl_id, lapl_id);
15 if (err < 0) {
16 HDF5ErrMapper::ToException<GroupException>(std::string("Unable to create external link: "));
17 }
18
19 return err;
20}
21
22inline herr_t h5l_create_soft(const char* link_target,
23 hid_t link_loc_id,
24 const char* link_name,
25 hid_t lcpl_id,
26 hid_t lapl_id) {
27 herr_t err = H5Lcreate_soft(link_target, link_loc_id, link_name, lcpl_id, lapl_id);
28 if (err < 0) {
29 HDF5ErrMapper::ToException<GroupException>(std::string("Unable to create soft link: "));
30 }
31
32 return err;
33}
34
35inline herr_t h5l_create_hard(hid_t cur_loc,
36 const char* cur_name,
37 hid_t dst_loc,
38 const char* dst_name,
39 hid_t lcpl_id,
40 hid_t lapl_id) {
41 herr_t err = H5Lcreate_hard(cur_loc, cur_name, dst_loc, dst_name, lcpl_id, lapl_id);
42 if (err < 0) {
43 HDF5ErrMapper::ToException<GroupException>(std::string("Unable to create hard link: "));
44 }
45
46 return err;
47}
48
49inline herr_t h5l_get_info(hid_t loc_id, const char* name, H5L_info_t* linfo, hid_t lapl_id) {
50 herr_t err = H5Lget_info(loc_id, name, linfo, lapl_id);
51 if (err < 0) {
52 HDF5ErrMapper::ToException<GroupException>(std::string("Unable to obtain info for link "));
53 }
54
55 return err;
56}
57
58inline herr_t h5l_delete(hid_t loc_id, const char* name, hid_t lapl_id) {
59 herr_t err = H5Ldelete(loc_id, name, lapl_id);
60 if (err < 0) {
61 HDF5ErrMapper::ToException<GroupException>(std::string("Invalid name for unlink() "));
62 }
63
64 return err;
65}
66
67inline htri_t h5l_exists(hid_t loc_id, const char* name, hid_t lapl_id) {
68 htri_t tri = H5Lexists(loc_id, name, lapl_id);
69 if (tri < 0) {
70 HDF5ErrMapper::ToException<GroupException>("Invalid link for exist()");
71 }
72
73 return tri;
74}
75
76namespace nothrow {
77
78inline htri_t h5l_exists(hid_t loc_id, const char* name, hid_t lapl_id) {
79 return H5Lexists(loc_id, name, lapl_id);
80}
81
82} // namespace nothrow
83
84inline herr_t h5l_iterate(hid_t grp_id,
85 H5_index_t idx_type,
86 H5_iter_order_t order,
87 hsize_t* idx,
88 H5L_iterate_t op,
89 void* op_data) {
90 herr_t err = H5Literate(grp_id, idx_type, order, idx, op, op_data);
91 if (err < 0) {
92 HDF5ErrMapper::ToException<GroupException>(std::string("Unable to list objects in group"));
93 }
94 return err;
95}
96
97inline herr_t h5l_move(hid_t src_loc,
98 const char* src_name,
99 hid_t dst_loc,
100 const char* dst_name,
101 hid_t lcpl_id,
102 hid_t lapl_id) {
103 herr_t err = H5Lmove(src_loc, src_name, dst_loc, dst_name, lcpl_id, lapl_id);
104
105 if (err < 0) {
106 HDF5ErrMapper::ToException<GroupException>(std::string("Unable to move link to \"") +
107 dst_name + "\":");
108 }
109 return err;
110}
111
112inline ssize_t h5l_get_name_by_idx(hid_t loc_id,
113 const char* group_name,
114 H5_index_t idx_type,
115 H5_iter_order_t order,
116 hsize_t n,
117 char* name,
118 size_t size,
119 hid_t lapl_id) {
120 ssize_t n_chars =
121 H5Lget_name_by_idx(loc_id, group_name, idx_type, order, n, name, size, lapl_id);
122
123 if (n_chars < 0) {
125 std::string("Unable to obtain link name from index."));
126 }
127
128 return n_chars;
129}
130
131} // namespace detail
132} // namespace HighFive
Definition H5_definitions.hpp:22
static void ToException(const std::string &prefix_msg)
Definition H5Exception_misc.hpp:43