matio-cpp  v0.2.5
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
ExogenousConversions.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Fondazione Istituto Italiano di Tecnologia
3  *
4  * This software may be modified and distributed under the terms of the
5  * BSD-2-Clause license (https://opensource.org/licenses/BSD-2-Clause).
6  */
7 #ifndef MATIOCPP_EXOGENOUSCONVERSION_H
8 #define MATIOCPP_EXOGENOUSCONVERSION_H
9 
12 #include <matioCpp/Element.h>
13 #include <matioCpp/Struct.h>
14 #include <matioCpp/CellArray.h>
15 #include <matioCpp/Span.h>
16 #include <matioCpp/Vector.h>
18 
19 #include <visit_struct/visit_struct_intrusive.hpp>
20 
22 
23 namespace matioCpp
24 {
25 
32 template <class Vector, typename = typename std::enable_if_t<is_vector_compatible<Vector>::value &&
35 
42 matioCpp::String make_variable(const std::string& name, const std::string& input);
43 
51 
58 template<typename type, typename = typename std::enable_if<std::is_fundamental<type>::value && !std::is_same<type, bool>::value>::type>
59 inline matioCpp::Element<type> make_variable(const std::string& name, const type& input);
60 
68 
76 
84 template<typename Struct, typename = typename std::enable_if_t<visit_struct::traits::is_visitable<Struct>::value>>
85 inline matioCpp::Struct make_variable(const std::string& name, const Struct& input);
86 
96 template<class iterator,
97  typename = typename std::enable_if_t<is_pair_iterator_string<iterator>::value>>
98 inline matioCpp::Struct make_struct(const std::string& name, iterator begin, iterator end);
99 
109 template<class iterator,
110  typename std::enable_if_t<is_pair_iterator_string<iterator>::value>* = nullptr>
111 inline matioCpp::CellArray make_cell_array(const std::string& name, const iterator& begin, const iterator& end);
112 
122 template<class iterator,
123  typename std::enable_if_t<!is_pair<decltype(*std::declval<iterator>())>::value>* = nullptr>
124 inline matioCpp::CellArray make_cell_array(const std::string& name, const iterator& begin, const iterator& end);
125 
129 template <typename Class, typename = void>
131 {};
132 
133 template <typename Class>
135 {
136 };
137 
141 template <typename Class>
143 {
144  using type = typename std::conditional_t<matioCpp::is_make_variable_callable<Class>::value, decltype(matioCpp::make_variable(std::declval<std::string>(), std::declval<Class>())), void>;
145 };
146 
147 }
148 
150 
151 #endif // MATIOCPP_EXOGENOUSCONVERSION_H
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
Struct is a particular type of Variable specialized for structs.
Definition: Struct.h:18
Vector is a particular type of Variable specialized for 1-D arrays of a generic type T.
Definition: Vector.h:23
matioCpp::Struct make_struct(const std::string &name, iterator begin, iterator end)
Create a matioCpp::Struct starting from the begin and end iterators of a map-like container The deref...
matioCpp::CellArray make_cell_array(const std::string &name, const iterator &begin, const iterator &end)
Create a matioCpp::CellArray starting from the begin and end iterators of a container.
matioCpp::Vector< typename std::remove_cv_t< typename matioCpp::SpanUtils::container_data< Vector >::type > > make_variable(const std::string &name, const Vector &input)
Conversion from a generic vector to a matioCpp::Vector.
is_make_variable_callable is a template utility to check if the make_variable works for a give type
make_variable_output is a template utility to check the type that make_variable would output.
typename std::conditional_t< matioCpp::is_make_variable_callable< Class >::value, decltype(matioCpp::make_variable(std::declval< std::string >(), std::declval< Class >())), void > type