12#include <initializer_list>
25inline DataSpace make_data_space(hid_t hid) {
35 std::array<hsize_t, N> real_dims;
36 std::copy(dims.begin(), dims.end(), real_dims.begin());
37 _hid = detail::h5s_create_simple(
static_cast<int>(N), real_dims.data(),
nullptr);
41 :
DataSpace(std::vector<size_t>(items)) {}
43template <
typename... Args>
45 :
DataSpace(std::array<size_t, 1 + sizeof...(dims)>{dim1,
static_cast<size_t>(dims)...}) {}
47template <
class IT,
typename>
49 std::vector<hsize_t> real_dims(begin, end);
51 _hid = detail::h5s_create_simple(
int(real_dims.size()), real_dims.data(),
nullptr);
63 if (dims.size() != maxdims.size()) {
67 std::vector<hsize_t> real_dims(dims.begin(), dims.end());
68 std::vector<hsize_t> real_maxdims(maxdims.begin(), maxdims.end());
71 std::replace(real_maxdims.begin(),
76 _hid = detail::h5s_create_simple(
int(dims.size()), real_dims.data(), real_maxdims.data());
80 auto to_hdf5 = [](
auto _space_type) -> H5S_class_t {
81 switch (_space_type) {
88 "Invalid dataspace type: should be "
89 "dataspace_scalar or dataspace_null");
93 _hid = detail::h5s_create(to_hdf5(space_type));
103 return static_cast<size_t>(detail::h5s_get_simple_extent_ndims(
_hid));
109 detail::h5s_get_simple_extent_dims(
_hid, dims.data(),
nullptr);
111 return details::to_vector_size_t(std::move(dims));
115 return static_cast<size_t>(detail::h5s_get_simple_extent_npoints(
_hid));
120 detail::h5s_get_simple_extent_dims(
_hid,
nullptr, maxdims.data());
122 std::replace(maxdims.begin(),
126 return details::to_vector_size_t(maxdims);
131 auto dims = details::inspector<T>::getDimensions(value);
135template <std::
size_t N, std::
size_t W
idth>
142inline bool checkDimensions(
const DataSpace& mem_space,
143 size_t min_dim_requested,
144 size_t max_dim_requested) {
145 return checkDimensions(mem_space.
getDimensions(), min_dim_requested, max_dim_requested);
Exception specific to HighFive DataSpace interface.
Definition H5Exception.hpp:115
Class representing the space (dimensions) of a DataSet.
Definition H5DataSpace.hpp:39
static DataSpace FromCharArrayStrings(const char(&string_array)[N][Width])
Create a DataSpace from a value of type string array.
Definition H5Dataspace_misc.hpp:136
static DataSpace fromId(hid_t hid)
Definition H5DataSpace.hpp:265
static DataSpace From(const T &value)
Automatically deduce the DataSpace from a container/value.
Definition H5Dataspace_misc.hpp:130
size_t getNumberDimensions() const
Returns the number of dimensions of a DataSpace.
Definition H5Dataspace_misc.hpp:102
std::vector< size_t > getMaxDimensions() const
Returns the maximum size of the dataset in each dimension.
Definition H5Dataspace_misc.hpp:118
DataspaceType
An enum to create scalar and null DataSpace with DataSpace::DataSpace(DataspaceType dtype).
Definition H5DataSpace.hpp:56
static DataSpace Scalar()
Create a scalar DataSpace.
Definition H5Dataspace_misc.hpp:54
static constexpr DataspaceType dataspace_scalar
Definition H5DataSpace.hpp:63
size_t getElementCount() const
Return the number of elements in this DataSpace.
Definition H5Dataspace_misc.hpp:114
std::vector< size_t > getDimensions() const
Returns the size of the dataset in each dimension.
Definition H5Dataspace_misc.hpp:106
DataSpace clone() const
Create a copy of the DataSpace which will have different id.
Definition H5Dataspace_misc.hpp:96
static constexpr DataspaceType dataspace_null
Definition H5DataSpace.hpp:64
static DataSpace Null()
Create a null DataSpace.
Definition H5Dataspace_misc.hpp:58
static const size_t UNLIMITED
Magic value to specify that a DataSpace can grow without limit.
Definition H5DataSpace.hpp:49
hid_t _hid
Definition H5Object.hpp:98
Definition assert_compatible_spaces.hpp:15