1#ifndef RITSUKO_HDF5_LOAD_DATASET_HPP
2#define RITSUKO_HDF5_LOAD_DATASET_HPP
14#include "_strings.hpp"
31 auto dtype = handle.getDataType();
32 if (dtype.isVariableStr()) {
34 handle.read(&vptr, dtype);
35 auto dspace = handle.getSpace();
36 [[maybe_unused]] VariableStringCleaner deletor(dtype.getId(), dspace.getId(), &vptr);
38 throw std::runtime_error(
"detected a NULL pointer for a variable length string in '" +
get_name(handle) +
"'");
40 std::string output(vptr);
43 size_t fixed_length = dtype.getSize();
44 std::vector<char> buffer(fixed_length);
45 handle.read(buffer.data(), dtype);
46 return std::string(buffer.begin(), buffer.begin() + find_string_length(buffer.data(), fixed_length));
57inline std::vector<std::string>
load_1d_string_dataset(
const H5::DataSet& handle, hsize_t full_length, hsize_t buffer_size) {
59 std::vector<std::string> output;
60 output.reserve(full_length);
61 for (hsize_t i = 0; i < full_length; ++i, stream.
next()) {
62 output.emplace_back(stream.
steal());
84template<
typename Type_>
99template<
typename Type_>
102 std::vector<Type_> output;
103 output.reserve(full_length);
104 for (hsize_t i = 0; i < full_length; ++i, stream.
next()) {
105 output.push_back(stream.
get());
117template<
typename Type_>
Stream a numeric 1-dimensional HDF5 dataset into memory.
Stream a numeric 1-dimensional HDF5 dataset into memory.
Stream a numeric 1-dimensional HDF5 dataset into memory.
Definition Stream1dNumericDataset.hpp:31
Type_ get()
Definition Stream1dNumericDataset.hpp:62
void next(size_t jump=1)
Definition Stream1dNumericDataset.hpp:88
Stream a 1-dimensional HDF5 string dataset into memory.
Definition Stream1dStringDataset.hpp:31
void next(size_t jump=1)
Definition Stream1dStringDataset.hpp:97
std::string steal()
Definition Stream1dStringDataset.hpp:84
Get the name of a HDF5 object.
std::string load_scalar_string_dataset(const H5::DataSet &handle)
Definition load_dataset.hpp:30
std::string get_name(const Handle_ &handle)
Definition get_name.hpp:24
const H5::PredType & as_numeric_datatype()
Definition as_numeric_datatype.hpp:26
std::vector< std::string > load_1d_string_dataset(const H5::DataSet &handle, hsize_t full_length, hsize_t buffer_size)
Definition load_dataset.hpp:57
hsize_t get_1d_length(const H5::DataSpace &space, bool allow_scalar)
Definition get_1d_length.hpp:25
Type_ load_scalar_numeric_dataset(const H5::DataSet &handle)
Definition load_dataset.hpp:85
std::vector< Type_ > load_1d_numeric_dataset(const H5::DataSet &handle, hsize_t full_length, hsize_t buffer_size)
Definition load_dataset.hpp:100
Assorted helper functions for parsing and validation.
Definition choose_missing_placeholder.hpp:15