Hello --
Part of my motivation for posting this is just in case someone finds
it a useful starting point for whatever they're trying to do. I'm a
newb at hdf5, but I finally figured out how to write a vector of
strings:
std::vector<std::string> confs;
...
H5::H5File file (filename, H5F_ACC_TRUNC);
H5::StrType st(H5::PredType::C_S1, H5T_VARIABLE);
hsize_t dim[1] = {0};
dim[0] = confs.size();
H5::DataSpace dataspace = H5::DataSpace(1, dim);
file.createDataSet(confName.str(),st,dataspace).write(&confs[0],st);
which seems simple enough, so i'm happy with this, unless someone has
a suggestion... but reading this seems more difficult than necessary
because I can't figure out if there's an easy way to read the whole
vector at once, instead of picking them off one at a time:
H5::H5File file (filename, H5F_ACC_RDONLY);
H5::DataSet dataset = file.openDataSet(confName.str());
hsize_t dims[1];
dataset.getSpace().getSimpleExtentDims(dims, NULL);
std::vector<std::string> conf(dims[0]);
for(std::size_t j=0; j<dims[0]; j++){
H5::DataSpace file_space = dataset.getSpace();
hsize_t count[1] = {1};
hsize_t start[1] = {j};
file_space.selectHyperslab(H5S_SELECT_SET,count,start);
hsize_t dim1[1] = {1};
H5::DataSpace mem_space(1,dim1);
dataset.read(conf[j],st,mem_space,file_space);
}
note: i've not tried to compile these abstracted code snippets
this seems to work for me... but if there's something better, I prefer
simple code... any suggestions?
thanks!
amos.