Merge a source group into a target group.
32 {
33
34 bool isEmpty =
target.getNumObjs() == 0;
35
36
37 for (hsize_t ii = 0; ii <
source.getNumObjs(); ++ii) {
38 H5G_obj_t childType =
source.getObjTypeByIdx(ii);
39 std::string childName =
source.getObjnameByIdx(ii);
40
41 hsize_t targetIdx = 0;
42 for (; targetIdx <
target.getNumObjs(); ++targetIdx)
43 if (
target.getObjnameByIdx(targetIdx) == childName)
44 break;
46 if (found) {
47
48 if (
target.getObjTypeByIdx(targetIdx) != childType)
49 throw std::invalid_argument(
50 "Both target and source contain " + childName +
51 " but they have different types!");
52 }
54 throw std::invalid_argument(
55 "Target and source have different formats!");
56 }
57 switch (childType) {
58 case H5G_GROUP:
59 {
60 H5::Group sg =
source.openGroup(childName);
61
62
63 if (sg.attrExists("uhi_schema")) {
65 continue;
66 }
67 H5::Group tg =
found ?
68 target.openGroup(childName) :
70 try {
72 }
73 catch (...) {
74 std::cerr << "Encountered an error merging child " << childName << std::endl;
75 throw;
76 }
77 }
78 break;
79 case H5G_DATASET:
80 {
81 H5::DataSet
sd =
source.openDataSet(childName);
82 if (
sd.getSpace().getSimpleExtentNdims() == 0) {
83 std::cerr << "WARNING: skipping scalar '"
84 << childName << "'" << std::endl;
85 break;
86 }
87 H5::DataSet td =
found ?
88 target.openDataSet(childName) :
90 try {
92 }
93 catch (...) {
94 std::cerr << "Encountered an error merging child " << childName << std::endl;
95 throw;
96 }
97 }
98 break;
99 default:
100 break;
101 }
102 }
103
104
105 }
H5::Group createFrom(H5::H5Location &targetLocation, const H5::Group &source)
Make a new group from information in a source group.