exists_HDF5_element
C++ Function Reference
1 Signature
bool BigDataStatMeth::exists_HDF5_element(H5::H5File *file, std::string element)2 Description
Checks if an HDF5 element (group or dataset) exists.
3 Parameters
file(H5::H5File *): Pointer to HDF5 fileelement(std::string): Path to the element to check
4 Returns
bool True if element exists, false otherwise
5 Details
filePointer to HDF5 file elementPath to the element to check bool True if element exists, false otherwiseH5::FileIExceptionon file operation errorsHandles trailing slashes in group paths
6 Call Graph
7 Source Code
NoteImplementation
File: inst/include/hdf5Utilities/hdf5Utilities.hpp • Lines 68-95
inline bool exists_HDF5_element(H5::H5File* file, std::string element)
{
bool bexists = false;
try
{
// H5::Exception::dontPrint();
if( element.substr(element.length(), element.length()) == "/" ) {
element = element.substr( 0, element.length()-1);
}
// Search dataset
if(pathExists( file->getId(), element))
bexists = true;
} catch(H5::FileIException& error) { // catch failure caused by the H5File operations
file->close();
Rcpp::Rcerr<<"c++ exception exists_HDF5_element (File IException)" << std::endl;
return bexists;
} catch(std::exception &ex) {
Rcpp::Rcerr << "c++ exception exists_HDF5_element: " << ex.what();
return(bexists);
} catch (...) {
Rcpp::Rcerr<<"\nC++ exception exists_HDF5_element (unknown reason)";
return(bexists);
}
return bexists;
}8 Usage Example
#include "BigDataStatMeth.hpp"
// Example usage
auto result = exists_HDF5_element(...);