9 #ifndef H5ANNOTATE_TRAITS_MISC_HPP
10 #define H5ANNOTATE_TRAITS_MISC_HPP
18 #include "../H5Attribute.hpp"
19 #include "../H5DataSpace.hpp"
20 #include "../H5DataType.hpp"
21 #include "../H5Exception.hpp"
23 #include <H5Apublic.h>
27 template <
typename Derivate>
33 if ((attribute.
_hid = H5Acreate2(
34 static_cast<Derivate*
>(
this)->getId(), attribute_name.c_str(),
35 dtype.
_hid, space.
_hid, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
36 HDF5ErrMapper::ToException<AttributeException>(
37 std::string(
"Unable to create the attribute \"") + attribute_name +
43 template <
typename Derivate>
44 template <
typename Type>
51 template <
typename Derivate>
63 template <
typename Derivate>
65 const std::string& attribute_name)
const {
67 if ((attribute.
_hid = H5Aopen(
static_cast<const Derivate*
>(
this)->getId(),
68 attribute_name.c_str(), H5P_DEFAULT)) < 0) {
69 HDF5ErrMapper::ToException<AttributeException>(
70 std::string(
"Unable to open the attribute \"") + attribute_name +
76 template <
typename Derivate>
78 int res = H5Aget_num_attrs(
static_cast<const Derivate*
>(
this)->getId());
80 HDF5ErrMapper::ToException<AttributeException>(std::string(
81 "Unable to count attributes in existing group or file"));
86 template <
typename Derivate>
87 inline std::vector<std::string>
90 std::vector<std::string> names;
93 size_t num_objs = getNumberAttributes();
94 names.reserve(num_objs);
96 if (H5Aiterate2(
static_cast<const Derivate*
>(
this)->getId(), H5_INDEX_NAME,
98 &details::internal_high_five_iterate<H5A_info_t>,
99 static_cast<void*
>(&iterateData)) < 0) {
100 HDF5ErrMapper::ToException<AttributeException>(
101 std::string(
"Unable to list attributes in group"));
107 template <
typename Derivate>
110 int res = H5Aexists(
static_cast<const Derivate*
>(
this)->getId(),
113 HDF5ErrMapper::ToException<AttributeException>(
114 std::string(
"Unable to check for attribute in group"));
120 #endif // H5ANNOTATE_TRAITS_MISC_HPP