Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 08:55:33

0001 /*
0002  *  Copyright (c), 2017, Adrien Devresse <adrien.devresse@epfl.ch>
0003  *
0004  *  Distributed under the Boost Software License, Version 1.0.
0005  *    (See accompanying file LICENSE_1_0.txt or copy at
0006  *          http://www.boost.org/LICENSE_1_0.txt)
0007  *
0008  */
0009 #pragma once
0010 
0011 #include <exception>
0012 #include <string>
0013 #include <vector>
0014 
0015 #include <H5Ipublic.h>
0016 
0017 namespace HighFive {
0018 
0019 namespace details {
0020 
0021 // iterator for H5 iterate
0022 
0023 struct HighFiveIterateData {
0024     inline HighFiveIterateData(std::vector<std::string>& my_names)
0025         : names(my_names)
0026         , err(NULL) {}
0027 
0028     std::vector<std::string>& names;
0029     std::exception* err;
0030 
0031     inline void throwIfError() {
0032         if (err) {
0033             throw *err;
0034         }
0035     }
0036 };
0037 
0038 template <typename InfoType>
0039 inline herr_t internal_high_five_iterate(hid_t /*id*/,
0040                                          const char* name,
0041                                          const InfoType* /*info*/,
0042                                          void* op_data) {
0043     auto* data = static_cast<HighFiveIterateData*>(op_data);
0044     try {
0045         data->names.emplace_back(name);
0046         return 0;
0047     } catch (...) {
0048         data->err = new ObjectException("Exception during H5Iterate, abort listing");
0049     }
0050     return -1;
0051 }
0052 
0053 }  // namespace details
0054 }  // namespace HighFive