hops
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 #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 
18 namespace HighFive {
19 
20 namespace details {
21 
22 // iterator for H5 iterate
23 
25  inline HighFiveIterateData(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 
38 template <typename InfoType>
40  hid_t /*id*/, const char* name, const InfoType* /*info*/, void* op_data) {
41  auto* data = static_cast<HighFiveIterateData*>(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
HighFive::details::HighFiveIterateData::HighFiveIterateData
HighFiveIterateData(std::vector< std::string > &my_names)
Definition: H5Iterables_misc.hpp:25
HighFive::details::HighFiveIterateData::err
std::exception * err
Definition: H5Iterables_misc.hpp:29
HighFive::details::internal_high_five_iterate
herr_t internal_high_five_iterate(hid_t, const char *name, const InfoType *, void *op_data)
Definition: H5Iterables_misc.hpp:39
HighFive::details::HighFiveIterateData
Definition: H5Iterables_misc.hpp:24
HighFive::details::HighFiveIterateData::names
std::vector< std::string > & names
Definition: H5Iterables_misc.hpp:28
HighFive::ObjectException
Exception specific to HighFive Object interface.
Definition: H5Exception.hpp:75
HighFive::details::HighFiveIterateData::throwIfError
void throwIfError()
Definition: H5Iterables_misc.hpp:31
HighFive
Definition: H5_definitions.hpp:15