openPMD-api
DatatypeMacros.hpp
1 /* Copyright 2023 Franz Poeschel
2  *
3  * This file is part of openPMD-api.
4  *
5  * openPMD-api is free software: you can redistribute it and/or modify
6  * it under the terms of of either the GNU General Public License or
7  * the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * openPMD-api is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License and the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * and the GNU Lesser General Public License along with openPMD-api.
19  * If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 // sic!
23 // no #pragma once
24 // Since the macros can be un-defined with UndefDatatypeMacros.hpp, this header
25 // may be included multiple times into one translation unit
26 
27 #include <array>
28 #include <complex>
29 #include <vector>
30 
31 // Need to alias this to avoid the comma
32 // Cannot use a namespace, otherwise the macro will work either only within
33 // or outside the namespace
34 // Defining macros means polluting the global namespace anyway
35 using openpmd_array_double_7 = std::array<double, 7>;
36 
37 #define OPENPMD_FOREACH_DATATYPE(MACRO) \
38  MACRO(char) \
39  MACRO(unsigned char) \
40  MACRO(signed char) \
41  MACRO(short) \
42  MACRO(int) \
43  MACRO(long) \
44  MACRO(long long) \
45  MACRO(unsigned short) \
46  MACRO(unsigned int) \
47  MACRO(unsigned long) \
48  MACRO(unsigned long long) \
49  MACRO(float) \
50  MACRO(double) \
51  MACRO(long double) \
52  MACRO(std::complex<float>) \
53  MACRO(std::complex<double>) \
54  MACRO(std::complex<long double>) \
55  MACRO(std::string) \
56  MACRO(std::vector<char>) \
57  MACRO(std::vector<short>) \
58  MACRO(std::vector<int>) \
59  MACRO(std::vector<long>) \
60  MACRO(std::vector<long long>) \
61  MACRO(std::vector<unsigned char>) \
62  MACRO(std::vector<unsigned short>) \
63  MACRO(std::vector<unsigned int>) \
64  MACRO(std::vector<unsigned long>) \
65  MACRO(std::vector<unsigned long long>) \
66  MACRO(std::vector<float>) \
67  MACRO(std::vector<double>) \
68  MACRO(std::vector<long double>) \
69  MACRO(std::vector<std::complex<float>>) \
70  MACRO(std::vector<std::complex<double>>) \
71  MACRO(std::vector<std::complex<long double>>) \
72  MACRO(std::vector<signed char>) \
73  MACRO(std::vector<std::string>) \
74  MACRO(openpmd_array_double_7) \
75  MACRO(bool)
76 
77 #define OPENPMD_FOREACH_NONVECTOR_DATATYPE(MACRO) \
78  MACRO(char) \
79  MACRO(unsigned char) \
80  MACRO(signed char) \
81  MACRO(short) \
82  MACRO(int) \
83  MACRO(long) \
84  MACRO(long long) \
85  MACRO(unsigned short) \
86  MACRO(unsigned int) \
87  MACRO(unsigned long) \
88  MACRO(unsigned long long) \
89  MACRO(float) \
90  MACRO(double) \
91  MACRO(long double) \
92  MACRO(std::complex<float>) \
93  MACRO(std::complex<double>) \
94  MACRO(std::complex<long double>) \
95  MACRO(std::string) \
96  MACRO(bool)
97 
98 #define OPENPMD_FOREACH_DATASET_DATATYPE(MACRO) \
99  MACRO(char) \
100  MACRO(unsigned char) \
101  MACRO(signed char) \
102  MACRO(short) \
103  MACRO(int) \
104  MACRO(long) \
105  MACRO(long long) \
106  MACRO(unsigned short) \
107  MACRO(unsigned int) \
108  MACRO(unsigned long) \
109  MACRO(unsigned long long) \
110  MACRO(float) \
111  MACRO(double) \
112  MACRO(long double) \
113  MACRO(std::complex<float>) \
114  MACRO(std::complex<double>) \
115  MACRO(std::complex<long double>)