h5::read<T>( [ds | path], {offset}, {size} );

Detailed Description

Templated [full|partial] READ operations for T:= std::vector<S> | arma::Row<T> | arma::Col<T> | arma::Mat<T> | arma::Cube<T> objects from opened ds dataset descriptor or path. Returned objects are RVO optimized and for calls within loops raw pointer templates provide means to load datasets from offset and given size.

Function Documentation

template<typename T , typename BaseType = typename utils::base<T>::type>
T h5::read ( hid_t  ds)
inlinenoexcept

reads entire HDF5 dataset and returns object defined by T template

Parameters
dsvalid HDF5 dataset descriptor
Template Parameters
Tstl|arma|eigen templated type
Returns
T<sometype> object
example:
stl::vector<float> entire_dataset = h5::read<stl::vector<float>>( ds );
template<typename T >
T* h5::read ( hid_t  ds,
T *  ptr,
std::initializer_list< hsize_t >  offset,
std::initializer_list< hsize_t >  count 
)
inlinenoexcept

partial reads HDF5 dataset into a memory region defined by pointer

Parameters
dsvalid HDF5 dataset descriptor
ptrpointer to a sufficient size allocated memory where data is loaded
offsetthe coordinates withing HDF5 dataset with rank of the file space, for instance a cube {0,0,0}
countamount of data returned, each dimension must be in (1,max_dimension), for instance {1,3,10} returns a matrix
Template Parameters
T:= ([unsigned] ( int8_t | int16_t | int32_t | int64_t )) | ( float | double )
Returns
T<sometype> object
template<typename T , typename BaseType = typename utils::base<T>::type>
T h5::read ( hid_t  ds,
std::initializer_list< hsize_t >  offset,
std::initializer_list< hsize_t >  count 
)
inlinenoexcept

partial reads HDF5 dataset into T object then returns it

Parameters
dsvalid HDF5 dataset descriptor
offsetthe coordinates withing HDF5 dataset with rank of the file space, for instance a cube {0,0,0}
countamount of data returned, each dimension must be in (1,max_dimension), for instance {1,3,10} returns a matrix
Template Parameters
T:= ([unsigned] ( int8_t | int16_t | int32_t | int64_t )) | ( float | double )
Returns
T<some_type> object
template<typename T >
T h5::read ( hid_t  fd,
const std::string &  path 
)
inline

reads entire HDF5 dataset specified by path and returns object defined by T template throws std::runtime_error if dataset not found, and return value is undefined

Parameters
fdvalid HDF5 file descriptor
pathvalid absolute path to HDF5 dataset
Template Parameters
T:= [stl | arma | eigen] templated type
Returns
T<sometype> object
Exceptions
std::runtime_error- if dataset not found
See also
std::runtime_error
example:
try{
stl::vector<float> entire_dataset =
h5::read<stl::vector<float>>( fd,"absolute/path" );
} catch( const std::runtime_error& ex ) {
std::cerr << ex.what();
}
template<typename T >
T h5::read ( const std::string &  file,
const std::string &  path 
)
inline

reads entire HDF5 dataset specified by path and returns object defined by T template throws std::runtime_error if dataset not found, and return value is undefined

Parameters
filepath to hdf5 file
pathvalid absolute path to HDF5 dataset
Template Parameters
T:= [stl | arma | eigen] templated type
Returns
T<sometype> object
Exceptions
std::runtime_error- if dataset not found
See also
std::runtime_error
example:
try{
stl::vector<float> entire_dataset =
h5::read<stl::vector<float>>( "myfile.h5","absolute/path" );
} catch( const std::runtime_error& ex ) {
std::cerr << ex.what();
}
template<typename T >
T* h5::read ( hid_t  fd,
const std::string &  path,
T *  ptr,
std::initializer_list< hsize_t >  offset,
std::initializer_list< hsize_t >  count 
)
inline

partial reads HDF5 dataset into a memory region defined by pointer throws std::runtime_error if dataset not found

Parameters
fdvalid HDF5 file descriptor
pathvalid absolute path to HDF5 dataset
ptrpointer to a sufficient size allocated memory where data is loaded
offsetthe coordinates withing HDF5 dataset with rank of the file space, for instance a cube {0,0,0}
countamount of data returned, each dimension must be in (1,max_dimension), for instance {1,3,10} returns a matrix
Template Parameters
T:= ([unsigned] ( int8_t | int16_t | int32_t | int64_t )) | ( float | double )
Returns
T<sometype> object
Exceptions
std::runtime_error- if dataset not found
See also
std::runtime_error
example:
float* ptr = malloc(100);
try{
h5::read<float*>( fd,"absolute/path",ptr, {10},{100} );
} catch( const std::runtime_error& ex ) {
std::cerr << ex.what();
}
...
template<typename T >
T h5::read ( hid_t  fd,
const std::string &  path,
std::initializer_list< hsize_t >  offset,
std::initializer_list< hsize_t >  count 
)
inline

partial reads HDF5 dataset into T object then returns it

Parameters
fdvalid HDF5 file descriptor
pathvalid absolute path to HDF5 dataset
offsetthe coordinates withing HDF5 dataset with rank of the file space, for instance a cube {0,0,0}
countamount of data returned, each dimension must be in (1,max_dimension), for instance {1,3,10} returns a matrix
Template Parameters
T:= ([unsigned] ( int8_t | int16_t | int32_t | int64_t )) | ( float | double )
Returns
T<some_type> object