HighFive 2.10.1
HighFive - Header-only C++ HDF5 interface
Loading...
Searching...
No Matches
H5Iterables_misc.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c), 2017, Adrien Devresse <adrien.devresse@epfl.ch>
3 *
4 * Distributed under the Boost Software License, Version 1.0.
5 * (See accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
7 *
8 */
9#pragma once
10
11#include <exception>
12#include <string>
13#include <vector>
14
15#include <H5Ipublic.h>
16
17namespace HighFive {
18
19namespace details {
20
21// iterator for H5 iterate
22
23struct HighFiveIterateData {
24 inline HighFiveIterateData(std::vector<std::string>& my_names)
25 : names(my_names)
26 , err(NULL) {}
27
28 std::vector<std::string>& names;
29 std::exception* err;
30
31 inline void throwIfError() {
32 if (err) {
33 throw *err;
34 }
35 }
36};
37
38template <typename InfoType>
39inline herr_t internal_high_five_iterate(hid_t /*id*/,
40 const char* name,
41 const InfoType* /*info*/,
42 void* op_data) {
43 auto* data = static_cast<HighFiveIterateData*>(op_data);
44 try {
45 data->names.emplace_back(name);
46 return 0;
47 } catch (...) {
48 data->err = new ObjectException("Exception during H5Iterate, abort listing");
49 }
50 return -1;
51}
52
53} // namespace details
54} // namespace HighFive
Definition H5_definitions.hpp:22