#include <iostream>
using std::cout;
using std::endl;
#include <string>
#include "H5Cpp.h"
const H5std_string FILE_NAME("SDScompound.h5");
const H5std_string DATASET_NAME("ArrayOfStructures");
const H5std_string MEMBER1("a_name");
const H5std_string MEMBER2("b_name");
const H5std_string MEMBER3("c_name");
const int LENGTH = 10;
const int RANK = 1;
int
main(void)
{
typedef struct s1_t {
int a;
float b;
double c;
} s1_t;
typedef struct s2_t {
double c;
int a;
} s2_t;
try {
int i;
s1_t s1[LENGTH];
for (i = 0; i < LENGTH; i++) {
s1[i].a = i;
s1[i].b = i * i;
s1[i].c = 1. / (i + 1);
}
hsize_t dim[] = {LENGTH};
dataset->
write(s1, mtype1);
delete dataset;
delete file;
file =
new H5File(FILE_NAME, H5F_ACC_RDONLY);
s2_t s2[LENGTH];
dataset->
read(s2, mtype2);
cout << endl << "Field c : " << endl;
for (i = 0; i < LENGTH; i++)
cout << s2[i].c << " ";
cout << endl;
cout << endl << "Field a : " << endl;
for (i = 0; i < LENGTH; i++)
cout << s2[i].a << " ";
cout << endl;
float s3[LENGTH];
dataset->
read(s3, mtype3);
cout << endl << "Field b : " << endl;
for (i = 0; i < LENGTH; i++)
cout << s3[i] << " ";
cout << endl;
delete dataset;
delete file;
}
return -1;
}
return -1;
}
return -1;
}
return -1;
}
return 0;
}