#include <iostream>
using std::cout;
using std::endl;
#include <string>
#include "H5Cpp.h"
const H5std_string FILE_NAME("Group.h5");
const int RANK = 2;
extern "C" herr_t file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata);
int
main(void)
{
hsize_t dims[2];
hsize_t cdims[2];
try {
Exception::dontPrint();
dims[0] = 1000;
dims[1] = 20;
cdims[0] = 20;
cdims[1] = 20;
file->
createDataSet(
"/Data/Compressed_Data", PredType::NATIVE_INT, *dataspace, ds_creatplist));
delete dataset;
delete dataspace;
dims[0] = 500;
dims[1] = 20;
delete dataset;
delete dataspace;
delete group;
delete file;
file =
new H5File(FILE_NAME, H5F_ACC_RDWR);
try {
}
cout << " Dataset is not found." << endl;
}
cout << "dataset \"/Data/Compressed_Data\" is open" << endl;
delete dataset;
file->
link(H5L_TYPE_HARD,
"Data",
"Data_new");
try {
}
cout << " Dataset is not found." << endl;
}
cout << "dataset \"/Data_new/Compressed_Data\" is open" << endl;
delete dataset;
cout << endl << "Iterating over elements in the file" << endl;
herr_t idx = H5Literate(file->
getId(), H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL);
cout << endl;
cout << "Unlinking..." << endl;
try {
}
cout << " unlink failed." << endl;
}
cout << "\"Data\" is unlinked" << endl;
cout << endl << "Iterating over elements in the file again" << endl;
idx = H5Literate(file->
getId(), H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL);
cout << endl;
delete group;
delete file;
}
return -1;
}
return -1;
}
return -1;
}
return -1;
}
return 0;
}
herr_t
file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata)
{
hid_t group;
group = H5Gopen2(loc_id, name, H5P_DEFAULT);
cout << "Name : " << name << endl;
H5Gclose(group);
return 0;
}
Definition: H5Exception.h:138
Class DSetCreatPropList inherits from ObjCreatPropList and provides wrappers for the HDF5 dataset cre...
Definition: H5DcreatProp.h:29
void setDeflate(int level) const
Sets compression method and compression level.
Definition: H5DcreatProp.cpp:222
void setChunk(int ndims, const hsize_t *dim) const
Sets the size of the chunks used to store a chunked layout dataset.
Definition: H5DcreatProp.cpp:137
Class DataSet operates on HDF5 datasets.
Definition: H5DataSet.h:28
Definition: H5Exception.h:131
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:25
Definition: H5Exception.h:103
static void printErrorStack(FILE *stream=stderr, hid_t err_stack=H5E_DEFAULT)
Prints the error stack in a default manner.
Definition: H5Exception.cpp:315
Definition: H5Exception.h:89
Class Group represents an HDF5 group.
Definition: H5Group.h:24
Definition: H5Exception.h:96
Class H5File represents an HDF5 file and inherits from class Group as file is a root group.
Definition: H5File.h:25
virtual hid_t getId() const H5_OVERRIDE
Get the id of this file.
Definition: H5File.cpp:561
Group createGroup(const char *name, const LinkCreatPropList &lcpl) const
Creates a new group at this location, which can be a file, group, dataset, attribute,...
Definition: H5Location.cpp:794
void link(const char *target_name, const char *link_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
Creates a soft link from link_name to target_name.
Definition: H5Location.cpp:1055
void unlink(const char *link_name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
Removes the specified link from this group.
Definition: H5Location.cpp:1442
DataSet openDataSet(const char *name, const DSetAccPropList &dapl=DSetAccPropList::DEFAULT) const
Opens an existing dataset at this location.
Definition: H5Location.cpp:1006
Group openGroup(const char *name) const
Opens an existing group in a location which can be a file or another group.
Definition: H5Location.cpp:900
DataSet createDataSet(const char *name, const DataType &data_type, const DataSpace &data_space, const DSetCreatPropList &create_plist=DSetCreatPropList::DEFAULT, const DSetAccPropList &dapl=DSetAccPropList::DEFAULT, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT) const
Creates a new dataset at this location.
Definition: H5Location.cpp:950
Definition: H5AbstractDs.cpp:34