Skip to content

Commit

Permalink
sync with highfive (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan authored May 7, 2024
1 parent c930968 commit 364592f
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions src/hdf5/detail/h5/h5_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,6 @@ namespace PHARE::hdf5::h5
using HiFile = HighFive::File;


/*
Highfive cannot accept a single flat array into >= 2d shaped datasets
*/
template<std::size_t dim, typename Data>
NO_DISCARD auto pointer_dim_caster(Data* data)
{
if constexpr (dim == 1)
return data;
if constexpr (dim == 2)
return reinterpret_cast<Data const** const>(data);
if constexpr (dim == 3)
return reinterpret_cast<Data const*** const>(data);
}
template<std::size_t dim, typename Data>
NO_DISCARD auto pointer_dim_caster(Data const* const data)
{
if constexpr (dim == 1)
return data;
if constexpr (dim == 2)
return reinterpret_cast<Data const* const* const>(data);
if constexpr (dim == 3)
return reinterpret_cast<Data const* const* const* const>(data);
}



template<std::size_t dim, typename Data>
Expand Down Expand Up @@ -94,7 +70,7 @@ class HighFiveFile
NO_DISCARD auto read_data_set_flat(std::string path) const
{
std::vector<T> data(H5Easy::getSize(h5file_, path));
h5file_.getDataSet(path).read_raw(pointer_dim_caster<dim>(data.data()));
h5file_.getDataSet(path).read_raw(data.data());
return data;
}

Expand All @@ -117,7 +93,7 @@ class HighFiveFile
template<std::size_t dim = 1, typename Data>
auto& write_data_set_flat(std::string path, Data const& data)
{
h5file_.getDataSet(path).write(pointer_dim_caster<dim>(data));
h5file_.getDataSet(path).write_raw(data);
return *this;
}

Expand Down

0 comments on commit 364592f

Please sign in to comment.