41 #include <initializer_list> 87 std::string name()
const;
92 bool is_valid()
const;
107 operator hid_t()
const 109 return static_cast<hid_t
>(handle_);
117 const node::Link &parent_link()
const noexcept;
132 void write(
const T& data)
const;
150 void write(
const char *data)
const;
170 void write(
const std::initializer_list<T> &list)
const 172 write(std::vector<T>{list});
204 void read(T &data)
const;
217 void write_fixed_length_string(
const T &data,
224 if(H5Awrite(static_cast<hid_t>(handle_),
225 static_cast<hid_t>(mem_type),
234 void write_variable_length_string(
const T &data,
238 auto buffer = Trait::to_buffer(data);
240 if(H5Awrite(static_cast<hid_t>(handle_),
241 static_cast<hid_t>(mem_type),
250 void write_contiguous_data(
const T &data,
254 if(H5Awrite(static_cast<hid_t>(handle_),static_cast<hid_t>(mem_type),ptr)<0)
261 void read_fixed_length_string(T &data,
269 if(H5Aread(static_cast<hid_t>(handle_),
270 static_cast<hid_t>(mem_type),
281 void read_variable_length_string(T &data,
286 typename Trait::BufferType buffer(dataspace().size());
288 if(H5Aread(static_cast<hid_t>(handle_),
289 static_cast<hid_t>(mem_type),
295 Trait::from_buffer(buffer,data);
297 if(H5Dvlen_reclaim(static_cast<hid_t>(mem_type),
298 static_cast<hid_t>(dataspace()),
302 std::stringstream ss;
303 ss<<
"Failure to reclaim buffer for variable length string" 304 <<
" string read on attribute!";
311 void read_contiguous_data(T &data,
316 if(H5Aread(static_cast<hid_t>(handle_),static_cast<hid_t>(mem_type),ptr)<0)
324 const std::string &operation)
const;
341 write_variable_length_string(data,mem_type);
345 write_fixed_length_string(data,mem_type);
350 write_contiguous_data(data,mem_type);
357 auto mem_type = datatype::create<T>(data);
359 write(data,mem_type);
365 auto file_type = datatype();
368 read(data, file_type);
372 auto mem_type = datatype::create<T>(data);
373 read(data, mem_type, file_type);
381 read(data, mem_type, file_type);
395 read_variable_length_string(data,mem_type);
399 read_fixed_length_string(data,mem_type);
404 read_contiguous_data(data,mem_type);
void read(T &data) const
Definition: attribute.hpp:363
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
a link
Definition: link.hpp:105
string datatype
Definition: string.hpp:39
Wrapper for hid_t object identifiers.
Definition: object_handle.hpp:66
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:355
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:170