9 #ifndef H5NODE_TRAITS_MISC_HPP
10 #define H5NODE_TRAITS_MISC_HPP
18 #include "../H5Attribute.hpp"
19 #include "../H5DataSet.hpp"
20 #include "../H5DataSpace.hpp"
21 #include "../H5DataType.hpp"
22 #include "../H5Exception.hpp"
23 #include "../H5Group.hpp"
25 #include <H5Apublic.h>
26 #include <H5Dpublic.h>
27 #include <H5Fpublic.h>
28 #include <H5Gpublic.h>
29 #include <H5Ppublic.h>
30 #include <H5Tpublic.h>
34 template <
typename Derivate>
43 if ((set.
_hid = H5Dcreate2(
static_cast<Derivate*
>(
this)->getId(),
44 dataset_name.c_str(), dtype.
_hid, space.
_hid,
45 H5P_DEFAULT, createProps.
getId(),
46 accessProps.
getId())) < 0) {
47 HDF5ErrMapper::ToException<DataSetException>(
48 std::string(
"Unable to create the dataset \"") + dataset_name +
54 template <
typename Derivate>
55 template <
typename Type>
63 createProps, accessProps);
66 template <
typename Derivate>
77 createProps, accessProps);
82 template <
typename Derivate>
87 if ((set.
_hid = H5Dopen2(
static_cast<const Derivate*
>(
this)->getId(),
88 dataset_name.c_str(), accessProps.
getId())) < 0) {
89 HDF5ErrMapper::ToException<DataSetException>(
90 std::string(
"Unable to open the dataset \"") + dataset_name +
96 template <
typename Derivate>
99 if ((group.
_hid = H5Gcreate2(
static_cast<Derivate*
>(
this)->getId(),
100 group_name.c_str(), H5P_DEFAULT, H5P_DEFAULT,
102 HDF5ErrMapper::ToException<GroupException>(
103 std::string(
"Unable to create the group \"") + group_name +
"\":");
108 template <
typename Derivate>
112 if ((group.
_hid = H5Gopen2(
static_cast<const Derivate*
>(
this)->getId(),
113 group_name.c_str(), H5P_DEFAULT)) < 0) {
114 HDF5ErrMapper::ToException<GroupException>(
115 std::string(
"Unable to open the group \"") + group_name +
"\":");
120 template <
typename Derivate>
123 if (H5Gget_num_objs(
static_cast<const Derivate*
>(
this)->getId(), &res) <
125 HDF5ErrMapper::ToException<GroupException>(
126 std::string(
"Unable to count objects in existing group or file"));
131 template <
typename Derivate>
133 const ssize_t maxLength = 1023;
134 char buffer[maxLength + 1];
136 H5Lget_name_by_idx(
static_cast<const Derivate*
>(
this)->getId(),
".",
137 H5_INDEX_NAME, H5_ITER_INC, index,
138 buffer, maxLength, H5P_DEFAULT);
140 HDF5ErrMapper::ToException<GroupException>(
141 "Error accessing object name");
142 if (length <= maxLength)
143 return std::string(buffer, length);
144 std::vector<char> bigBuffer(length + 1, 0);
145 H5Lget_name_by_idx(
static_cast<const Derivate*
>(
this)->getId(),
".",
146 H5_INDEX_NAME, H5_ITER_INC, index,
147 bigBuffer.data(), length, H5P_DEFAULT);
148 return std::string(bigBuffer.data(), length);
151 template <
typename Derivate>
154 std::vector<std::string> names;
157 size_t num_objs = getNumberObjects();
158 names.reserve(num_objs);
160 if (H5Literate(
static_cast<const Derivate*
>(
this)->getId(), H5_INDEX_NAME,
162 &details::internal_high_five_iterate<H5L_info_t>,
163 static_cast<void*
>(&iterateData)) < 0) {
164 HDF5ErrMapper::ToException<GroupException>(
165 std::string(
"Unable to list objects in group"));
171 template <
typename Derivate>
173 htri_t val = H5Lexists(
static_cast<const Derivate*
>(
this)->getId(),
174 node_name.c_str(), H5P_DEFAULT);
176 HDF5ErrMapper::ToException<GroupException>(
177 std::string(
"Invalid link for exist() "));
185 #endif // H5NODE_TRAITS_MISC_HPP