4#include "../H5Exception.hpp"
17struct inspector_stl_span {
19 using value_type = unqualified_t<typename Span::value_type>;
20 using base_type =
typename inspector<value_type>::base_type;
21 using hdf5_type =
typename inspector<value_type>::hdf5_type;
23 static constexpr size_t ndim = 1;
24 static constexpr size_t min_ndim = ndim + inspector<value_type>::min_ndim;
25 static constexpr size_t max_ndim = ndim + inspector<value_type>::max_ndim;
27 static constexpr bool is_trivially_copyable = std::is_trivially_copyable<value_type>::value &&
28 inspector<value_type>::is_trivially_nestable;
29 static constexpr bool is_trivially_nestable =
false;
32 static size_t getRank(
const type& val) {
34 return ndim + inspector<value_type>::getRank(val[0]);
40 static std::vector<size_t> getDimensions(
const type& val) {
41 auto rank = getRank(val);
42 std::vector<size_t> sizes(rank, 1ul);
43 sizes[0] = val.size();
45 auto s = inspector<value_type>::getDimensions(val[0]);
46 assert(s.size() + ndim == sizes.size());
47 for (
size_t i = 0; i < s.size(); ++i) {
48 sizes[i + ndim] = s[i];
54 static void prepare(type& val,
const std::vector<size_t>& expected_dims) {
55 auto actual_dims = getDimensions(val);
56 if (actual_dims.size() != expected_dims.size()) {
57 throw DataSpaceException(
"Mismatching rank.");
60 for (
size_t i = 0; i < actual_dims.size(); ++i) {
61 if (actual_dims[i] != expected_dims[i]) {
62 throw DataSpaceException(
"Mismatching dimensions.");
67 static hdf5_type* data(type& val) {
68 return val.empty() ? nullptr : inspector<value_type>::data(val[0]);
71 static const hdf5_type* data(
const type& val) {
72 return val.empty() ? nullptr : inspector<value_type>::data(val[0]);
76 static void serialize(
const type& val,
const std::vector<size_t>& dims, It m) {
78 auto subdims = std::vector<size_t>(dims.begin() + ndim, dims.end());
80 for (
const auto& e: val) {
81 inspector<value_type>::serialize(e, subdims, m);
88 static void unserialize(
const It& vec_align,
const std::vector<size_t>& dims, type& val) {
89 std::vector<size_t> subdims(dims.begin() + ndim, dims.end());
91 for (
size_t i = 0; i < dims[0]; ++i) {
92 inspector<value_type>::unserialize(vec_align + i * subsize, subdims, val[i]);
Definition assert_compatible_spaces.hpp:15
size_t compute_total_size(const std::vector< size_t > &dims)
Definition compute_total_size.hpp:10