matio-cpp  v0.2.5
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
ExogenousConversions.cpp
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 
9 
10 
12 {
13  return matioCpp::Element<matioCpp::Logical>(name, input);
14 }
15 
17 {
18  return matioCpp::String(name, input);
19 }
20 
22 {
23  return matioCpp::Vector<matioCpp::Logical>(name, input);
24 }
25 
27 {
28  matioCpp::CellArray stringsArray(name, {input.size(), 1});
29  for (size_t i = 0; i < input.size(); ++i)
30  {
31  stringsArray.setElement(i, make_variable("unused_name_" + std::to_string(i), input[i]));
32  }
33 
34  return stringsArray;
35 }
CellArray is a particular type of Variable specialized for cell arrays.
Definition: CellArray.h:18
bool setElement(const std::vector< index_type > &el, const Variable &newValue)
Set the element at the specified position.
Definition: CellArray.cpp:235
Element allows having a 1x1 variable (like double, int,..) castable to a primitive type.
Definition: Element.h:20
Vector is a particular type of Variable specialized for 1-D arrays of a generic type T.
Definition: Vector.h:23
Vector< char > String
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.
T size(T... args)
T to_string(T... args)