38 auto shandle = group.openGroup(
"seed");
39 seed_details =
validate(shandle, version, options);
41 std::throw_with_nested(std::runtime_error(
"failed to validate 'seed'"));
47 auto mhandle = group.openDataSet(
"method");
48 method = read_scalar_string_dataset(mhandle);
49 if (!is_valid_comparison_operation(method)) {
50 throw std::runtime_error(
"unrecognized operation '" + method +
"'");
53 std::throw_with_nested(std::runtime_error(
"failed to validate 'method'"));
58 auto shandle = group.openDataSet(
"side");
59 auto side = read_scalar_string_dataset(shandle);
60 if (side !=
"left" && side !=
"right") {
61 throw std::runtime_error(
"expected either 'left' or 'right'");
64 std::throw_with_nested(std::runtime_error(
"failed to validate 'side'"));
67 enum Failure { VALUE, ALONG };
68 Failure who_failed = VALUE;
70 auto vhandle = group.openDataSet(
"value");
73 if (version.lt(1, 1, 0)) {
74 val_type = translate_type_0_99(vhandle.getTypeClass());
77 auto thandle = vhandle.openAttribute(
"type");
78 auto type = read_scalar_string_attribute(thandle);
79 val_type = translate_type_1_1(type);
80 check_type_1_1(vhandle, val_type);
82 std::throw_with_nested(std::runtime_error(
"failed to validate the 'type' attribute"));
85 if ((val_type == STRING) != (seed_details.
type == STRING)) {
86 throw std::runtime_error(
"both or neither of 'seed' and 'value' should contain strings");
89 validate_missing_placeholder(vhandle, version);
91 auto ndims = vhandle.getSpace().getSimpleExtentNdims();
93 if (vhandle.getTypeClass() == H5T_STRING) {
94 ritsuko::hdf5::validate_scalar_string(vhandle);
97 }
else if (ndims == 1) {
99 vhandle.getSpace().getSimpleExtentDims(&extent);
101 auto ahandle = group.openDataSet(
"along");
102 check_unary_along(ahandle, version, seed_details.
dimensions, extent);
105 if (vhandle.getTypeClass() == H5T_STRING) {
106 ritsuko::hdf5::validate_1d_strings(
110 ritsuko::hdf5::Validate1dStringsOptions opt;
118 throw std::runtime_error(
"dataset should be scalar or 1-dimensional");
123 switch (who_failed) {
124 case VALUE: desc =
"value";
break;
125 case ALONG: desc =
"along";
break;
127 std::throw_with_nested(std::runtime_error(
"failed to validate '" + desc +
"'"));
131 seed_details.
type = BOOLEAN;
ArrayDetails validate(const H5::Group &group, const ritsuko::Version &version, const Options &options)
Definition validate.hpp:96
ArrayDetails validate_unary_comparison(const H5::Group &group, const ritsuko::Version &version, const Options &options)
Definition unary_comparison.hpp:35