Hello -
I'm writing a number of datatypes to HDF5 successfully using a struct
similar to this:
struct FooMemoryType_t {
boost::int64_t timestamp_;
char data_[ Foo::DATA_LENGTH ];
};
The data length varies for each type.
The char data originates in std::string and/or std::vector of char:
struct FooNetworkType_t {
boost::int64_t timestamp_;
std::string< char> data_;
};
The network data is therefore copied into the memory type for HDF write.
Is there a way to avoid such a copy using only a reference or pointer to the
network data assuming the network structure cannot be changed?
I did attempt the following, but H5Tinsert clearly needs an offset to actual
bytes in FooMemoryType_t.
struct FooMemoryType_t {
boost::int64_t timestamp_;
const char * data_p_;
};
compoundTypeID = H5Tcreate( H5T_COMPOUND, sizeof( FooMemoryType_t ) );
hid_t stringTypeID = H5Tcopy( H5T_C_S1 );
result = H5Tset_size( stringTypeID, Foo::DATA_LENGTH );
result = H5Tinsert( compoundTypeID, "Packet", HOFFSET( FooMemoryType_t,
data_p_ ), stringTypeID );
Thanks.