matio-cpp  v0.2.5
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
CellArray.h
Go to the documentation of this file.
1 #ifndef MATIOCPP_CELLARRAY_H
2 #define MATIOCPP_CELLARRAY_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 
12 #include <matioCpp/Variable.h>
13 
18 {
19 
27  virtual bool checkCompatibility(const matvar_t* inputPtr, matioCpp::VariableType variableType, matioCpp::ValueType valueType) const final;
28 
29 public:
30 
31  using index_type = size_t;
37  CellArray();
38 
43  CellArray(const std::string& name);
44 
51 
62 
66  CellArray(const CellArray& other);
67 
71  CellArray(CellArray&& other);
72 
77  CellArray(const MatvarHandler& handler);
78 
82  ~CellArray();
83 
90  CellArray& operator=(const CellArray& other);
91 
98  CellArray& operator=(CellArray&& other);
99 
109 
122 
130  bool indicesFromRawIndex(size_t rawIndex, std::vector<index_type>& el) const;
131 
137  bool setName(const std::string& newName);
138 
145  void resize(const std::vector<index_type>& newDimensions);
146 
150  void clear();
151 
157 
165  bool setElement(const std::vector<index_type>& el, const Variable& newValue);
166 
174  bool setElement(index_type el, const Variable& newValue);
175 
184 
192 
200 
206  const matioCpp::Variable operator()(index_type el) const;
207 
216 
224 
232 
238  const matioCpp::Variable operator[](index_type el) const;
239 };
240 
241 #endif // MATIOCPP_CELLARRAY_H
CellArray is a particular type of Variable specialized for cell arrays.
Definition: CellArray.h:18
matioCpp::Variable operator[](const std::vector< index_type > &el)
Access specified element.
Definition: CellArray.cpp:305
index_type rawIndexFromIndices(const std::vector< index_type > &el) const
Get the linear index corresponding to the provided indices.
Definition: CellArray.cpp:163
bool fromVectorOfVariables(const std::vector< index_type > &dimensions, std::vector< Variable > &elements)
Set from a vector of Variables.
Definition: CellArray.cpp:133
~CellArray()
Destructor.
Definition: CellArray.cpp:116
bool setElement(const std::vector< index_type > &el, const Variable &newValue)
Set the element at the specified position.
Definition: CellArray.cpp:235
index_type numberOfElements() const
Get the total number of elements in the array.
Definition: CellArray.cpp:230
matioCpp::Variable operator()(const std::vector< index_type > &el)
Access specified element.
Definition: CellArray.cpp:283
bool setName(const std::string &newName)
Change the name of the Variable.
Definition: CellArray.cpp:214
CellArray & operator=(const CellArray &other)
Assignement operator (copy) from another CellArray.
Definition: CellArray.cpp:121
CellArray()
The type used for indices.
Definition: CellArray.cpp:27
void clear()
Clear the cell array.
Definition: CellArray.cpp:225
bool indicesFromRawIndex(size_t rawIndex, std::vector< index_type > &el) const
Get the indices given the raw index.
Definition: CellArray.cpp:182
void resize(const std::vector< index_type > &newDimensions)
Resize the cell array.
Definition: CellArray.cpp:219
The matioCpp::Variable class is the equivalent of matvar_t in matio.
Definition: Variable.h:23
std::string name() const
Get the name of the Variable.
Definition: Variable.cpp:494
matioCpp::Span< const size_t > dimensions() const
Get the dimensions of this object.
Definition: Variable.cpp:528
matioCpp::VariableType variableType() const
Get the VariableType.
Definition: Variable.cpp:506
matioCpp::ValueType valueType() const
Get the ValueType.
Definition: Variable.cpp:511
VariableType
Define the type of variable.
ValueType
The list of types for an element of a certain variable type.