File indexing completed on 2026-06-25 08:27:26
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include <algorithm>
0013 #include <array>
0014 #include <cstddef> // __GLIBCXX__
0015 #include <exception>
0016 #include <string>
0017 #include <type_traits>
0018 #include <vector>
0019 #include <sstream>
0020
0021 #include <H5public.h>
0022
0023 #include "../H5Exception.hpp"
0024 #include "H5Friends.hpp"
0025
0026 namespace HighFive {
0027
0028 namespace details {
0029
0030 template <typename Size>
0031 inline std::vector<std::size_t> to_vector_size_t(const std::vector<Size>& vec) {
0032 static_assert(!std::is_same<Size, std::size_t>::value, " hsize_t != size_t mandatory here");
0033 std::vector<size_t> res(vec.size());
0034 std::transform(vec.cbegin(), vec.cend(), res.begin(), [](Size e) {
0035 return static_cast<size_t>(e);
0036 });
0037 return res;
0038 }
0039
0040
0041 inline std::vector<std::size_t> to_vector_size_t(const std::vector<std::size_t>& vec) {
0042 return vec;
0043 }
0044
0045
0046 template <typename T>
0047 inline std::string get_name(T fct) {
0048 constexpr size_t maxLength = 255;
0049 std::array<char, maxLength + 1> buffer;
0050 ssize_t retcode = fct(buffer.data(), static_cast<hsize_t>(buffer.size()));
0051 if (retcode < 0) {
0052 HDF5ErrMapper::ToException<GroupException>("Error accessing object name");
0053 }
0054 const size_t length = static_cast<std::size_t>(retcode);
0055 if (length <= maxLength) {
0056 return std::string(buffer.data(), length);
0057 }
0058 std::vector<char> bigBuffer(length + 1, 0);
0059 fct(bigBuffer.data(), length + 1);
0060 return std::string(bigBuffer.data(), length);
0061 }
0062
0063 template <class Container>
0064 inline std::string format_vector(const Container& container) {
0065 auto sout = std::stringstream{};
0066
0067 sout << "[ ";
0068 for (size_t i = 0; i < container.size(); ++i) {
0069 sout << container[i] << (i == container.size() - 1 ? "" : ", ");
0070 }
0071 sout << "]";
0072
0073 return sout.str();
0074 }
0075
0076 }
0077 }