Hello guys:
In a program, I use some relatively small HDF5 files multiple times and
transfer them then through TCP/IP, so I read them into memory as
`std::string`, and then read them as HDF5 using:
fileHandle=H5LTopen_file_image((void*)&FileImage.front(),FileImage.size(),H5LT_FILE_IMAGE_OPEN_RW);
*My question is:* Since I'm opening this as RW, how can I write an
attribute to it and retrieve the image back?
The motivation behind my question is simple. I have a simple function
that can write an attribute to an object by its ID. Here it's:
voidWriteStringAttribute(hid_tdataset_id,conststd::string&name,conststd::string&value)
{
hid_tAttributeType=H5Tcopy(H5T_C_S1);
H5Tset_size(AttributeType,value.length());
hid_tdataspaceHandle=H5Screate(H5S_SCALAR);
hid_tAttrHandle=H5Acreate(dataset_id,name.c_str(),AttributeType,dataspaceHandle,H5P_DEFAULT,H5P_DEFAULT);
H5Awrite(AttrHandle,AttributeType,&value.front());
H5Aclose(AttrHandle);
H5Sclose(dataspaceHandle);
}
What I don't understand is that after writing the attribute using this
function (Is it right to do this?
WriteStringAttribute(fileHandle,"MyAttr","MyAttrValue");
), the image size should've been changed. How can I get the new correct
image size and write it back to a file (or do anything else with it, for
that matter)?
Thank you.
Best,
Samer Afach