|
matio-cpp v0.3.0
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
|
Struct is a particular type of Variable specialized for structs. More...
#include <matioCpp/Struct.h>
Inheritance diagram for matioCpp::Struct:Public Types | |
| using | index_type = size_t |
Public Member Functions | |
| Struct () | |
| The type used for indices. | |
| Struct (const std::string &name) | |
| Constructor. | |
| Struct (const std::string &name, const std::vector< Variable > &elements) | |
| Constructor. | |
| Struct (const Struct &other) | |
| Copy constructor. | |
| Struct (Struct &&other) | |
| Move constructor. | |
| Struct (const MatvarHandler &handler) | |
| Constructor to share the data ownership of another variable. | |
| ~Struct () | |
| Destructor. | |
| Struct & | operator= (const Struct &other) |
| Assignement operator (copy) from another Struct. | |
| Struct & | operator= (Struct &&other) |
| Assignement operator (move) from another Struct. | |
| bool | fromVectorOfVariables (const std::vector< Variable > &elements) |
| Set from a vector of Variables. | |
| bool | setName (const std::string &newName) |
| Change the name of the Struct. | |
| index_type | numberOfFields () const |
| Get the total number of fields in the struct. | |
| std::vector< std::string > | fields () const |
| Get the list of fields. | |
| void | clear () |
| Clear the struct. | |
| bool | isFieldExisting (const std::string &field) const |
| Check if a field is existing It performs a linear search over the output of fields(). | |
| size_t | getFieldIndex (const std::string &field) const |
| Get the index of the specified field in the struct by performing a linear search. | |
| bool | setField (index_type index, const Variable &newValue) |
| Set the field at the specified position. | |
| bool | setField (const std::string &field, const Variable &newValue) |
| Set the given field to the newValue. | |
| bool | setField (const Variable &newValue) |
| Set the field given the newValue name. | |
| matioCpp::Variable | operator() (index_type el) |
| Access field at a specific index. | |
| const matioCpp::Variable | operator() (index_type el) const |
| Access field at a specific index. | |
| matioCpp::Variable | operator() (const std::string &el) |
| Access field at a specific index. | |
| const matioCpp::Variable | operator() (const std::string &el) const |
| Access field at a specific index. | |
| matioCpp::Variable | operator[] (index_type el) |
| Access field at a specific index. | |
| const matioCpp::Variable | operator[] (index_type el) const |
| Access field at a specific index. | |
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. | |
Friends | |
| class | 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. | |
| using matioCpp::Struct::index_type = size_t |
| matioCpp::Struct::Struct | ( | ) |
The type used for indices.
Default Constructor
Definition at line 29 of file Struct.cpp.
References matioCpp::Struct, and matioCpp::VARIABLE.
| matioCpp::Struct::Struct | ( | const std::string & | name | ) |
Constructor.
| name | The name of the Struct |
Definition at line 38 of file Struct.cpp.
References matioCpp::Struct, and matioCpp::VARIABLE.
| matioCpp::Struct::Struct | ( | const std::string & | name, |
| const std::vector< Variable > & | elements | ||
| ) |
Constructor.
| name | The name of the Struct |
| elements | The elements to be added to the Struct (they are copied) |
Definition at line 47 of file Struct.cpp.
References matioCpp::MultiDimensionalArray< T >::data(), std::endl(), matioCpp::MatvarHandler::GetMatvarDuplicate(), std::vector< T >::size(), matioCpp::Struct, and matioCpp::VARIABLE.
Copy constructor.
Definition at line 70 of file Struct.cpp.
| matioCpp::Struct::Struct | ( | matioCpp::Struct && | other | ) |
Move constructor.
Definition at line 75 of file Struct.cpp.
| matioCpp::Struct::Struct | ( | 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 80 of file Struct.cpp.
References matioCpp::Variable::initializeVariable(), matioCpp::Struct, matioCpp::Variable::valueType(), matioCpp::VARIABLE, and matioCpp::Variable::variableType().
| matioCpp::Struct::~Struct | ( | ) |
Destructor.
Definition at line 94 of file Struct.cpp.
| void matioCpp::Struct::clear | ( | ) |
| std::vector< std::string > matioCpp::Struct::fields | ( | ) | const |
| bool matioCpp::Struct::fromVectorOfVariables | ( | const std::vector< Variable > & | elements | ) |
Set from a vector of Variables.
| elements | The elements to be set. |
Definition at line 111 of file Struct.cpp.
References matioCpp::MultiDimensionalArray< T >::data(), std::endl(), matioCpp::MatvarHandler::GetMatvarDuplicate(), std::vector< T >::size(), matioCpp::Struct, and matioCpp::VARIABLE.
| size_t matioCpp::Struct::getFieldIndex | ( | const std::string & | field | ) | const |
Get the index of the specified field in the struct by performing a linear search.
| field | The field to search |
Definition at line 169 of file Struct.cpp.
| bool matioCpp::Struct::isFieldExisting | ( | const std::string & | field | ) | const |
Check if a field is existing It performs a linear search over the output of fields().
Definition at line 163 of file Struct.cpp.
| matioCpp::Struct::index_type matioCpp::Struct::numberOfFields | ( | ) | const |
Get the total number of fields in the struct.
Definition at line 136 of file Struct.cpp.
| matioCpp::Variable matioCpp::Struct::operator() | ( | const std::string & | el | ) |
Access field at a specific index.
| el | The name of the field to be accessed. |
Definition at line 204 of file Struct.cpp.
| const matioCpp::Variable matioCpp::Struct::operator() | ( | const std::string & | el | ) | const |
Access field at a specific index.
| el | The name of the field to be accessed. |
Definition at line 211 of file Struct.cpp.
| matioCpp::Variable matioCpp::Struct::operator() | ( | index_type | el | ) |
Access field at a specific index.
| el | The index of the field to be accessed. |
Definition at line 192 of file Struct.cpp.
| const matioCpp::Variable matioCpp::Struct::operator() | ( | index_type | el | ) | const |
Access field at a specific index.
| el | The index of the field to be accessed. |
Definition at line 198 of file Struct.cpp.
| matioCpp::Struct & matioCpp::Struct::operator= | ( | const Struct & | other | ) |
Assignement operator (copy) from another Struct.
| other | The other Struct. |
Definition at line 99 of file Struct.cpp.
| matioCpp::Struct & matioCpp::Struct::operator= | ( | matioCpp::Struct && | other | ) |
Assignement operator (move) from another Struct.
| other | The other Struct. |
Definition at line 105 of file Struct.cpp.
| matioCpp::Variable matioCpp::Struct::operator[] | ( | index_type | el | ) |
Access field at a specific index.
| el | The index of the field to be accessed. |
Definition at line 218 of file Struct.cpp.
| const matioCpp::Variable matioCpp::Struct::operator[] | ( | index_type | el | ) | const |
Access field at a specific index.
| el | The index of the field to be accessed. |
Definition at line 224 of file Struct.cpp.
| bool matioCpp::Struct::setField | ( | const std::string & | field, |
| const Variable & | newValue | ||
| ) |
Set the given field to the newValue.
| field | The name of the field to set |
| newValue | The Variable that will be copied in the specified field |
Definition at line 182 of file Struct.cpp.
Set the field given the newValue name.
| newValue | The Variable that will be copied in the specified field |
Definition at line 187 of file Struct.cpp.
References matioCpp::Variable::name().
| bool matioCpp::Struct::setField | ( | index_type | index, |
| const Variable & | newValue | ||
| ) |
Set the field at the specified position.
| index | The linear index of the specified field |
| newValue | The Variable that will be copied in the specified location |
Definition at line 176 of file Struct.cpp.
| bool matioCpp::Struct::setName | ( | const std::string & | newName | ) |
Change the name of the Struct.
| newName | The new name |
Definition at line 131 of file Struct.cpp.
|
friend |