Hi Werner,

On Sep 23, 2010, at 12:04 PM, Werner Benger wrote:

> Hi,
> 
> how would one create a compound data type that consists out of two strings?
> Loose equivalent in C:
> 
> struct        Type
> {
>       char    *first, *second;
> };
> 
> In HDF5, it would be a compound type made from two type ID's that are
> either "hid_t H5Tvlen_create( hid_t base_type_id  )" or H5T_C_S1, to
> be inserted as a member "first" and "second" to a
> 
> hid_t TypeID = H5Tcreate( H5T_COMPOUND, size_t size  );
>   H5Tinsert( TypeID, "first" , 0            ,  H5T_C_S1  );
>   H5Tinsert( TypeID, "second", size_t offset,  H5T_C_S1  );
> 
> 
> However, what would be the "size" of this compound data type and the
> offset of the second member?
> 
> It would seem this presumably simple approach can't work (would be nice
> to document that around H5Tcreate() or H5Tinsert() ) ?
> 
> Alternatively, it should be possible to create an array of strings, using
> 
> hsize_t dims[1] = { 2 };
> H5Tarray_create( H5T_C_S1, 1, dims);
> 
> but this would be less verbose as the data type doesn't get named members.
> 
> Any hints/recommendation on what would work best?

        Nope, having two VL-strings as fields in a compound datatype is fine.  
Just create a variable length string datatype (tid = H5Tcopy(H5T_C_S1); 
H5Tset_size(tid, H5T_VARIABLE); )  and then insert that for each field, at the 
appropriate offset.

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

Reply via email to