remove_elements

C++ Function Reference

1 Signature

bool BigDataStatMeth::remove_elements(H5::H5File *file, H5std_string element)

2 Description

Removes a single element from an HDF5 file.

3 Parameters

  • file (H5::H5File *): Pointer to HDF5 file
  • element (H5std_string): Full path to element to remove

4 Returns

bool True if removal successful, false otherwise

5 Details

filePointer to HDF5 file elementFull path to element to remove bool True if removal successful, false otherwiseH5::FileIExceptionon file operation errors H5::GroupIExceptionon group operation errors H5::DataSetIExceptionon dataset operation errors H5::DataSpaceIExceptionon dataspace operation errorsIf element is not found, returns false

6 Caller Graph

Function dependencies

7 Source Code

File: inst/include/hdf5Utilities/hdf5Utilities.hppLines 183-221

inline bool remove_elements(H5::H5File* file, H5std_string element)
    {
        
        bool bremok = true;
        
        try
        {
            H5::Exception::dontPrint();
            
            // H5std_string elementtoremove = element;
            
            int result = H5Ldelete(file->getId(), element.data(), H5P_DEFAULT);  
            if(result<0) {
                Rcpp::Rcout<<"\n Error removing : "<<element<<"\n";
                bremok = false;
            } 
            
        } catch(H5::FileIException& error) { // catch failure caused by the H5File operations
            Rcpp::Rcerr<<"c++ exception remove_HDF5_multiple_elements_ptr (File IException)" << std::endl;
            return(bremok);
        } catch(H5::GroupIException& error) { // catch failure caused by the Group operations
            Rcpp::Rcerr<<"c++ exception remove_HDF5_multiple_elements_ptr (Group IException)" << std::endl;
            return(bremok);
        } catch(H5::DataSetIException& error) { // catch failure caused by the DataSet operations
            Rcpp::Rcerr<<"c++ exception remove_HDF5_multiple_elements_ptr (DataSet IException)" << std::endl;
            return(bremok);
        } catch(H5::DataSpaceIException& error) { // catch failure caused by the DataSpace operations
            Rcpp::Rcerr<<"c++ exception remove_HDF5_multiple_elements_ptr (DataSpace IException)" << std::endl;
            return(bremok);
        } catch(std::exception &ex) {
            Rcpp::Rcerr << "c++ exception remove_HDF5_multiple_elements_ptr: " << ex.what();
            return(bremok);
        }  catch (...) {
            Rcpp::Rcerr<<"\nC++ exception remove_HDF5_multiple_elements_ptr (unknown reason)";
            return(bremok);
        }
        
        return(bremok);
    }

8 Usage Example

#include "BigDataStatMeth.hpp"

// Example usage
auto result = remove_elements(...);