File hdf5type.h
File List > code_source > templat > include > TempLat > lattice > IO > HDF5 > helpers > hdf5type.h
Go to the documentation of this file
#ifndef TEMPLAT_LATTICE_IO_HDF5_HELPERS_HDF5TYPE_H
#define TEMPLAT_LATTICE_IO_HDF5_HELPERS_HDF5TYPE_H
/* This file is part of TempLat, available at https://cosmolattice.github.io/templat .
Copyright 2021-2026 The TempLat authors, see AUTHORS.md.
Released under the MIT license, see LICENSE.md. */
// File info: Main contributor(s): Adrien Florio, Year: 2020
#ifdef HAVE_HDF5
#include <hdf5.h>
namespace TempLat
{
namespace HDF5TypeConstant
{
static constexpr int FixedSizeStringLength = 256;
}
template <typename T> struct HDF5Type {
void close() {}
};
template <> struct HDF5Type<double> {
HDF5Type() { type = H5T_NATIVE_DOUBLE; }
void close() {}
hid_t type;
};
template <> struct HDF5Type<float> {
HDF5Type() { type = H5T_NATIVE_FLOAT; }
void close() {}
hid_t type;
};
template <> struct HDF5Type<double *> {
HDF5Type() { type = H5T_NATIVE_DOUBLE; }
void close() {}
hid_t type;
};
template <> struct HDF5Type<float *> {
HDF5Type() { type = H5T_NATIVE_FLOAT; }
void close() {}
hid_t type;
};
template <> struct HDF5Type<int> {
HDF5Type() { type = H5T_NATIVE_INT; }
void close() {}
hid_t type;
};
template <> struct HDF5Type<int *> {
HDF5Type() { type = H5T_NATIVE_INT; }
void close() {}
hid_t type;
};
template <> struct HDF5Type<const char *> {
HDF5Type()
{
auto memtype = H5Tcopy(H5T_C_S1);
H5Tset_size(memtype, HDF5TypeConstant::FixedSizeStringLength);
type = memtype;
}
void close() { H5Tclose(type); }
hid_t type;
};
template <> struct HDF5Type<char *> {
HDF5Type()
{
auto memtype = H5Tcopy(H5T_C_S1);
H5Tset_size(memtype, HDF5TypeConstant::FixedSizeStringLength);
type = memtype;
}
void close() { H5Tclose(type); }
hid_t type;
};
template <> struct HDF5Type<char[HDF5TypeConstant::FixedSizeStringLength]> {
HDF5Type()
{
auto memtype = H5Tcopy(H5T_C_S1);
H5Tset_size(memtype, HDF5TypeConstant::FixedSizeStringLength);
type = memtype;
}
void close() { H5Tclose(type); }
hid_t type;
};
} // namespace TempLat
#endif
#endif