I worked it out for myself. This function below actually works.
static
void
WriteHDFStringList(H5::H5File &file,
const char *name,
std::vector<std::string> &stringList)
{
hsize_t numStrings(stringList.size());
char **stringListCstr = new char *[numStrings];
{
int i = 0;
for(std::vector<std::string>::iterator it = stringList.begin();
it != stringList.end(); it++)
{
stringListCstr[i] = new char[it->size()+1];
strcpy(stringListCstr[i],it->c_str());
i++;
}
}
H5::DataSpace strSpace(1,&numStrings);
H5::StrType strType(H5::PredType::C_S1,H5T_VARIABLE);
H5::DataSet strSet = file.createDataSet(name,strType,strSpace);
strSet.write(stringListCstr,strType);
for(unsigned int i = 0; i < numStrings; i++)
{
delete [] stringListCstr[i];
}
delete [] stringListCstr;
}
________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the
Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and
may be legally privileged. If you are not the intended recipient, you are
hereby notified that any retention, dissemination, distribution, or copying of
this communication is strictly prohibited. Please reply to the sender that you
have received the message in error, then delete it. Thank you.
________________________________
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org