File indexing completed on 2025-04-19 08:55:35
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 deprecated {
0029
0030 template <std::size_t N>
0031 class FixedLenStringArray;
0032 }
0033
0034 namespace details {
0035
0036 template <typename Size>
0037 inline std::vector<std::size_t> to_vector_size_t(const std::vector<Size>& vec) {
0038 static_assert(std::is_same<Size, std::size_t>::value == false,
0039 " hsize_t != size_t mandatory here");
0040 std::vector<size_t> res(vec.size());
0041 std::transform(vec.cbegin(), vec.cend(), res.begin(), [](Size e) {
0042 return static_cast<size_t>(e);
0043 });
0044 return res;
0045 }
0046
0047
0048 inline std::vector<std::size_t> to_vector_size_t(const std::vector<std::size_t>& vec) {
0049 return vec;
0050 }
0051
0052
0053 template <typename T>
0054 inline std::string get_name(T fct) {
0055 const size_t maxLength = 255;
0056 char buffer[maxLength + 1];
0057 ssize_t retcode = fct(buffer, static_cast<hsize_t>(maxLength) + 1);
0058 if (retcode < 0) {
0059 HDF5ErrMapper::ToException<GroupException>("Error accessing object name");
0060 }
0061 const size_t length = static_cast<std::size_t>(retcode);
0062 if (length <= maxLength) {
0063 return std::string(buffer, length);
0064 }
0065 std::vector<char> bigBuffer(length + 1, 0);
0066 fct(bigBuffer.data(), length + 1);
0067 return std::string(bigBuffer.data(), length);
0068 }
0069
0070 template <class Container>
0071 inline std::string format_vector(const Container& container) {
0072 auto sout = std::stringstream{};
0073
0074 sout << "[ ";
0075 for (size_t i = 0; i < container.size(); ++i) {
0076 sout << container[i] << (i == container.size() - 1 ? "" : ", ");
0077 }
0078 sout << "]";
0079
0080 return sout.str();
0081 }
0082
0083 }
0084 }