matio-cpp  v0.2.5
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
ForwardDeclarations.h
Go to the documentation of this file.
1 #ifndef MATIOCPP_FORWARDDECLARATIONS_H
2 #define MATIOCPP_FORWARDDECLARATIONS_H
3 
4 /*
5  * Copyright (C) 2020 Fondazione Istituto Italiano di Tecnologia
6  *
7  * This software may be modified and distributed under the terms of the
8  * BSD-2-Clause license (https://opensource.org/licenses/BSD-2-Clause).
9  */
10 #include <algorithm> // for lexicographical_compare
11 #include <array> // for array
12 #include <cassert>
13 #include <cctype> // for isalpha, isalnum
14 #include <complex>
15 #include <cstddef> // for ptrdiff_t, size_t, nullptr_t
16 #include <cstdio> //for remove
17 #include <cstring> //for memcpy
18 #include <initializer_list>
19 #include <iostream>
20 #include <iterator> // for reverse_iterator, distance, random_access_...
21 #include <limits>
22 #include <memory>
23 #include <stdexcept>
24 #include <string>
25 #include <type_traits> // for enable_if_t, declval, is_convertible, inte...
26 #include <unordered_map>
27 #include <unordered_set>
28 #include <utility>
29 #include <vector>
30 
31 #include <matio.h>
32 
33 #include <matioCpp/Config.h>
34 
35 #ifdef _MSC_VER
36 #pragma warning(push)
37 
38 // turn off some warnings that are noisy about our Expects statements
39 #pragma warning(disable : 4127) // conditional expression is constant
40 #pragma warning(disable : 4702) // unreachable code
41 
42 // blanket turn off warnings from CppCoreCheck for now
43 // so people aren't annoyed by them when running the tool.
44 #pragma warning(disable : 26481 26482 26483 26485 26490 26491 26492 26493 26495)
45 
46 #if _MSC_VER < 1910
47 #pragma push_macro("constexpr")
48 #define constexpr /*constexpr*/
49 #define MATIOCPP_USE_STATIC_CONSTEXPR_WORKAROUND
50 
51 #endif // _MSC_VER < 1910
52 #else // _MSC_VER
53 
54 // See if we have enough C++17 power to use a static constexpr data member
55 // without needing an out-of-line definition
56 #if !(defined(__cplusplus) && (__cplusplus >= 201703L))
57 #define MATIOCPP_USE_STATIC_CONSTEXPR_WORKAROUND
58 #endif // !(defined(__cplusplus) && (__cplusplus >= 201703L))
59 
60 #endif // _MSC_VER
61 
62 // constexpr workaround for SWIG
63 #ifdef SWIG
64 #define MATIOCPP_CONSTEXPR
65 #else
66 #define MATIOCPP_CONSTEXPR constexpr
67 #endif
68 
69 namespace matioCpp
70 {
71 
76 template <class T> struct dependent_false : std::false_type
77 {
78 };
79 
83 template <typename... Args> inline void unused(Args&&...) {}
84 
88 enum class VariableType
89 {
90  Element,
91  Vector,
93  Struct,
94  CellArray,
97 };
98 
102 enum class ValueType
103 {
104  INT8,
105  UINT8,
106  INT16,
107  UINT16,
108  INT32,
109  UINT32,
110  SINGLE,
111  DOUBLE,
112  INT64,
113  UINT64,
114  UTF8,
115  UTF16,
116  UTF32,
117  STRING,
118  LOGICAL,
119  VARIABLE, //This is the case of composite containers, like Struct, CellArray, and Container
121 };
122 
126 enum class FileMode
127 {
128  ReadOnly,
130 };
131 
135 enum class FileVersion
136 {
137  Default,
138  MAT4,
139  MAT5,
140  MAT7_3,
141  Undefined
142 };
143 
147 enum class Compression
148 {
149  None,
150  zlib
151 };
152 
156 enum class DeleteMode
157 {
158  DoNotDelete,
159  ShallowDelete,
160  Delete
161 };
162 
166 class Logical {
167 private:
168  Logical() {}; //Logical is meant to be used only as type.
169 };
170 
171 // [views.constants], constants
173 
174 template <class Container, bool IsConst>
175 class vector_iterator;
176 
177 template <class ElementType, std::ptrdiff_t Extent = dynamic_extent>
178 class Span;
179 
180 class MatvarHandler;
181 
182 class SharedMatvar;
183 
184 class WeakMatvar;
185 
186 class Variable;
187 
188 template<typename T>
189 class Element;
190 
191 template<typename T>
192 class Vector;
193 
195 
197 
199 
200 template<typename T>
202 
203 class CellArray;
204 
205 class File;
206 
207 class Struct;
208 
209 class StructArray;
210 
211 template <bool isConst>
212 class StructArrayElement;
213 
214 }
215 
216 #endif // MATIOCPP_FORWARDDECLARATIONS_H
#define MATIOCPP_CONSTEXPR
CellArray is a particular type of Variable specialized for cell arrays.
Definition: CellArray.h:18
Element allows having a 1x1 variable (like double, int,..) castable to a primitive type.
Definition: Element.h:20
Utility class to consider logical values.
MultiDimensionalArray is a particular type of Variable specialized for multidimensional arrays of a g...
StructArray is a particular type of Variable specialized for array of structs.
Definition: StructArray.h:21
Struct is a particular type of Variable specialized for structs.
Definition: Struct.h:18
The matioCpp::Variable class is the equivalent of matvar_t in matio.
Definition: Variable.h:23
Vector is a particular type of Variable specialized for 1-D arrays of a generic type T.
Definition: Vector.h:23
MATIOCPP_CONSTEXPR const std::ptrdiff_t dynamic_extent
DeleteMode
The delete mode of matvar_t pointers.
@ ShallowDelete
The handler does not delete the pointer.
@ Delete
The handler deletes the pointer but not the data.
FileVersion
The supported file versions.
@ MAT4
This is one of the following three depending on the matio installation.
@ MAT5
Matlab version 4 file
@ MAT7_3
Matlab version 5 file
@ Undefined
Matlab version 7.3 file
FileMode
The available modes with which a file can be opened.
void unused(Args &&...)
Utility metafunction to avoid compiler warnings about unused variables.
VariableType
Define the type of variable.
ValueType
The list of types for an element of a certain variable type.
Compression
Compression type when writing to a file.
@ zlib
No compression.
dependent_false is a type-dependent expression that is always false.