41 #include <initializer_list> 88 std::string name()
const;
93 bool is_valid()
const;
108 operator hid_t()
const 110 return static_cast<hid_t
>(handle_);
118 const node::Link &parent_link()
const noexcept;
133 void write(
const T& data)
const;
151 void write(
const char *data)
const;
171 void write(
const std::initializer_list<T> &list)
const 173 write(std::vector<T>{list});
205 void read(T &data)
const;
218 void write_fixed_length_string(
const T &data,
225 if(H5Awrite(static_cast<hid_t>(handle_),
226 static_cast<hid_t>(mem_type),
235 void write_variable_length_string(
const T &data,
239 auto buffer = Trait::to_buffer(data);
241 if(H5Awrite(static_cast<hid_t>(handle_),
242 static_cast<hid_t>(mem_type),
251 void write_contiguous_data(
const T &data,
255 if(H5Awrite(static_cast<hid_t>(handle_),static_cast<hid_t>(mem_type),ptr)<0)
262 void read_fixed_length_string(T &data,
270 if(H5Aread(static_cast<hid_t>(handle_),
271 static_cast<hid_t>(mem_type),
282 void read_variable_length_string(T &data,
287 typename Trait::BufferType buffer(dataspace().size());
289 if(H5Aread(static_cast<hid_t>(handle_),
290 static_cast<hid_t>(mem_type),
298 if(H5Dvlen_reclaim(static_cast<hid_t>(mem_type),
299 static_cast<hid_t>(dataspace()),
303 std::stringstream ss;
304 ss<<
"Failure to reclaim buffer for variable length string" 305 <<
" string read on attribute!";
312 void read_contiguous_data(T &data,
317 if(H5Aread(static_cast<hid_t>(handle_),static_cast<hid_t>(mem_type),ptr)<0)
325 const std::string &operation)
const;
342 write_variable_length_string(data,mem_type);
346 write_fixed_length_string(data,mem_type);
351 write_contiguous_data(data,mem_type);
358 auto mem_type = datatype::create<T>(data);
360 write(data,mem_type);
366 auto file_type = datatype();
369 read(data, file_type);
373 auto mem_type = datatype::create<T>(data);
374 read(data, mem_type, file_type);
382 read(data, mem_type, file_type);
396 read_variable_length_string(data,mem_type);
400 read_fixed_length_string(data,mem_type);
405 read_contiguous_data(data,mem_type);
void read(T &data) const
Definition: attribute.hpp:364
TypeTrait< T >::DataspaceType create(const T &value)
factory function for dataspaces
Definition: type_trait.hpp:115
dataspace base class
Definition: dataspace.hpp:41
static Singleton & instance()
reference to singleton
Definition: error.hpp:50
void throw_with_stack(const std::string &message)
throws an exception, potentially nested with error stack
an HDF5 link
Definition: link.hpp:113
string datatype
Definition: string.hpp:39
Wrapper for hid_t object identifiers.
Definition: object_handle.hpp:66
File from_buffer(T &data, ImageFlags flags=ImageFlags::READONLY)
load an image file from a buffer
Definition: functions.hpp:120
const void * cptr(const T &value)
Definition: type_trait.hpp:125
bool is_variable_length() const
return true if type is a variable length string
Definition: attribute.hpp:43
type trait for dataspace construction
Definition: type_trait.hpp:51
void write(const T &data) const
write data to attribute
Definition: attribute.hpp:356
Definition: dataset_transfer.hpp:53
void * ptr(T &value)
Definition: type_trait.hpp:120
#define DLL_EXPORT
Definition: windows.hpp:35
Class get_class() const
returns the datatypes class
Definition: fixed_length_string.hpp:56
Definition: attribute.hpp:46
variable length string buffer trait
Definition: variable_length_string.hpp:53
base class for all data types
Definition: datatype.hpp:41
void write(const std::initializer_list< T > &list) const
write from initializer list
Definition: attribute.hpp:171