RcppRemove_hdf5_elements
C++ Function Reference
1 Signature
void BigDataStatMeth::RcppRemove_hdf5_elements(BigDataStatMeth::hdf5File *file, std::vector< std::string > elements)2 Description
Removes specified elements from an HDF5 file.
3 Parameters
file(BigDataStatMeth::hdf5File *): Pointer to the HDF5 file objectelements(std::vector< std::string >): Vector of element paths to be removed
4 Details
This function safely removes multiple elements from an HDF5 file. It checks for the existence of each element before attempting removal and provides appropriate feedback messages.
5 Call Graph
6 Source Code
NoteImplementation
File: inst/include/hdf5Utilities/hdf5RemoveElements.hpp • Lines 59-108
inline void RcppRemove_hdf5_elements(BigDataStatMeth::hdf5File* file, std::vector<std::string> elements)
{
try
{
H5::Exception::dontPrint();
if(elements.size() == 0) {
std::string strmessage = "Nothing to be removed removed";
Rcpp::message(Rcpp::wrap(strmessage));
} else { // Remove datasets
// for (int i=0; i<elements.size(); i++)
for (size_t i = 0; i < elements.size(); ++i)
{
H5std_string element = "" + elements[i];
if(exists_HDF5_element( file->getFileptr(), element))
{
int result = H5Ldelete( (file->getFileptr())->getId(), element.data(), H5P_DEFAULT);
if(result<0) {
Rcpp::Rcout<<"\n Error removing : "<<elements[i]<<"\n";
}
} else {
Rcpp::Rcout<<"\n Element: "<<elements[i]<<" does not exists \n";
}
}
}
} catch(H5::FileIException& error) { // catch failure caused by the H5File operations
Rcpp::Rcerr<<"c++ exception RcppRemove_hdf5_elements (File IException)";
return void();
} catch(H5::GroupIException& error) { // catch failure caused by the Group operations
Rcpp::Rcerr<<"c++ exception RcppRemove_hdf5_elements (Group IException)";
return void();
} catch(H5::DataSetIException& error) { // catch failure caused by the DataSet operations
Rcpp::Rcerr<<"c++ exception RcppRemove_hdf5_elements (DataSet IException)";
return void();
} catch(H5::DataSpaceIException& error) { // catch failure caused by the DataSpace operations
Rcpp::Rcerr<<"c++ exception RcppRemove_hdf5_elements (DataSpace IException)";
return void();
} catch(std::exception &ex) {
Rcpp::Rcerr << "c++ exception RcppRemove_hdf5_elements: " << ex.what();
return void();
} catch (...) {
Rcpp::Rcerr<<"C++ exception RcppRemove_hdf5_elements (unknown reason)";
return void();
}
return void();
}7 Usage Example
#include "BigDataStatMeth.hpp"
// Example usage
auto result = RcppRemove_hdf5_elements(...);