22template <
typename Derivate>
26 auto attr_id = H5Acreate2(
static_cast<Derivate*
>(
this)->getId(),
27 attribute_name.c_str(),
33 HDF5ErrMapper::ToException<AttributeException>(
34 std::string(
"Unable to create the attribute \"") + attribute_name +
"\":");
36 return detail::make_attribute(attr_id);
39template <
typename Derivate>
40template <
typename Type>
43 return createAttribute(attribute_name, space, create_and_check_datatype<Type>());
46template <
typename Derivate>
51 createAttribute(attribute_name,
58template <
typename Derivate>
60 if (H5Adelete(
static_cast<const Derivate*
>(
this)->getId(), attribute_name.c_str()) < 0) {
61 HDF5ErrMapper::ToException<AttributeException>(
62 std::string(
"Unable to delete attribute \"") + attribute_name +
"\":");
66template <
typename Derivate>
69 H5Aopen(
static_cast<const Derivate*
>(
this)->getId(), attribute_name.c_str(), H5P_DEFAULT);
71 HDF5ErrMapper::ToException<AttributeException>(
72 std::string(
"Unable to open the attribute \"") + attribute_name +
"\":");
74 return detail::make_attribute(attr_id);
77template <
typename Derivate>
79 int res = H5Aget_num_attrs(
static_cast<const Derivate*
>(
this)->getId());
81 HDF5ErrMapper::ToException<AttributeException>(
82 std::string(
"Unable to count attributes in existing group or file"));
84 return static_cast<size_t>(res);
87template <
typename Derivate>
89 std::vector<std::string> names;
90 details::HighFiveIterateData iterateData(names);
92 size_t num_objs = getNumberAttributes();
93 names.reserve(num_objs);
95 if (H5Aiterate2(
static_cast<const Derivate*
>(
this)->getId(),
99 &details::internal_high_five_iterate<H5A_info_t>,
100 static_cast<void*
>(&iterateData)) < 0) {
101 HDF5ErrMapper::ToException<AttributeException>(
102 std::string(
"Unable to list attributes in group"));
108template <
typename Derivate>
110 int res = H5Aexists(
static_cast<const Derivate*
>(
this)->getId(), attr_name.c_str());
112 HDF5ErrMapper::ToException<AttributeException>(
113 std::string(
"Unable to check for attribute in group"));
Attribute createAttribute(const std::string &attribute_name, const DataSpace &space, const DataType &type)
create a new attribute with the name attribute_name
Definition H5Annotate_traits_misc.hpp:23
std::vector< std::string > listAttributeNames() const
list all attribute name of the node / group
Definition H5Annotate_traits_misc.hpp:88
void deleteAttribute(const std::string &attribute_name)
deleteAttribute let you delete an attribute by its name.
Definition H5Annotate_traits_misc.hpp:59
Attribute getAttribute(const std::string &attribute_name) const
open an existing attribute with the name attribute_name
Definition H5Annotate_traits_misc.hpp:67
bool hasAttribute(const std::string &attr_name) const
checks an attribute exists
Definition H5Annotate_traits_misc.hpp:109
size_t getNumberAttributes() const
return the number of attributes of the node / group
Definition H5Annotate_traits_misc.hpp:78
Class representing an attribute of a dataset or group.
Definition H5Attribute.hpp:46
void write(const T &buffer)
Definition H5Attribute_misc.hpp:117
Class representing the space (dimensions) of a dataset.
Definition H5DataSpace.hpp:25
static DataSpace From(const T &value)
Create a dataspace matching a type accepted by details::inspector.
Definition H5Dataspace_misc.hpp:131
HDF5 Data Type.
Definition H5DataType.hpp:54
hid_t getId() const noexcept
getId
Definition H5Object_misc.hpp:65
Definition H5_definitions.hpp:15
DataType create_and_check_datatype()
Create a DataType instance representing type T and perform a sanity check on its size.
Definition H5DataType_misc.hpp:479