I'm using HDF5 C++ API in HDF5 1.8.7 and would like to use an H5::Attribute instance to set a couple of scalar attributes in an H5::DataSet instance, but cannot find any examples. It's pretty cut and dry using the C API:
/* Value of the scalar attribute */
int point = 1;
/*
* Create scalar attribute for the dataset, my_dataset.
*/
aid2 = H5Screate(H5S_SCALAR);
attr2 = H5Acreate(my_dataset, "Integer attribute", H5T_NATIVE_INT, aid2,H5P_DEFAULT);
/*
* Write scalar attribute to my_dataset.
*/
ret = H5Awrite(attr2, H5T_NATIVE_INT, &point);
/*
* Close attribute dataspace.
*/
ret = H5Sclose(aid2);
/*
* Close attribute.
*/
ret = H5Aclose(attr2);
For some strange reason, the H5::Attribute and H5::DataSet classes in the C++ API seem to be missing the necessary methods. If anyone can come up with a concrete example using the C++ API, I'd be very appreciative.