Well I know now that the code below doesn't work. It doesn't like the data
type, I pass in apparently.

HDF5-DIAG: Error detected in HDF5 (1.8.7-snap2) thread 0:
  #000: HDF5/src/H5Dio.c line 266 in H5Dwrite(): can't write data
    major: Dataset
    minor: Write failed
  #001: HDF5/src/H5Dio.c line 541 in H5D_write(): unable to set up type
info
    major: Dataset
    minor: Unable to initialize object
  #002: HDF5/src/H5Dio.c line 836 in H5D_typeinfo_init(): unable to
convert between src and dest datatype
    major: Dataset
    minor: Feature is unsupported
  #003: HDF5/src/H5T.c line 4454 in H5T_path_find(): no appropriate
function for conversion path
    major: Datatype
    minor: Unable to initialize object
terminate called after throwing an instance of 'H5::DataSetIException'


void WriteArray(H5::H5File &output,const std::string &setName,
                std::vector<std::string> &subjectNames)
{
  hvl_t *ids = new hvl_t[subjectNames.size()];

  { // initialize variable length array
  int i = 0;
  for(std::vector<std::string>::iterator it = subjectNames.begin();
      it != subjectNames.end(); it++)
    {
    ids[i].len = (*it).size()+1;
    ids[i].p = static_cast<void *>(new char[ids[i].len]);
    strcpy(static_cast<char *>(ids[i].p),(*it).c_str());
    i++;
    }
  }

  hsize_t numStrings(subjectNames.size());

  H5::DataSpace strSpace(1,&numStrings);
  H5::StrType strType(0,H5T_VARIABLE);

  H5::DataSet strSet =
output.createDataSet("/SubjectIDs",strType,strSpace);

  strSet.write(ids,H5::PredType::C_S1);
  for(int i = 0; i < numStrings; i++)
    {
    delete [] static_cast<char *>(ids[i].p);
    }
  delete [] ids;
}



________________________________
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

Reply via email to