Go to the documentation of this file.
9 #ifndef H5ANNOTATE_TRAITS_MISC_HPP
10 #define H5ANNOTATE_TRAITS_MISC_HPP
15 #include <H5Apublic.h>
16 #include <H5Ppublic.h>
23 template <
typename Derivate>
29 if ((attribute.
_hid = H5Acreate2(
30 static_cast<Derivate*
>(
this)->getId(), attribute_name.c_str(),
31 dtype.
_hid, space.
_hid, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
32 HDF5ErrMapper::ToException<AttributeException>(
33 std::string(
"Unable to create the attribute \"") + attribute_name +
"\":");
38 template <
typename Derivate>
39 template <
typename Type>
43 return createAttribute(attribute_name, space, create_and_check_datatype<Type>());
46 template <
typename Derivate>
59 template<
typename Derivate>
62 if (H5Adelete(
static_cast<const Derivate*
>(
this)->getId(), attribute_name.c_str()) < 0) {
63 HDF5ErrMapper::ToException<AttributeException>(
64 std::string(
"Unable to delete attribute \"") + attribute_name +
"\":");
68 template <
typename Derivate>
72 if ((attribute.
_hid = H5Aopen(
static_cast<const Derivate*
>(
this)->getId(),
73 attribute_name.c_str(), H5P_DEFAULT)) < 0) {
74 HDF5ErrMapper::ToException<AttributeException>(
75 std::string(
"Unable to open the attribute \"") + attribute_name +
81 template <
typename Derivate>
83 int res = H5Aget_num_attrs(
static_cast<const Derivate*
>(
this)->getId());
85 HDF5ErrMapper::ToException<AttributeException>(
std::string(
86 "Unable to count attributes in existing group or file"));
88 return static_cast<size_t>(res);
91 template <
typename Derivate>
92 inline std::vector<std::string>
95 std::vector<std::string> names;
98 size_t num_objs = getNumberAttributes();
99 names.reserve(num_objs);
101 if (H5Aiterate2(
static_cast<const Derivate*
>(
this)->getId(), H5_INDEX_NAME,
103 &details::internal_high_five_iterate<H5A_info_t>,
104 static_cast<void*
>(&iterateData)) < 0) {
105 HDF5ErrMapper::ToException<AttributeException>(
106 std::string(
"Unable to list attributes in group"));
112 template <
typename Derivate>
115 int res = H5Aexists(
static_cast<const Derivate*
>(
this)->getId(),
118 HDF5ErrMapper::ToException<AttributeException>(
119 std::string(
"Unable to check for attribute in group"));
126 #endif // H5ANNOTATE_TRAITS_MISC_HPP
HDF5 Data Type.
Definition: H5DataType.hpp:42
size_t getNumberAttributes() const
return the number of attributes of the node / group
Definition: H5Annotate_traits_misc.hpp:82
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:25
bool hasAttribute(const std::string &attr_name) const
checks an attribute exists
Definition: H5Annotate_traits_misc.hpp:114
static DataSpace From(const ScalarValue &scalar_value)
Definition: H5Dataspace_misc.hpp:129
void deleteAttribute(const std::string &attribute_name)
deleteAttribute let you delete an attribute by its name.
Definition: H5Annotate_traits_misc.hpp:61
Definition: H5Iterables_misc.hpp:24
unqualified_t< T > type
Definition: H5Utils.hpp:137
Class representing an attribute of a dataset or group.
Definition: H5Attribute.hpp:23
std::vector< std::string > listAttributeNames() const
list all attribute name of the node / group
Definition: H5Annotate_traits_misc.hpp:93
Attribute getAttribute(const std::string &attribute_name) const
open an existing attribute with the name attribute_name
Definition: H5Annotate_traits_misc.hpp:69
hid_t _hid
Definition: H5Object.hpp:81
DataType create_and_check_datatype()
Create a DataType instance representing type T and perform a sanity check on its size.
Definition: H5DataType_misc.hpp:406
Class representing the space (dimensions) of a dataset.
Definition: H5DataSpace.hpp:37
NAME string(REPLACE ".cpp" "_bin" example_name ${example_filename}) if($
Definition: hops/Third-party/HighFive/src/examples/CMakeLists.txt:6
Definition: H5_definitions.hpp:15
void write(const T &buffer)
Definition: H5Attribute_misc.hpp:106