|
matio-cpp v0.3.0
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
|
CellArray is a particular type of Variable specialized for cell arrays. More...
#include <matioCpp/CellArray.h>
Inheritance diagram for matioCpp::CellArray:Public Types | |
| using | index_type = size_t |
Public Member Functions | |
| CellArray () | |
| The type used for indices. | |
| CellArray (const std::string &name) | |
| Constructor. | |
| CellArray (const std::string &name, const std::vector< index_type > &dimensions) | |
| Constructor. | |
| CellArray (const std::string &name, const std::vector< index_type > &dimensions, std::vector< Variable > &elements) | |
| Constructor. | |
| CellArray (const CellArray &other) | |
| Copy constructor. | |
| CellArray (CellArray &&other) | |
| Move constructor. | |
| CellArray (const MatvarHandler &handler) | |
| Constructor to share the data ownership of another variable. | |
| ~CellArray () | |
| Destructor. | |
| CellArray & | operator= (const CellArray &other) |
| Assignement operator (copy) from another CellArray. | |
| CellArray & | operator= (CellArray &&other) |
| Assignement operator (move) from another CellArray. | |
| bool | fromVectorOfVariables (const std::vector< index_type > &dimensions, std::vector< Variable > &elements) |
| Set from a vector of Variables. | |
| index_type | rawIndexFromIndices (const std::vector< index_type > &el) const |
| Get the linear index corresponding to the provided indices. | |
| bool | indicesFromRawIndex (size_t rawIndex, std::vector< index_type > &el) const |
| Get the indices given the raw index. | |
| bool | setName (const std::string &newName) |
| Change the name of the Variable. | |
| void | resize (const std::vector< index_type > &newDimensions) |
| Resize the cell array. | |
| void | clear () |
| Clear the cell array. | |
| index_type | numberOfElements () const |
| Get the total number of elements in the array. | |
| bool | setElement (const std::vector< index_type > &el, const Variable &newValue) |
| Set the element at the specified position. | |
| bool | setElement (index_type el, const Variable &newValue) |
| Set the element at the specified position. | |
| matioCpp::Variable | operator() (const std::vector< index_type > &el) |
| Access specified element. | |
| const matioCpp::Variable | operator() (const std::vector< index_type > &el) const |
| Access specified element. | |
| matioCpp::Variable | operator() (index_type el) |
| Access specified element. | |
| const matioCpp::Variable | operator() (index_type el) const |
| Access specified element. | |
| matioCpp::Variable | operator[] (const std::vector< index_type > &el) |
| Access specified element. | |
| const matioCpp::Variable | operator[] (const std::vector< index_type > &el) const |
| Access specified element. | |
| matioCpp::Variable | operator[] (index_type el) |
| Access specified element. | |
| const matioCpp::Variable | operator[] (index_type el) const |
| Access specified element. | |
Public Member Functions inherited from matioCpp::Variable | |
| Variable () | |
| Default constructor. | |
| Variable (const matvar_t *inputVar) | |
| Constructor from an existing matvar_t pointer. | |
| Variable (const Variable &other) | |
| Copy constructor. | |
| Variable (Variable &&other) | |
| Move constructor. | |
| Variable (const MatvarHandler &handler) | |
| Constructor to share the data ownership of another variable. | |
| ~Variable () | |
| Destructor. | |
| Variable & | operator= (const Variable &other) |
| Copy assignement. | |
| Variable & | operator= (Variable &&other) |
| Move assignement. | |
| bool | fromMatio (const matvar_t *inputVar) |
| Set this variable from an existing matio variable. | |
| bool | fromOther (const Variable &other) |
| Set this variable from another variable. | |
| bool | fromOther (Variable &&other) |
| Set this variable from another variable. | |
| const matvar_t * | toMatio () const |
| Convert this Variable to a matio variable. | |
| matvar_t * | toMatio () |
| Convert this Variable to a matio variable. | |
| std::string | name () const |
| Get the name of the Variable. | |
| matioCpp::VariableType | variableType () const |
| Get the VariableType. | |
| matioCpp::ValueType | valueType () const |
| Get the ValueType. | |
| bool | isComplex () const |
| Get if the variable is complex. | |
| matioCpp::Span< const size_t > | dimensions () const |
| Get the dimensions of this object. | |
| bool | isValid () const |
| Check if the variable is valid. | |
| matioCpp::Variable | operator[] (const std::string &el) |
| Access field with specific name. | |
| const matioCpp::Variable | operator[] (const std::string &el) const |
| Access field with specific name. | |
| template<typename T > | |
| matioCpp::Element< T > | asElement () |
| Cast the variable as a Element. | |
| template<typename T > | |
| const matioCpp::Element< T > | asElement () const |
| Cast the variable as a const Element. | |
| template<typename T > | |
| matioCpp::Vector< T > | asVector () |
| Cast the variable as a Vector. | |
| template<typename T > | |
| const matioCpp::Vector< T > | asVector () const |
| Cast the variable as a const Vector. | |
| matioCpp::String | asString () |
| Cast the variable as a String. | |
| const matioCpp::String | asString () const |
| Cast the variable as a const String. | |
| matioCpp::String16 | asString16 () |
| Cast the variable as a String16. | |
| const matioCpp::String16 | asString16 () const |
| Cast the variable as a const String16. | |
| matioCpp::String32 | asString32 () |
| Cast the variable as a String32. | |
| const matioCpp::String32 | asString32 () const |
| Cast the variable as a const String32. | |
| template<typename T > | |
| matioCpp::MultiDimensionalArray< T > | asMultiDimensionalArray () |
| Cast the variable as a MultiDimensionalArray. | |
| template<typename T > | |
| const matioCpp::MultiDimensionalArray< T > | asMultiDimensionalArray () const |
| Cast the variable as a const MultiDimensionalArray. | |
| matioCpp::CellArray | asCellArray () |
| Cast the variable as a CellArray. | |
| const matioCpp::CellArray | asCellArray () const |
| Cast the variable as a const CellArray. | |
| matioCpp::Struct | asStruct () |
| Cast the variable as a Struct. | |
| const matioCpp::Struct | asStruct () const |
| Cast the variable as a const Struct. | |
| matioCpp::StructArray | asStructArray () |
| Cast the variable as a StructArray. | |
| const matioCpp::StructArray | asStructArray () const |
| Cast the variable as a const StructArray. | |
Additional Inherited Members | |
Protected Member Functions inherited from matioCpp::Variable | |
| bool | initializeVariable (const std::string &name, const VariableType &variableType, const ValueType &valueType, matioCpp::Span< const size_t > dimensions, void *data) |
| Initialize the variable. | |
| bool | initializeComplexVariable (const std::string &name, const VariableType &variableType, const ValueType &valueType, matioCpp::Span< const size_t > dimensions, void *realData, void *imaginaryData) |
| Initialize a complex variable. | |
| template<typename T > | |
| bool | initializeComplexVector (const std::string &name, const Span< T > realInputVector, const Span< T > imaginaryInputVector) |
| Initialize a complex vector. | |
| bool | changeName (const std::string &newName) |
| Change the name of the variable. | |
| size_t | getArrayNumberOfElements () const |
| Get the total number of elements in the array. | |
| bool | setCellElement (size_t linearIndex, const Variable &newValue) |
| Set a cell element at a specified linear position. | |
| Variable | getCellElement (size_t linearIndex) |
| Get a cell element at a specified linear position. | |
| const Variable | getCellElement (size_t linearIndex) const |
| Get a cell element at a specified linear position. | |
| size_t | getStructNumberOfFields () const |
| Get the total number of fields in the variable, considered as a struct. | |
| char *const * | getStructFields () const |
| Get the list of fields in the variable, considered as a struct. | |
| bool | getStructFieldIndex (const std::string &field, size_t &index) const |
| Get the index of the specified field in the variable, considered as a struct. | |
| bool | setStructField (size_t index, const Variable &newValue, size_t structPositionInArray=0) |
| Set the field of the struct at the specified position. | |
| bool | addStructField (const std::string &newField) |
| Add a new field to the variable, considered as a struct. | |
| bool | setStructField (const std::string &field, const Variable &newValue, size_t structPositionInArray=0) |
| Set the field of the struct given the newValue name. | |
| Variable | getStructField (size_t index, size_t structPositionInArray=0) |
| Get the specified field in the variable, considered as a struct. | |
| const Variable | getStructField (size_t index, size_t structPositionInArray=0) const |
| Get the specified field in the variable, considered as a struct. | |
| Struct | getStructArrayElement (size_t linearIndex) |
| Get an element of the variable, considered as a StructArray. | |
| const Struct | getStructArrayElement (size_t linearIndex) const |
| Get an element of the variable, considered as a StructArray. | |
CellArray is a particular type of Variable specialized for cell arrays.
Definition at line 17 of file CellArray.h.
| using matioCpp::CellArray::index_type = size_t |
Definition at line 31 of file CellArray.h.
| matioCpp::CellArray::CellArray | ( | ) |
The type used for indices.
Default Constructor
Definition at line 27 of file CellArray.cpp.
References matioCpp::CellArray, and matioCpp::VARIABLE.
| matioCpp::CellArray::CellArray | ( | const std::string & | name | ) |
Constructor.
| name | The name of the CellArray |
Definition at line 36 of file CellArray.cpp.
References matioCpp::CellArray, and matioCpp::VARIABLE.
| matioCpp::CellArray::CellArray | ( | const std::string & | name, |
| const std::vector< index_type > & | dimensions | ||
| ) |
Constructor.
Definition at line 45 of file CellArray.cpp.
References matioCpp::CellArray, std::endl(), and matioCpp::VARIABLE.
| matioCpp::CellArray::CellArray | ( | const std::string & | name, |
| const std::vector< index_type > & | dimensions, | ||
| std::vector< Variable > & | elements | ||
| ) |
Constructor.
| name | The name of the CellArray |
| dimensions | The dimensions of the CellArray |
| elements | The elements to be added to the CellArray (they are copied) |
Definition at line 62 of file CellArray.cpp.
References matioCpp::CellArray, matioCpp::MultiDimensionalArray< T >::data(), std::endl(), matioCpp::MatvarHandler::GetMatvarDuplicate(), std::vector< T >::size(), and matioCpp::VARIABLE.
Copy constructor.
Definition at line 92 of file CellArray.cpp.
| matioCpp::CellArray::CellArray | ( | CellArray && | other | ) |
Move constructor.
Definition at line 97 of file CellArray.cpp.
| matioCpp::CellArray::CellArray | ( | const MatvarHandler & | handler | ) |
Constructor to share the data ownership of another variable.
| handler | The MatvarHandler handler to the matvar_t which has to be shared. |
Definition at line 102 of file CellArray.cpp.
References matioCpp::CellArray, matioCpp::Variable::initializeVariable(), matioCpp::Variable::valueType(), matioCpp::VARIABLE, and matioCpp::Variable::variableType().
| matioCpp::CellArray::~CellArray | ( | ) |
Destructor.
Definition at line 116 of file CellArray.cpp.
| void matioCpp::CellArray::clear | ( | ) |
| bool matioCpp::CellArray::fromVectorOfVariables | ( | const std::vector< index_type > & | dimensions, |
| std::vector< Variable > & | elements | ||
| ) |
Set from a vector of Variables.
| dimensions | The input dimensions |
| elements | The input vector of variables. |
Definition at line 133 of file CellArray.cpp.
References matioCpp::CellArray, matioCpp::MultiDimensionalArray< T >::data(), std::endl(), matioCpp::MatvarHandler::GetMatvarDuplicate(), std::vector< T >::size(), and matioCpp::VARIABLE.
| bool matioCpp::CellArray::indicesFromRawIndex | ( | size_t | rawIndex, |
| std::vector< index_type > & | el | ||
| ) | const |
Get the indices given the raw index.
| rawIndex | The input raw index from which to compute the indices |
| el | The output indices |
Definition at line 182 of file CellArray.cpp.
References std::endl(), and matioCpp::MultiDimensionalArray< T >::resize().
| matioCpp::CellArray::index_type matioCpp::CellArray::numberOfElements | ( | ) | const |
Get the total number of elements in the array.
Definition at line 230 of file CellArray.cpp.
| matioCpp::Variable matioCpp::CellArray::operator() | ( | const std::vector< index_type > & | el | ) |
Access specified element.
| el | The element to be accessed. |
Definition at line 283 of file CellArray.cpp.
| const matioCpp::Variable matioCpp::CellArray::operator() | ( | const std::vector< index_type > & | el | ) | const |
Access specified element.
| el | The element to be accessed. |
Definition at line 288 of file CellArray.cpp.
| matioCpp::Variable matioCpp::CellArray::operator() | ( | index_type | el | ) |
Access specified element.
| el | The element to be accessed (raw index). |
Definition at line 293 of file CellArray.cpp.
| const matioCpp::Variable matioCpp::CellArray::operator() | ( | index_type | el | ) | const |
Access specified element.
| el | The element to be accessed (raw index). |
Definition at line 299 of file CellArray.cpp.
| matioCpp::CellArray & matioCpp::CellArray::operator= | ( | matioCpp::CellArray && | other | ) |
Assignement operator (move) from another CellArray.
| other | The other CellArray. |
Definition at line 127 of file CellArray.cpp.
| matioCpp::CellArray & matioCpp::CellArray::operator= | ( | const CellArray & | other | ) |
Assignement operator (copy) from another CellArray.
| other | The other CellArray. |
Definition at line 121 of file CellArray.cpp.
| matioCpp::Variable matioCpp::CellArray::operator[] | ( | const std::vector< index_type > & | el | ) |
Access specified element.
| el | The element to be accessed. |
Definition at line 305 of file CellArray.cpp.
| const matioCpp::Variable matioCpp::CellArray::operator[] | ( | const std::vector< index_type > & | el | ) | const |
Access specified element.
| el | The element to be accessed. |
Definition at line 310 of file CellArray.cpp.
| matioCpp::Variable matioCpp::CellArray::operator[] | ( | index_type | el | ) |
Access specified element.
| el | The element to be accessed. |
Definition at line 315 of file CellArray.cpp.
| const matioCpp::Variable matioCpp::CellArray::operator[] | ( | index_type | el | ) | const |
Access specified element.
| el | The element to be accessed. |
Definition at line 321 of file CellArray.cpp.
| matioCpp::CellArray::index_type matioCpp::CellArray::rawIndexFromIndices | ( | const std::vector< index_type > & | el | ) | const |
Get the linear index corresponding to the provided indices.
| el | The desired element |
Since the variables are stored internally in column-major, an element (i,j,k,l,..) of an array of dimensions (n,m,p,k,...) corresponds to a row index equal to i + j*n + k*n*m + l*n*m*p +...
Definition at line 163 of file CellArray.cpp.
| void matioCpp::CellArray::resize | ( | const std::vector< index_type > & | newDimensions | ) |
Resize the cell array.
| newDimensions | The new dimensions. |
Definition at line 219 of file CellArray.cpp.
References std::move().
| bool matioCpp::CellArray::setElement | ( | const std::vector< index_type > & | el, |
| const Variable & | newValue | ||
| ) |
Set the element at the specified position.
| el | The indices of the specified element |
| newValue | The Variable that will be copied in the specified location |
Definition at line 235 of file CellArray.cpp.
References std::endl(), and matioCpp::Variable::isValid().
| bool matioCpp::CellArray::setElement | ( | index_type | el, |
| const Variable & | newValue | ||
| ) |
Set the element at the specified position.
| el | The raw index of the specified element |
| newValue | The Variable that will be copied in the specified location |
Definition at line 258 of file CellArray.cpp.
References std::endl(), and matioCpp::Variable::isValid().
| bool matioCpp::CellArray::setName | ( | const std::string & | newName | ) |
Change the name of the Variable.
| newName | The new name |
Definition at line 214 of file CellArray.cpp.