H5DataType_misc.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c), 2017, Adrien Devresse <adrien.devresse@epfl.ch>
3  *
4  * Distributed under the Boost Software License, Version 1.0.
5  * (See accompanying file LICENSE_1_0.txt or copy at
6  * http://www.boost.org/LICENSE_1_0.txt)
7  *
8  */
9 #ifndef H5DATATYPE_MISC_HPP
10 #define H5DATATYPE_MISC_HPP
11 
12 #include <string>
13 #include <complex>
14 
15 #include "../H5DataType.hpp"
16 #include "../H5Exception.hpp"
17 
18 #include <H5Tpublic.h>
19 
20 namespace HighFive {
21 
22 inline DataType::DataType() {}
23 
24 inline bool DataType::operator==(const DataType& other) const {
25  return (H5Tequal(_hid, other._hid) > 0);
26 }
27 
28 inline bool DataType::operator!=(const DataType& other) const {
29  return !(*this == other);
30 }
31 
32 // char mapping
33 template <>
35  _hid = H5Tcopy(H5T_NATIVE_CHAR);
36 }
37 
38 template <>
40  _hid = H5Tcopy(H5T_NATIVE_CHAR);
41 }
42 
43 template <>
45  _hid = H5Tcopy(H5T_NATIVE_UCHAR);
46 }
47 
48 // short mapping
49 template <>
51  _hid = H5Tcopy(H5T_NATIVE_SHORT);
52 }
53 
54 template <>
56  _hid = H5Tcopy(H5T_NATIVE_USHORT);
57 }
58 
59 // integer mapping
60 template <>
62  _hid = H5Tcopy(H5T_NATIVE_INT);
63 }
64 
65 template <>
67  _hid = H5Tcopy(H5T_NATIVE_UINT);
68 }
69 
70 // long mapping
71 template <>
73  _hid = H5Tcopy(H5T_NATIVE_LONG);
74 }
75 
76 template <>
78  _hid = H5Tcopy(H5T_NATIVE_ULONG);
79 }
80 
81 // long long mapping
82 template <>
84  _hid = H5Tcopy(H5T_NATIVE_LLONG);
85 }
86 
87 template <>
89  _hid = H5Tcopy(H5T_NATIVE_ULLONG);
90 }
91 
92 // float and double mapping
93 template <>
95  _hid = H5Tcopy(H5T_NATIVE_FLOAT);
96 }
97 
98 template <>
100  _hid = H5Tcopy(H5T_NATIVE_DOUBLE);
101 }
102 
103 // boolean mapping
104 template <>
106  _hid = H5Tcopy(H5T_NATIVE_HBOOL);
107 }
108 
109 // std string
110 template <>
112  _hid = H5Tcopy(H5T_C_S1);
113  if (H5Tset_size(_hid, H5T_VARIABLE) < 0) {
114  HDF5ErrMapper::ToException<DataTypeException>(
115  "Unable to define datatype size to variable");
116  }
117  // define encoding to UTF-8 by default
118  H5Tset_cset(_hid, H5T_CSET_UTF8);
119 }
120 
121 template <>
123 {
124  static struct ComplexType : public Object
125  {
126  ComplexType()
127  {
128  _hid = H5Tcreate(H5T_COMPOUND, sizeof(std::complex<double>));
129  // h5py/numpy compatible datatype
130  H5Tinsert(_hid, "r", 0, H5T_NATIVE_DOUBLE);
131  H5Tinsert(_hid, "i", sizeof(double), H5T_NATIVE_DOUBLE);
132  };
133  } complexType;
134  _hid = H5Tcopy(complexType.getId());
135 }
136 
137 }
138 
139 
140 
141 
142 #endif // H5DATATYPE_MISC_HPP
HighFive::DataType::DataType
DataType()
Definition: H5DataType_misc.hpp:22
HighFive::DataType
HDF5 Data Type.
Definition: H5DataType.hpp:21
HighFive::Object
Definition: H5Object.hpp:21
HighFive::AtomicType::AtomicType
AtomicType()
HighFive::DataType::operator==
bool operator==(const DataType &other) const
Definition: H5DataType_misc.hpp:24
HighFive::AtomicType
create an HDF5 DataType from a C++ type
Definition: H5DataType.hpp:41
HighFive::DataType::operator!=
bool operator!=(const DataType &other) const
Definition: H5DataType_misc.hpp:28
HighFive::Object::_hid
hid_t _hid
Definition: H5Object.hpp:48
HighFive
Definition: H5Annotate_traits.hpp:14


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:23