1#ifndef CHIHAYA_UNARY_LOGIC_HPP
2#define CHIHAYA_UNARY_LOGIC_HPP
5#include "ritsuko/ritsuko.hpp"
6#include "ritsuko/hdf5/hdf5.hpp"
10#include "utils_logic.hpp"
11#include "utils_unary.hpp"
12#include "utils_type.hpp"
13#include "utils_misc.hpp"
27namespace unary_logic {
38 auto seed_details = internal_logic::fetch_seed(handle,
"seed", version, options);
41 auto method = internal_unary::load_method(handle);
42 if (method !=
"!" && method !=
"&&" && method !=
"||") {
43 throw std::runtime_error(
"unrecognized operation in 'method' (got '" + method +
"')");
48 auto side = internal_unary::load_side(handle);
49 if (side !=
"left" && side !=
"right") {
50 throw std::runtime_error(
"'side' for operation '" + method +
"' should be 'left' or 'right' (got '" + side +
"')");
54 auto vhandle = ritsuko::hdf5::open_dataset(handle,
"value");
57 if (version.lt(1, 1, 0)) {
58 if (vhandle.getTypeClass() == H5T_STRING) {
59 throw std::runtime_error(
"dataset should be integer, float or boolean");
62 auto type = ritsuko::hdf5::open_and_load_scalar_string_attribute(vhandle,
"type");
63 auto array_type = internal_type::translate_type_1_1(type);
64 if (array_type != INTEGER && array_type != BOOLEAN && array_type != FLOAT) {
65 throw std::runtime_error(
"dataset should be integer, float or boolean");
67 internal_type::check_type_1_1(vhandle, array_type);
70 internal_misc::validate_missing_placeholder(vhandle, version);
72 size_t ndims = vhandle.getSpace().getSimpleExtentNdims();
75 }
else if (ndims == 1) {
77 vhandle.getSpace().getSimpleExtentDims(&extent);
78 internal_unary::check_along(handle, version, seed_details.dimensions, extent);
80 throw std::runtime_error(
"dataset should be scalar or 1-dimensional");
82 }
catch (std::exception& e) {
83 throw std::runtime_error(
"failed to validate 'value'; " + std::string(e.what()));
88 seed_details.type = BOOLEAN;
ArrayDetails validate(const H5::Group &handle, const ritsuko::Version &version, Options &options)
Definition: unary_logic.hpp:37
Namespace for all chihaya functions.
Definition: binary_arithmetic.hpp:22
Details about an array.
Definition: utils_public.hpp:36
Validation options.
Definition: utils_public.hpp:66
bool details_only
Definition: utils_public.hpp:71