diff --git a/sample/testHDF5.cpp b/sample/testHDF5.cpp index f09147d..4011889 100644 --- a/sample/testHDF5.cpp +++ b/sample/testHDF5.cpp @@ -45,17 +45,30 @@ struct MyStruct char c; }; +struct MyStruct2 +{ + MyStruct base; + int d; +}; + + CTOOL_STRUCT_TYPE(MyStruct, hdf5t_MyStruct, ((int, a)) ((double, b)) ((char, c)) ) +CTOOL_STRUCT_TYPE(MyStruct2, hdf5t_MyStruct2, + ((MyStruct, base)) + ((int, d)) +) + int main() { typedef boost::multi_array array_type; typedef boost::multi_array array3_type; typedef boost::multi_array array_mys_type; + typedef boost::multi_array array_mys2_type; typedef boost::multi_array, 2> arrayc_type; typedef array_type::index index; @@ -68,6 +81,7 @@ int main() array3_type C(boost::extents[2][3][4]); arrayc_type D, E; array_mys_type F(boost::extents[10]), G; + array_mys2_type H(boost::extents[10]); int values = 0; for (index i = 0; i != 2; i++) @@ -79,11 +93,14 @@ int main() F[i].a = i; F[i].b = double(i)/4.; F[i].c = 'r'+i; + H[i].base = F[i]; + H[i].d = 2*i; } std::cout << " c = " << ((char *)&F[1])[offsetof(MyStruct, c)] << endl; CosmoTool::hdf5_write_array(g, "test_data", A); CosmoTool::hdf5_write_array(g, "test_struct", F); + CosmoTool::hdf5_write_array(g, "test_struct2", H); CosmoTool::hdf5_read_array(g, "test_data", B);