File indexing completed on 2025-08-05 08:19:07
0001
0002
0003
0004
0005
0006 #ifndef HDF5_UTILS_H
0007 #define HDF5_UTILS_H
0008
0009 #include <string>
0010
0011 #ifdef TRENTO_HDF5
0012 #include <H5Cpp.h>
0013
0014 #ifndef H5_VERSION_GE
0015 #define H5_VERSION_GE(Maj,Min,Rel) \
0016 (((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR==Min) && (H5_VERS_RELEASE>=Rel)) || \
0017 ((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR>Min)) || \
0018 (H5_VERS_MAJOR>Maj))
0019 #endif
0020 #endif
0021
0022 #include "fwd_decl.h"
0023
0024 namespace trento {
0025
0026 namespace hdf5 {
0027
0028
0029 bool filename_is_hdf5(const fs::path& path);
0030 bool filename_is_hdf5(const std::string& path);
0031
0032 #ifdef TRENTO_HDF5
0033
0034
0035
0036 H5::H5File try_open_file(
0037 const std::string& path, unsigned int flags = H5F_ACC_RDONLY);
0038
0039
0040
0041 using H5::PredType;
0042 template <typename T> inline const PredType& type();
0043 template <> inline const PredType& type<int>() { return PredType::NATIVE_INT; }
0044 template <> inline const PredType& type<unsigned long>() { return PredType::NATIVE_UINT; }
0045 template <> inline const PredType& type<long int>() { return PredType::NATIVE_LONG; }
0046 template <> inline const PredType& type<long long int>() { return PredType::NATIVE_LLONG; }
0047 template <> inline const PredType& type<float>() { return PredType::NATIVE_FLOAT; }
0048 template <> inline const PredType& type<double>() { return PredType::NATIVE_DOUBLE; }
0049 template <> inline const PredType& type<long double>() { return PredType::NATIVE_LDOUBLE; }
0050
0051
0052
0053 template <typename Container>
0054 inline typename std::enable_if<
0055 std::is_same<typename Container::value_type, hsize_t>::value,
0056 H5::DataSpace
0057 >::type
0058 make_dataspace(const Container& shape) {
0059 return H5::DataSpace{shape.size(), shape.data()};
0060 }
0061
0062 #endif
0063
0064 }
0065
0066 }
0067
0068 #endif