29 return details::get_name(
30 [&](
char* buffer,
size_t length) {
return detail::h5a_get_name(
_hid, length, buffer); });
34 return static_cast<size_t>(detail::h5a_get_storage_size(
_hid));
39 res.
_hid = detail::h5a_get_type(
_hid);
45 space.
_hid = detail::h5a_get_space(
_hid);
64 const details::BufferInfo<T> buffer_info(
66 [
this]() -> std::string {
return this->
getName(); },
67 details::BufferInfo<T>::Operation::read);
69 if (!details::checkDimensions(mem_space, buffer_info.n_dimensions)) {
70 std::ostringstream ss;
72 <<
" into arrays of dimensions " << buffer_info.n_dimensions;
78 auto effective_dims = details::squeezeDimensions(dims,
79 details::inspector<T>::recursive_ndim);
81 details::inspector<T>::prepare(array, effective_dims);
85 auto r = details::data_converter::get_reader<T>(dims, array, file_datatype);
86 read_raw(r.getPointer(), buffer_info.data_type);
90 auto t = buffer_info.data_type;
91 auto c = t.getClass();
94#if H5_VERSION_GE(1, 12, 0)
96 (void) detail::h5t_reclaim(t.getId(), mem_space.
getId(), H5P_DEFAULT, r.getPointer());
99 (void) detail::h5d_vlen_reclaim(t.getId(), mem_space.
getId(), H5P_DEFAULT, r.getPointer());
111 static_assert(!std::is_const<T>::value,
112 "read() requires a non-const structure to read data into");
114 detail::h5a_read(
getId(), mem_datatype.
getId(),
static_cast<void*
>(array));
124 using element_type =
typename details::inspector<T>::base_type;
125 const DataType& mem_datatype = create_and_check_datatype<element_type>();
140 const details::BufferInfo<T> buffer_info(
142 [
this]() -> std::string {
return this->
getName(); },
143 details::BufferInfo<T>::Operation::write);
145 if (!details::checkDimensions(mem_space, buffer_info.n_dimensions)) {
146 std::ostringstream ss;
147 ss <<
"Impossible to write buffer of dimensions " << buffer_info.n_dimensions
151 auto w = details::data_converter::serialize<T>(buffer, file_datatype);
152 write_raw(w.getPointer(), buffer_info.data_type);
157 detail::h5a_write(
getId(), mem_datatype.
getId(), buffer);
162 using element_type =
typename details::inspector<T>::base_type;
163 const auto& mem_datatype = create_and_check_datatype<element_type>();
DataSpace getSpace() const
Get the DataSpace of the current Attribute.
Definition H5Attribute_misc.hpp:43
DataType getDataType() const
Get the DataType of the Attribute.
Definition H5Attribute_misc.hpp:37
void read_raw(T *array, const DataType &mem_datatype) const
Read the attribute into a pre-allocated buffer.
Definition H5Attribute_misc.hpp:110
std::string getName() const
Get the name of the current Attribute.
Definition H5Attribute_misc.hpp:28
T read() const
Get the value of the Attribute.
Definition H5Attribute_misc.hpp:54
DataSpace getMemSpace() const
Get the DataSpace of the current Attribute.
Definition H5Attribute_misc.hpp:49
void write(const T &value)
Write the value into the Attribute.
Definition H5Attribute_misc.hpp:131
void write_raw(const T *buffer, const DataType &mem_datatype)
Write from a raw pointer.
Definition H5Attribute_misc.hpp:156
size_t getStorageSize() const
The number of bytes required to store the attribute in the HDF5 file.
Definition H5Attribute_misc.hpp:33
Exception specific to HighFive DataSpace interface.
Definition H5Exception.hpp:112
Class representing the space (dimensions) of a DataSet.
Definition H5DataSpace.hpp:39
size_t getNumberDimensions() const
Returns the number of dimensions of a DataSpace.
Definition H5Dataspace_misc.hpp:100
size_t getElementCount() const
Return the number of elements in this DataSpace.
Definition H5Dataspace_misc.hpp:112
std::vector< size_t > getDimensions() const
Returns the size of the dataset in each dimension.
Definition H5Dataspace_misc.hpp:104
HDF5 Data Type.
Definition H5DataType.hpp:61
hid_t getId() const noexcept
getId
Definition H5Object_misc.hpp:69
hid_t _hid
Definition H5Object.hpp:105
Definition H5_definitions.hpp:22