22struct io_impl<T, typename std::enable_if<xt::is_xexpression<T>::value>::type> {
23 inline static std::vector<size_t> shape(
const T& data) {
24 return std::vector<size_t>(data.shape().cbegin(), data.shape().cend());
27 inline static DataSet
dump(File& file,
28 const std::string& path,
30 const DumpOptions& options) {
31 using value_type =
typename std::decay_t<T>::value_type;
32 DataSet dataset = initDataset<value_type>(file, path, shape(data), options);
33 dataset.write_raw(data.data());
34 if (options.flush()) {
40 inline static T
load(
const File& file,
const std::string& path) {
42 xt::has_data_interface<T>::value,
43 "Cannot load to xt::xfunction or xt::xgenerator, use e.g. xt::xtensor or xt::xarray");
44 DataSet dataset = file.getDataSet(path);
45 std::vector<size_t> dims = dataset.getDimensions();
46 T data = T::from_shape(dims);
47 dataset.read_raw(data.data());
52 const std::string& path,
53 const std::string& key,
55 const DumpOptions& options) {
56 using value_type =
typename std::decay_t<T>::value_type;
57 Attribute attribute = initAttribute<value_type>(file, path, key, shape(data), options);
58 attribute.write_raw(data.data());
59 if (options.flush()) {
66 const std::string& path,
67 const std::string& key) {
69 xt::has_data_interface<T>::value,
70 "Cannot load to xt::xfunction or xt::xgenerator, use e.g. xt::xtensor or xt::xarray");
71 DataSet dataset = file.getDataSet(path);
72 Attribute attribute = dataset.getAttribute(key);
73 DataSpace dataspace = attribute.getSpace();
74 std::vector<size_t> dims = dataspace.getDimensions();
75 T data = T::from_shape(dims);
76 attribute.read_raw(data.data());
Definition H5Easy_Eigen.hpp:17
T loadAttribute(const File &file, const std::string &path, const std::string &key)
Definition H5Easy_public.hpp:166
DataSet dump(File &file, const std::string &path, const T &data, const DumpOptions &options)
Definition H5Easy_public.hpp:91
T load(const File &file, const std::string &path, const std::vector< size_t > &idx)
Definition H5Easy_public.hpp:138
Attribute dumpAttribute(File &file, const std::string &path, const std::string &key, const T &data, DumpMode mode)
Definition H5Easy_public.hpp:148