|
class MatVar
MatVar is an RAII-style wrapper around a matvar_t* that optionally owns the underlying resource and frees it on destruction. It provides convenient accessors for variable metadata (name, type, dimensions), total element counts, and struct field introspection and retrieval.
operator matvar_t *()
Returns the underlying matvar_t*, allowing interoperation with MatIO functions.
const char *GetName()
Returns the variable’s name; this method throws if the variable has not been created.
enum matio_classes GetType()
Returns the MatIO class type (such as MAT_C_DOUBLE or MAT_C_STRUCT); this method throws if the variable is not valid.
int GetDimCount() const
Returns the number of dimensions (rank) of the variable; this method throws if the variable is not valid.
int GetDimCount(int dim) const
Returns the size of the specified dimension; this method throws if the variable is not valid.
const char *GetTypeString()
Returns a human-readable description of the MatIO class type; this method throws if the variable is not valid.
int GetCount()
Returns the total number of elements, computed as the product of all dimensions; this method throws if the variable is not valid.
int GetFieldCount()
Returns the number of fields in a struct; this method throws if the variable is not valid or not a struct.
const char *GetFieldName(int id)
Returns the name of a struct field by index; this method throws if the variable is not valid or not a struct.
bool IsLoaded()
Returns true if the wrapper currently holds a non-null variable pointer.
bool IsStruct()
Returns true if the variable’s class type indicates a MATLAB struct.
MatVar GetStructVar(const char *field_name)
Returns a wrapper for the named struct field without taking ownership of the returned matvar_t*.
bool ExistStructVar(const char *field_name)
Returns true if the variable field_name exists.
MatVar()
Constructs an empty wrapper that does not reference any variable
MatVar(matvar_t *var_, bool del_ = true)
Wraps an existing variable pointer and optionally assumes ownership for freeing it.
~MatVar()
Frees the underlying matvar_t if the wrapper owns it .
|