我在 HDF5 1.8.7 中使用 HDF5 C++ API,并希望使用 H5::Attribute 实例在 H5::DataSet 实例中设置几个标量属性,但找不到任何示例。使用 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);
由于某些奇怪的原因,C++ API 中的 H5::Attribute 和 H5::DataSet 类似乎缺少必要的方法。如果有人能提出使用 C++ API 的具体示例,我将不胜感激。