9 #ifndef H5ATTRIBUTE_MISC_HPP
10 #define H5ATTRIBUTE_MISC_HPP
19 #include <boost/multi_array.hpp>
22 #include <H5Apublic.h>
23 #include <H5Ppublic.h>
31 return details::get_name([&](
char *buffer, hsize_t length) {
32 return H5Aget_name(
_hid, length, buffer);
37 return static_cast<size_t>(H5Aget_storage_size(
_hid));
48 if ((space.
_hid = H5Aget_space(
_hid)) < 0) {
49 HDF5ErrMapper::ToException<AttributeException>(
50 "Unable to get DataSpace out of Attribute");
59 static_assert(!std::is_const<
typename std::remove_reference<T>::type>::value,
60 "read() requires a non-const array to read into");
61 using element_type =
typename details::type_of_array<T>::type;
62 const size_t dim_array = details::array_dims<T>::value;
66 if (!details::checkDimensions(mem_space, dim_array)) {
67 std::ostringstream ss;
68 ss <<
"Impossible to read attribute of dimensions "
74 const DataType mem_datatype = create_and_check_datatype<element_type>();
77 details::data_converter<T> converter(mem_space);
80 static_cast<void*
>(converter.transform_read(array))) < 0) {
81 HDF5ErrMapper::ToException<AttributeException>(
82 "Error during HDF5 Read: ");
86 converter.process_result(array);
91 static_assert(!std::is_const<T>::value,
92 "read() requires a non-const structure to read data into");
93 using element_type =
typename details::type_of_array<T>::type;
96 const DataType mem_datatype = create_and_check_datatype<element_type>();
99 static_cast<void*
>(array)) < 0) {
100 HDF5ErrMapper::ToException<AttributeException>(
101 "Error during HDF5 Read: ");
105 template <
typename T>
107 using element_type =
typename details::type_of_array<T>::type;
108 const size_t dim_buffer = details::array_dims<T>::value;
112 if (!details::checkDimensions(mem_space, dim_buffer)) {
113 std::ostringstream ss;
114 ss <<
"Impossible to write buffer of dimensions " << dim_buffer
115 <<
" into attribute of dimensions "
120 const DataType mem_datatype = create_and_check_datatype<element_type>();
121 details::data_converter<T> converter(mem_space);
124 static_cast<const void*
>(converter.transform_write(buffer))) < 0) {
125 HDF5ErrMapper::ToException<DataSetException>(
126 "Error during HDF5 Write: ");
130 template <
typename T>
132 using element_type =
typename details::type_of_array<T>::type;
135 const DataType mem_datatype = create_and_check_datatype<element_type>();
136 details::data_converter<T> converter(mem_space);
139 static_cast<const void*
>(converter.transform_write(buffer))) < 0) {
140 HDF5ErrMapper::ToException<DataSetException>(
141 "Error during HDF5 Write: ");
void write_raw(const T &buffer)
Definition: H5Attribute_misc.hpp:131
DataSpace getSpace() const
getSpace
Definition: H5Attribute_misc.hpp:46
DataType getDataType() const
getDataType
Definition: H5Attribute_misc.hpp:40
std::string getName() const
return the name of the current attribute
Definition: H5Attribute_misc.hpp:30
void write(const T &buffer)
Definition: H5Attribute_misc.hpp:106
DataSpace getMemSpace() const
getMemSpace
Definition: H5Attribute_misc.hpp:55
size_t getStorageSize() const
Definition: H5Attribute_misc.hpp:36
void read(T &array) const
Definition: H5Attribute_misc.hpp:58
Exception specific to HighFive DataSpace interface.
Definition: H5Exception.hpp:99
Class representing the space (dimensions) of a dataset.
Definition: H5DataSpace.hpp:37
size_t getNumberDimensions() const
getNumberDimensions
Definition: H5Dataspace_misc.hpp:90
HDF5 Data Type.
Definition: H5DataType.hpp:42
hid_t getId() const noexcept
getId
Definition: H5Object_misc.hpp:55
hid_t _hid
Definition: H5Object.hpp:81
Definition: H5_definitions.hpp:15