41 #include <initializer_list>
103 operator hid_t()
const
105 return static_cast<hid_t
>(handle_);
128 void write(const T& data) const;
146 void write(const
char *data) const;
166 void write(const std::initializer_list<T> &list)
const
168 write(std::vector<T>{list});
200 void read(T &data)
const;
213 void write_fixed_length_string(
const T &data,
220 if(H5Awrite(
static_cast<hid_t
>(handle_),
221 static_cast<hid_t
>(mem_type),
230 void write_variable_length_string(
const T &data,
234 auto buffer = Trait::to_buffer(data);
236 if(H5Awrite(
static_cast<hid_t
>(handle_),
237 static_cast<hid_t
>(mem_type),
246 void write_contiguous_data(
const T &data,
247 const datatype::Datatype &mem_type)
const
250 if(H5Awrite(
static_cast<hid_t
>(handle_),
static_cast<hid_t
>(mem_type),
ptr)<0)
257 void read_fixed_length_string(T &data,
258 const datatype::Datatype &mem_type)
const
260 using Trait = FixedLengthStringTrait<T>;
265 if(H5Aread(
static_cast<hid_t
>(handle_),
266 static_cast<hid_t
>(mem_type),
277 void read_variable_length_string(T &data,
278 const datatype::Datatype &mem_type)
const
280 using Trait = VarLengthStringTrait<T>;
282 typename Trait::BufferType buffer(
signed2unsigned<
typename std::vector<T>::size_type>(dataspace().size()));
284 if(H5Aread(
static_cast<hid_t
>(handle_),
285 static_cast<hid_t
>(mem_type),
293 if(H5Dvlen_reclaim(
static_cast<hid_t
>(mem_type),
294 static_cast<hid_t
>(dataspace()),
295 static_cast<hid_t
>(property::DatasetTransferList()),
298 std::stringstream ss;
299 ss<<
"Failure to reclaim buffer for variable length string"
300 <<
" string read on attribute!";
307 void read_contiguous_data(T &data,
308 const datatype::Datatype &mem_type)
const
312 if(H5Aread(
static_cast<hid_t
>(handle_),
static_cast<hid_t
>(mem_type),
ptr)<0)
318 void check_size(
const dataspace::Dataspace &mem_space,
319 const dataspace::Dataspace &file_space,
320 const std::string &operation)
const;
337 write_variable_length_string(data,mem_type);
341 write_fixed_length_string(data,mem_type);
346 write_contiguous_data(data,mem_type);
355 write(data,mem_type_holder.
get<T>());
364 read(data, file_type);
369 read(data, mem_type_holder.
get<T>(), file_type);
377 read(data, mem_type, file_type);
389 if(string_type.is_variable_length())
391 read_variable_length_string(data,mem_type);
395 read_fixed_length_string(data,mem_type);
400 read_contiguous_data(data,mem_type);
Wrapper for hid_t object identifiers.
Definition: object_handle.hpp:67
Definition: attribute.hpp:49
datatype::Datatype datatype() const
return the data type of the attribute
void write(const char *data, const datatype::Datatype &mem_type) const
Attribute(ObjectHandle &&handle, const node::Link &parent_link)
constructor
void close()
close the attribute
Attribute()=default
default constructor
bool is_valid() const
check if object is valid
void write(const T &data) const
write data to attribute
Definition: attribute.hpp:351
const node::Link & parent_link() const noexcept
get the parent ndoe
void read(T &data) const
Definition: attribute.hpp:359
dataspace::Dataspace dataspace() const
return the dataspace of the attribute
std::string name() const
return the name of the attribute
dataspace base class
Definition: dataspace.hpp:41
type trait for dataspace construction
Definition: type_trait.hpp:54
data type object holder
Definition: factory.hpp:54
const Datatype & get(const T &v=T{})
factory holder method for getting reference of data types
Definition: factory.hpp:74
base class for all data types
Definition: datatype.hpp:42
Class get_class() const
returns the datatypes class
string datatype
Definition: string.hpp:40
bool is_variable_length() const
return true if type is a variable length string
static Singleton & instance()
reference to singleton
Definition: error.hpp:59
void throw_with_stack(const std::string &message)
throws an exception, potentially nested with error stack
an HDF5 link
Definition: link.hpp:114
const void * cptr(const T &value)
Definition: type_trait.hpp:116
void * ptr(T &value)
Definition: type_trait.hpp:111
TypeTrait< T >::DataspaceType create(const T &value)
factory function for dataspaces
Definition: type_trait.hpp:89
@ String
indicates a string type
File from_buffer(T &data, ImageFlags flags=ImageFlags::ReadOnly)
load an image file from a buffer
Definition: functions.hpp:126
top-level namespace of the entire library
Definition: attribute.hpp:45
Definition: fixed_length_string.hpp:58
variable length string buffer trait
Definition: variable_length_string.hpp:54
TType signed2unsigned(SType &&source_value)
Definition: utilities.hpp:79
#define DLL_EXPORT
Definition: windows.hpp:29