chihaya
Validating delayed array operations in HDF5
Loading...
Searching...
No Matches
external_hdf5.hpp
Go to the documentation of this file.
1#ifndef CHIHAYA_EXTERNAL_HDF5_HPP
2#define CHIHAYA_EXTERNAL_HDF5_HPP
3
4#include "H5Cpp.h"
5#include "ritsuko/ritsuko.hpp"
6#include "ritsuko/hdf5/hdf5.hpp"
7
8#include "minimal_array.hpp"
9
15namespace chihaya {
16
21namespace external_hdf5 {
22
31inline ArrayDetails validate(const H5::Group& handle, const ritsuko::Version& version, Options& options) {
32 auto deets = minimal_array::validate(handle, version, options);
33
34 if (!options.details_only) {
35 auto fhandle = ritsuko::hdf5::open_dataset(handle, "file");
36 if (!ritsuko::hdf5::is_scalar(fhandle)) {
37 throw std::runtime_error("'file' should be a scalar");
38 }
39 if (!ritsuko::hdf5::is_utf8_string(fhandle)) {
40 throw std::runtime_error("'file' should have a datatype that can be represented by a UTF-8 encoded string");
41 }
42
43 auto nhandle = ritsuko::hdf5::open_dataset(handle, "name");
44 if (!ritsuko::hdf5::is_scalar(nhandle)) {
45 throw std::runtime_error("'name' should be a scalar");
46 }
47 if (!ritsuko::hdf5::is_utf8_string(nhandle)) {
48 throw std::runtime_error("'name' should have a datatype that can be represented by a UTF-8 encoded string");
49 }
50 }
51
52 return deets;
53}
54
55}
56
57}
58
59#endif
ArrayDetails validate(const H5::Group &handle, const ritsuko::Version &version, Options &options)
Definition: external_hdf5.hpp:31
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