I'm trying to work with HDF5-Files (in C++). Therefor I work with the Examples from the HDF5-API: http://www.hdfgroup.org/HDF5/doc/cpplus_RM/namespaceH5.html
There are a lot of useful examples but I have trouble when I try to "mix" it with other examples from the Tutorial: http://www.hdfgroup.org/HDF5/Tutor/
For example I try to find out if an attribute exists in an HDF5-File. Therefor I open an existing file and then I get problems with the function: H5Aexists
#ifdef OLD_HEADER_FILENAME
#include <iostream.h>
#else
#include <iostream>
#endif
#include <string>
#ifndef H5_NO_NAMESPACE
#ifndef H5_NO_STD
using std::cout;
using std::endl;
#endif // H5_NO_STD
#endif
#include "H5Cpp.h"
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif
const H5std_string FILE_NAME ("file.h5");
const H5std_string DATASET_NAME ("/dataset1/data1/data");
int main (void)
{
Exception::dontPrint();
/*
* Open the specified file and the specified dataset in the file.
*/
H5File file( FILE_NAME, H5F_ACC_RDONLY );
DataSet dataset = file.openDataSet( DATASET_NAME );
const char* where;
//H5Aexists(file,where);
return 0;
}
H5exists expects an integer hid_t with the object id. When I use examples from the Tutorial, then I get an object id by using:
hid_t file_id;
file_id = H5File( FILE_NAME_dBBSC, H5F_ACC_RDONLY );
therefore they always include hdf5.h
not H5Cpp.h
.
But where here do I get my "obj_id" from my code?
In general, I don't get the difference between H5Cpp.h and hdf5.h. Or between the HDF5-API and the other functions?!
Thanks for your help!
edit:
I guess this is how I get an file id?!
hid_t file_id = file.getId();
but how can I get the Id of an attribute? I can't find how to open an Attribute (not a DataSet) so that I can read the contents?!