renameElement

C++ Function Reference

1 Signature

void BigDataStatMeth::renameElement(H5::H5File *file, std::string original, std::string link)

2 Description

Renames an element in an HDF5 file.

3 Parameters

  • file (H5::H5File *): Pointer to HDF5 file
  • original (std::string): Current path of element
  • link (std::string): New path for element

4 Details

filePointer to HDF5 file originalCurrent path of element linkNew path for elementH5::FileIExceptionon file operation errors H5::DataSetIExceptionon dataset operation errors H5::GroupIExceptionon group operation errors std::exceptionon other errors

5 Source Code

File: inst/include/hdf5Utilities/hdf5Utilities.hppLines 291-329

inline void renameElement( H5::H5File* file, std::string original, std::string link)
    {
        
        try{
            
            H5::Exception::dontPrint();
            
            const char * charOriginal = original.c_str();
            const char * charLink = link.c_str();
            
            // Rcpp::Rcout<<"original: "<< original<<" - Desti: "<<link<<"\n";
            
            herr_t status = H5Lmove(file->getId(), charOriginal, file->getId(), charLink, H5P_DEFAULT, H5P_DEFAULT);
            
            if(status<0) {
                Rcpp::Rcerr<<"c++ exception renameElement (rename_element IException)" << std::endl;
                return void();
            } 
            
            
        } catch(H5::FileIException& error) { 
            Rcpp::Rcerr<<"c++ exception renameElement (File IException)" << std::endl;
            return void();
        } catch(H5::DataSetIException& error) { 
            Rcpp::Rcerr<<"c++ exception renameElement (DataSet IException)" << std::endl;
            return void();
        } catch(H5::GroupIException& error) { 
            Rcpp::Rcerr<<"c++ exception renameElement (Group IException)" << std::endl;
            return void();
        } catch(std::exception &ex) {
            Rcpp::Rcerr << "c++ exception renameElement: " << ex.what();
            return void();
        }  catch (...) {
            Rcpp::Rcerr<<"\nC++ exception renameElement (unknown reason)";
            return void();
        }
        
        return void();
    }

6 Usage Example

#include "BigDataStatMeth.hpp"

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