h5gt 0.2.0
C++ wrapper for HDF5 library (based on HighFive project)
Loading...
Searching...
No Matches
H5Iterables_misc.hpp
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#ifndef H5ITERABLE_MISC_HPP
10#define H5ITERABLE_MISC_HPP
11
12#include <exception>
13#include <string>
14#include <vector>
15
16#include <H5Ipublic.h>
17
18namespace h5gt {
19
20namespace details {
21
22// iterator for H5 iterate
23
25 inline H5GTIterateData(std::vector<std::string>& my_names)
26 : names(my_names), 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_h5gt_iterate(
40 hid_t /*id*/, const char* name, const InfoType* /*info*/, void* op_data) {
41 auto* data = static_cast<H5GTIterateData*>(op_data);
42 try {
43 data->names.emplace_back(name);
44 return 0;
45 } catch (...) {
46 data->err =
47 new ObjectException("Exception during H5Iterate, abort listing");
48 }
49 return -1;
50}
51
52} // end details
53}
54
55#endif // H5ITERABLE_MISC_HPP
Exception specific to h5gt Object interface.
Definition H5Exception.hpp:75
Definition H5Iterables_misc.hpp:24