Added support for enum type in HDF5

This commit is contained in:
Guilhem Lavaux 2015-02-16 10:59:33 +01:00
parent 188af485c9
commit 22aa572370
2 changed files with 79 additions and 1 deletions

View file

@ -51,6 +51,10 @@ struct MyStruct2
int d;
};
enum MyColors
{
RED, GREEN, BLUE
};
CTOOL_STRUCT_TYPE(MyStruct, hdf5t_MyStruct,
((int, a))
@ -63,11 +67,17 @@ CTOOL_STRUCT_TYPE(MyStruct2, hdf5t_MyStruct2,
((int, d))
)
CTOOL_ENUM_TYPE(MyColors, hdf5t_MyColors,
(RED) (GREEN) (BLUE)
)
int main()
{
typedef boost::multi_array<float, 2> array_type;
typedef boost::multi_array<float, 3> array3_type;
typedef boost::multi_array<MyStruct, 1> array_mys_type;
typedef boost::multi_array<MyColors, 1> array_mys_color;
typedef boost::multi_array<bool, 1> array_mys_bool;
typedef boost::multi_array<MyStruct2, 1> array_mys2_type;
typedef boost::multi_array<std::complex<double>, 2> arrayc_type;
typedef array_type::index index;
@ -82,6 +92,13 @@ int main()
arrayc_type D, E;
array_mys_type F(boost::extents[10]), G;
array_mys2_type H(boost::extents[10]);
array_mys_color I(boost::extents[2]);
array_mys_bool J(boost::extents[2]);
I[0] = RED;
I[1] = BLUE;
J[0] = false;
J[1] = true;
int values = 0;
for (index i = 0; i != 2; i++)
@ -101,7 +118,8 @@ int main()
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_write_array(g, "colors", I);
CosmoTool::hdf5_write_array(g, "bools", J);
CosmoTool::hdf5_read_array(g, "test_data", B);
int verify = 0;