18 #include <type_traits>
22 # include <boost/multi_array.hpp>
23 # include <boost/numeric/ublas/matrix.hpp>
26 # include <Eigen/Eigen>
31 #include "../H5Exception.hpp"
36 template <std::
size_t N>
37 class FixedLenStringArray;
45 static constexpr
size_t value = 0;
48 template <std::
size_t N>
50 static constexpr
size_t value = 1;
63 template <
typename T, std::
size_t N>
69 template<
typename T, std::
size_t N>
75 template <
typename T, std::
size_t Dims>
76 struct array_dims<boost::multi_array<T, Dims> > {
77 static constexpr
size_t value = Dims;
81 struct array_dims<boost::numeric::ublas::matrix<T> > {
82 static constexpr
size_t value = 2;
87 template<
typename T,
int M,
int N>
88 struct array_dims<Eigen::Matrix<T, M, N>> {
89 static constexpr
size_t value = 2;
92 template<
typename T,
int M,
int N>
93 struct array_dims<std::vector<Eigen::Matrix<T, M, N>>> {
94 static constexpr
size_t value = 2;
102 template <
typename T>
104 dims.push_back(vec.size());
108 template <
typename T>
110 std::vector<size_t> dims;
116 template <
typename T, std::
size_t N>
122 template <
typename T, std::
size_t N>
124 std::vector<size_t> dims;
130 template <
typename T>
131 using unqualified_t =
typename std::remove_const<typename std::remove_reference<T>::type
135 template <
typename T>
140 template <
typename T>
145 template <
typename T, std::
size_t N>
151 template <
typename T, std::
size_t Dims>
156 template <
typename T>
157 struct type_of_array<boost::numeric::ublas::matrix<T>> {
163 template<
typename T,
int M,
int N>
164 struct type_of_array<Eigen::Matrix<T, M, N>> {
169 template <
typename T>
174 template <
typename T, std::
size_t N>
186 template <
typename T>
188 typedef typename std::conditional<
189 std::is_same<unqualified_t<T>,
char>::value,
195 template <
typename T, std::
size_t N>
197 typedef typename std::conditional<
198 std::is_same<unqualified_t<T>,
char>::value,
211 template <
typename T>
222 template <
typename T>
224 static const bool value =
true;
227 template <
typename T, std::
size_t N>
234 template <
typename Size>
236 static_assert(std::is_same<Size, std::size_t>::value ==
false,
237 " hsize_t != size_t mandatory here");
238 std::vector<size_t> res(vec.size());
239 std::transform(vec.cbegin(), vec.cend(), res.begin(), [](Size e) {
240 return static_cast<size_t>(e);
253 const size_t maxLength = 255;
254 char buffer[maxLength + 1];
255 ssize_t retcode = fct(buffer,
static_cast<hsize_t
>(maxLength) + 1);
257 HDF5ErrMapper::ToException<GroupException>(
"Error accessing object name");
259 const size_t length =
static_cast<std::size_t
>(retcode);
260 if (length <= maxLength) {
263 std::vector<char> bigBuffer(length + 1, 0);
264 fct(bigBuffer.data(),
static_cast<hsize_t
>(length) + 1);
271 #endif // H5UTILS_HPP