1 #ifndef MATIOCPP_VARIABLE_H
2 #define MATIOCPP_VARIABLE_H
67 if (realInputVector.
size() != imaginaryInputVector.
size())
69 std::string errorPrefix =
"[ERROR][matioCpp::Variable::createComplexVector] ";
72 std::cerr << errorPrefix <<
"The real and imaginary part have different size." <<
std::endl;
215 Variable(
const matvar_t * inputVar);
259 bool fromMatio(
const matvar_t * inputVar);
283 const matvar_t *
toMatio()
const;
CellArray is a particular type of Variable specialized for cell arrays.
Element allows having a 1x1 variable (like double, int,..) castable to a primitive type.
MultiDimensionalArray is a particular type of Variable specialized for multidimensional arrays of a g...
MATIOCPP_CONSTEXPR index_type size() const noexcept
MATIOCPP_CONSTEXPR pointer data() const noexcept
StructArray is a particular type of Variable specialized for array of structs.
Struct is a particular type of Variable specialized for structs.
The matioCpp::Variable class is the equivalent of matvar_t in matio.
bool setStructField(size_t index, const Variable &newValue, size_t structPositionInArray=0)
Set the field of the struct at the specified position.
matioCpp::String16 asString16()
Cast the variable as a String16.
Struct getStructArrayElement(size_t linearIndex)
Get an element of the variable, considered as a StructArray.
char *const * getStructFields() const
Get the list of fields in the variable, considered as a struct.
matioCpp::String32 asString32()
Cast the variable as a String32.
size_t getArrayNumberOfElements() const
Get the total number of elements in the array.
Variable & operator=(const Variable &other)
Copy assignement.
Variable()
Default constructor.
matioCpp::StructArray asStructArray()
Cast the variable as a StructArray.
bool setCellElement(size_t linearIndex, const Variable &newValue)
Set 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.
bool initializeComplexVector(const std::string &name, const Span< T > realInputVector, const Span< T > imaginaryInputVector)
Initialize a complex vector.
std::string name() const
Get the name of the Variable.
virtual bool checkCompatibility(const matvar_t *inputPtr, matioCpp::VariableType variableType, matioCpp::ValueType valueType) const
Check if an input matio pointer is compatible with the specified variable.
bool addStructField(const std::string &newField)
Add a new field to the variable, considered as a struct.
const matvar_t * toMatio() const
Convert this Variable to a matio variable.
size_t getStructFieldIndex(const std::string &field) const
Get the index of the specified field in the variable, considered as a struct.
matioCpp::MultiDimensionalArray< T > asMultiDimensionalArray()
Cast the variable as a MultiDimensionalArray.
bool changeName(const std::string &newName)
Change the name of the variable.
bool fromMatio(const matvar_t *inputVar)
Set this variable from an existing matio variable.
matioCpp::Span< const size_t > dimensions() const
Get the dimensions of this object.
bool isValid() const
Check if the variable is valid.
matioCpp::VariableType variableType() const
Get the VariableType.
matioCpp::Element< T > asElement()
Cast the variable as a Element.
bool fromOther(const Variable &other)
Set this variable from another variable.
bool initializeVariable(const std::string &name, const VariableType &variableType, const ValueType &valueType, matioCpp::Span< const size_t > dimensions, void *data)
Initialize the variable.
matioCpp::ValueType valueType() const
Get the ValueType.
Variable getCellElement(size_t linearIndex)
Get a cell element at a specified linear position.
Variable getStructField(size_t index, size_t structPositionInArray=0)
Get the specified field in the variable, considered as a struct.
bool isComplex() const
Get if the variable is complex.
matioCpp::Vector< T > asVector()
Cast the variable as a Vector.
matioCpp::CellArray asCellArray()
Cast the variable as a CellArray.
matioCpp::Struct asStruct()
Cast the variable as a Struct.
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.
matioCpp::String asString()
Cast the variable as a String.
Vector is a particular type of Variable specialized for 1-D arrays of a generic type T.
VariableType
Define the type of variable.
ValueType
The list of types for an element of a certain variable type.
Utility metafunction to get the ValueType from a given primitive type.