QMCPACK
h5data_proxy< std::vector< bool > > Struct Template Reference

specialization for std::vector<bool> More...

+ Inheritance diagram for h5data_proxy< std::vector< bool > >:
+ Collaboration diagram for h5data_proxy< std::vector< bool > >:

Public Types

using FileSpace = h5_space_type< char, 1 >
 
using data_type = std::vector< bool >
 

Public Member Functions

 h5data_proxy (const data_type &a)
 
bool read (data_type &ref, hid_t grp, const std::string &aname, hid_t xfer_plist=H5P_DEFAULT)
 
bool write (const data_type &ref, hid_t grp, const std::string &aname, hid_t xfer_plist=H5P_DEFAULT) const
 
bool write (const data_type &ref, hid_t grp, const std::string &aname, const std::vector< hsize_t > &dvec, hid_t xfer_plist) const
 

Additional Inherited Members

- Static Public Member Functions inherited from h5_space_type< char, 1 >
static constexpr int added_rank ()
 new rank added due to T More...
 
static auto get_address (char *a)
 return the address More...
 
static auto get_address (const char *a)
 
- Public Attributes inherited from h5_space_type< char, 1 >
hsize_t dims [RANK > 0 ? RANK :1]
 shape of the dataspace, protected for zero size array, hdf5 support scalar as rank = 0 More...
 
- Static Public Attributes inherited from h5_space_type< char, 1 >
static constexpr hsize_t rank
 rank of the multidimensional dataspace More...
 

Detailed Description

template<>
struct qmcplusplus::h5data_proxy< std::vector< bool > >

specialization for std::vector<bool>

Used with bool which doesn't have a h5 datatype we can use.

Definition at line 64 of file hdf_stl.h.

Member Typedef Documentation

◆ data_type

using data_type = std::vector<bool>

Definition at line 69 of file hdf_stl.h.

◆ FileSpace

using FileSpace = h5_space_type<char, 1>

Definition at line 66 of file hdf_stl.h.

Constructor & Destructor Documentation

◆ h5data_proxy()

h5data_proxy ( const data_type a)
inline

Definition at line 71 of file hdf_stl.h.

References h5_space_type< T, 0 >::dims.

71 { dims[0] = a.size(); }
hsize_t dims[RANK > 0 ? RANK :1]
shape of the dataspace, protected for zero size array, hdf5 support scalar as rank = 0 ...
Definition: hdf_dataspace.h:47

Member Function Documentation

◆ read()

bool read ( data_type ref,
hid_t  grp,
const std::string &  aname,
hid_t  xfer_plist = H5P_DEFAULT 
)
inline

Definition at line 73 of file hdf_stl.h.

References h5_space_type< T, 0 >::dims, h5_space_type< T, 0 >::get_address(), qmcplusplus::h5d_read(), and h5_space_type< T, 0 >::rank.

74  {
75  std::vector<char> temp_char_vec;
76  if (!checkShapeConsistency<char>(grp, aname, FileSpace::rank, dims))
77  temp_char_vec.resize(dims[0]);
78  h5d_read(grp, aname, get_address(temp_char_vec.data()), xfer_plist);
79  ref.resize(dims[0]);
80  std::transform(temp_char_vec.begin(), temp_char_vec.end(), ref.begin(), [](auto& cval) { return cval > 0; });
81  return true;
82  }
hsize_t dims[RANK > 0 ? RANK :1]
shape of the dataspace, protected for zero size array, hdf5 support scalar as rank = 0 ...
Definition: hdf_dataspace.h:47
static auto get_address(char *a)
return the address
Definition: hdf_dataspace.h:53
static constexpr hsize_t rank
rank of the multidimensional dataspace
Definition: hdf_dataspace.h:49
bool h5d_read(hid_t grp, const std::string &aname, T *first, hid_t xfer_plist)
return true, if successful

◆ write() [1/2]

bool write ( const data_type ref,
hid_t  grp,
const std::string &  aname,
hid_t  xfer_plist = H5P_DEFAULT 
) const
inline

Definition at line 84 of file hdf_stl.h.

References h5_space_type< T, 0 >::dims, h5_space_type< T, 0 >::get_address(), qmcplusplus::h5d_write(), and h5_space_type< T, 0 >::rank.

85  {
86  std::vector<char> temp_char_vec(ref.size());
87  std::transform(ref.begin(), ref.end(), temp_char_vec.begin(), [](bool bval) { return bval ? 1 : 0; });
88  return h5d_write(grp, aname.c_str(), FileSpace::rank, dims, get_address(temp_char_vec.data()), xfer_plist);
89  }
hsize_t dims[RANK > 0 ? RANK :1]
shape of the dataspace, protected for zero size array, hdf5 support scalar as rank = 0 ...
Definition: hdf_dataspace.h:47
static auto get_address(char *a)
return the address
Definition: hdf_dataspace.h:53
static constexpr hsize_t rank
rank of the multidimensional dataspace
Definition: hdf_dataspace.h:49
bool h5d_write(hid_t grp, const std::string &aname, hsize_t ndims, const hsize_t *dims, const T *first, hid_t xfer_plist)

◆ write() [2/2]

bool write ( const data_type ref,
hid_t  grp,
const std::string &  aname,
const std::vector< hsize_t > &  dvec,
hid_t  xfer_plist 
) const
inline

Definition at line 91 of file hdf_stl.h.

References h5_space_type< T, 0 >::get_address(), and qmcplusplus::h5d_write().

96  {
97  std::vector<char> temp_char_vec(ref.size());
98  std::transform(ref.begin(), ref.end(), temp_char_vec.begin(), [](bool bval) { return bval ? 1 : 0; });
99  return h5d_write(grp, aname.c_str(), dvec.size(), dvec.data(), get_address(temp_char_vec.data()), xfer_plist);
100  }
static auto get_address(char *a)
return the address
Definition: hdf_dataspace.h:53
bool h5d_write(hid_t grp, const std::string &aname, hsize_t ndims, const hsize_t *dims, const T *first, hid_t xfer_plist)

The documentation for this struct was generated from the following file: