Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
typetraits.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
3
4#ifndef DUNE_FUFEM_HDF5_TYPETRAITS_HH
5#define DUNE_FUFEM_HDF5_TYPETRAITS_HH
6
7#if __has_include(<hdf5.h>)
8
9#include <hdf5.h>
10
12
13namespace HDF5 {
14template <typename ctype>
15struct TypeTraits {
16 static hid_t getType() {
17 DUNE_THROW(Dune::Exception, "Type not recognised");
18 }
19};
20
21template <>
22struct TypeTraits<float> {
23 static hid_t getType() { return H5T_NATIVE_FLOAT; }
24};
25template <>
26struct TypeTraits<double> {
27 static hid_t getType() { return H5T_NATIVE_DOUBLE; }
28};
29template <>
30struct TypeTraits<long double> {
31 static hid_t getType() { return H5T_NATIVE_LDOUBLE; }
32};
33
34template <>
35struct TypeTraits<char> {
36 static hid_t getType() { return H5T_NATIVE_CHAR; }
37};
38template <>
39struct TypeTraits<signed char> {
40 static hid_t getType() { return H5T_NATIVE_SCHAR; }
41};
42template <>
43struct TypeTraits<unsigned char> {
44 static hid_t getType() { return H5T_NATIVE_UCHAR; }
45};
46
47template <>
48struct TypeTraits<short> {
49 static hid_t getType() { return H5T_NATIVE_SHORT; }
50};
51template <>
52struct TypeTraits<unsigned short> {
53 static hid_t getType() { return H5T_NATIVE_USHORT; }
54};
55
56template <>
57struct TypeTraits<int> {
58 static hid_t getType() { return H5T_NATIVE_INT; }
59};
60template <>
61struct TypeTraits<unsigned int> {
62 static hid_t getType() { return H5T_NATIVE_UINT; }
63};
64
65template <>
66struct TypeTraits<long> {
67 static hid_t getType() { return H5T_NATIVE_LONG; }
68};
69template <>
70struct TypeTraits<unsigned long> {
71 static hid_t getType() { return H5T_NATIVE_ULONG; }
72};
73
74template <>
75struct TypeTraits<long long> {
76 static hid_t getType() { return H5T_NATIVE_LLONG; }
77};
78template <>
79struct TypeTraits<unsigned long long> {
80 static hid_t getType() { return H5T_NATIVE_ULLONG; }
81};
82}
83
84#else
85 #warning Including hdf5/typetraits.hh but hdf5.h is missing.
86#endif // __has_include(<hdf5.h>)
87
88#endif
#define DUNE_THROW(E,...)