ritsuko
Helper utilities for ArtifactDB C++ code
Loading...
Searching...
No Matches
open.hpp
Go to the documentation of this file.
1#ifndef RITSUKO_HDF5_VLS_OPEN_HPP
2#define RITSUKO_HDF5_VLS_OPEN_HPP
3
4#include "H5Cpp.h"
5
6#include <string>
7#include <stdexcept>
8
9#include "../open.hpp"
10#include "../get_name.hpp"
11#include "Pointer.hpp"
12
18namespace ritsuko {
19
20namespace hdf5 {
21
22namespace vls {
23
41inline H5::DataSet open_pointers(const H5::Group& handle, const char* name, size_t offset_precision, size_t length_precision) {
42 auto dhandle = open_dataset(handle, name);
43 if (dhandle.getTypeClass() != H5T_COMPOUND) {
44 throw std::runtime_error("expected a compound datatype for a VLS pointer dataset at '" + get_name(dhandle) + "'");
45 }
46 try {
47 validate_pointer_datatype(dhandle.getCompType(), offset_precision, length_precision);
48 } catch (std::exception& e) {
49 throw std::runtime_error("incorrect type for VLS pointer dataset at '" + get_name(dhandle) + "; " + std::string(e.what()));
50 }
51 return dhandle;
52}
53
71inline H5::DataSet open_heap(const H5::Group& handle, const char* name) {
72 auto dhandle = open_dataset(handle, name);
73 if (dhandle.getTypeClass() != H5T_INTEGER) {
74 throw std::runtime_error("expected an integer datatype for the VLS heap at '" + get_name(dhandle) + "'");
75 }
76 if (exceeds_integer_limit(dhandle.getIntType(), 8, false)) {
77 throw std::runtime_error("expected 8-bit unsigned integers for the VLS heap at '" + get_name(dhandle) + "'");
78 }
79 if (dhandle.getSpace().getSimpleExtentNdims() != 1) {
80 throw std::runtime_error("expected a 1-dimensional dataset for the VLS heap at '" + get_name(dhandle) + "'");
81 }
82 return dhandle;
83}
84
85}
86
87}
88
89}
90
91#endif
Compound datatype for the VLS heap pointer.
Get the name of a HDF5 object.
H5::DataSet open_heap(const H5::Group &handle, const char *name)
Definition open.hpp:71
void validate_pointer_datatype(const H5::CompType &type, size_t offset_precision, size_t length_precision)
Definition Pointer.hpp:85
H5::DataSet open_pointers(const H5::Group &handle, const char *name, size_t offset_precision, size_t length_precision)
Definition open.hpp:41
std::string get_name(const Handle_ &handle)
Definition get_name.hpp:24
H5::DataSet open_dataset(const H5::Group &handle, const char *name)
Definition open.hpp:72
bool exceeds_integer_limit(const H5::IntType &itype, size_t precision, bool is_signed)
Definition exceeds_limit.hpp:27
Assorted helper functions for parsing and validation.
Definition choose_missing_placeholder.hpp:15
Convenience functions to safely open HDF5 handles.