Hi Phil,

You can read the string into an std::string or a char* buffer then assign it
to a vector element, or read directly to the vector element, I think.  Here
is an example using the char* buffer to read a string:

        char *string_ds;
        dataset.read(&string_ds, vlst); // string is variable length.
or
        char string_ds[size_of_your_string]; // or dynamically allocate it
        dataset.read(string_ds, vlst); // string is fixed length.

I hope that helps.
Binh-Minh

-----Original Message-----
From: [email protected] [mailto:[email protected]]
On Behalf Of Philipp Kraus
Sent: Monday, June 07, 2010 11:56 AM
To: [email protected]
Subject: Re: [Hdf-forum] HDF5 with C++


I know these examples and they help me to understand the structures, but I
don't find string examples and (string) array examples. I have a hdf5 file
(created with Matlab) and I would like to read in my C++ program. My code:

std::vector<std::string> hdf::readStringVector( const std::string& p_path )
const
    {
        H5::DataSet   l_dataset   = m_file.openDataSet( p_path.c_str() );
        H5::DataSpace l_dataspace = l_dataset.getSpace();
        
        hsize_t l_size[1];
        l_dataspace.getSimpleExtentDims( l_size );              
        l_dataspace.close();

        std::vector<std::string> l_vec( l_size[0] );

  *** How can I read the array data             
        
        return l_vec;
    }



-- 
View this message in context:
http://hdf-forum.184993.n3.nabble.com/HDF5-with-C-tp874249p876706.html
Sent from the hdf-forum mailing list archive at Nabble.com.

_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org


-- 
Internal Virus Database is out-of-date.
Checked by AVG. 
Version: 7.5.549 / Virus Database: 270.9.0/1778 - Release Date: 11/9/2008
2:14 PM



_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Reply via email to