22#ifndef LIBH5_STL_TUPLE_HPP
23#define LIBH5_STL_TUPLE_HPP
43 template <
typename... T>
45 static std::string invoke() {
return "PythonTupleWrap"; }
51 template <
typename... Ts, std::size_t... Is>
52 void h5_write_tuple_impl(
group g, std::string
const &, std::tuple<Ts...>
const &tup, std::index_sequence<Is...>) {
53 (
h5_write(g, std::to_string(Is), std::get<Is>(tup)), ...);
57 template <
typename... Ts, std::size_t... Is>
58 void h5_read_tuple_impl(group g, std::string
const &, std::tuple<Ts...> &tup, std::index_sequence<Is...>) {
59 if (g.get_all_subgroup_dataset_names().size() !=
sizeof...(Is))
60 throw std::runtime_error(
61 "Error in h5_read_tuple_impl: Reading a std::tuple<Ts...> from a group with more/less than sizeof...(Ts) subgroups/datasets is not allowed");
62 (
h5_read(g, std::to_string(Is), std::get<Is>(tup)), ...);
77 template <
typename... Ts>
78 void h5_write(
group g, std::string
const &name, std::tuple<Ts...>
const &tup) {
81 detail::h5_write_tuple_impl(gr, name, tup, std::index_sequence_for<Ts...>{});
94 template <
typename... Ts>
95 void h5_read(
group g, std::string
const &name, std::tuple<Ts...> &tup) {
97 detail::h5_read_tuple_impl(gr, name, tup, std::index_sequence_for<Ts...>{});
A handle to an HDF5 group.
group create_group(std::string const &key, bool delete_if_exists=true) const
Create a subgroup with the given key in the group.
group open_group(std::string const &key) const
Open a subgroup with the given key in the group.
Provides a handle to an HDF5 group and various methods to simplify the creation/opening of subgroups,...
T h5_read(group g, std::string const &key)
Generic implementation for reading from an HDF5 dataset/subgroup.
void h5_write(group g, std::string const &name, T const &x) H5_REQUIRES(std
Write a scalar to an HDF5 dataset.
Provides functions to read/write std::string, char* and h5::char_buf objects from/to HDF5.