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 267-299

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) {
                throw std::runtime_error("c++ exception renameElement (rename_element IException)");
            } 
            
            
        } catch(H5::FileIException& error) { 
            throw std::runtime_error("c++ exception renameElement (File IException)");
        } catch(H5::DataSetIException& error) { 
            throw std::runtime_error("c++ exception renameElement (DataSet IException)");
        } catch(H5::GroupIException& error) { 
            throw std::runtime_error("c++ exception renameElement (Group IException)");
        } catch(std::exception &ex) {
            throw std::runtime_error(std::string("c++ exception renameElement: ") + ex.what());
        }  catch (...) {
            throw std::runtime_error("C++ exception renameElement (unknown reason)");
        }
        
        return void();
    }

6 Usage Example

#include "BigDataStatMeth.hpp"

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