matio-cpp
v0.2.5
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
|
Namespaces | |
details | |
SpanUtils | |
Data Structures | |
class | CellArray |
CellArray is a particular type of Variable specialized for cell arrays. More... | |
struct | get_type |
Utility metafunction to get the ValueType from a given primitive type. More... | |
struct | get_type< int8_t > |
struct | get_type< uint8_t > |
struct | get_type< int16_t > |
struct | get_type< uint16_t > |
struct | get_type< int32_t > |
struct | get_type< uint32_t > |
struct | get_type< float > |
struct | get_type< double > |
struct | get_type< int64_t > |
struct | get_type< size_t_type > |
struct | get_type< char > |
struct | get_type< char16_t > |
struct | get_type< char32_t > |
struct | get_type< Logical > |
struct | is_string_compatible |
Utility meta-function to check if a type is compatible with a std::string. More... | |
struct | is_string_compatible< char > |
struct | is_string_compatible< uint8_t > |
struct | is_string16_compatible |
Utility meta-function to check if a type is compatible with a std::u16string. More... | |
struct | is_string16_compatible< char16_t > |
struct | is_string16_compatible< uint16_t > |
struct | is_string32_compatible |
Utility meta-function to check if a type is compatible with a std::u32string. More... | |
struct | is_string32_compatible< char32_t > |
struct | is_string32_compatible< uint32_t > |
class | Element |
Element allows having a 1x1 variable (like double, int,..) castable to a primitive type. More... | |
struct | is_make_variable_callable |
is_make_variable_callable is a template utility to check if the make_variable works for a give type More... | |
struct | is_make_variable_callable< Class, matioCpp::SpanUtils::void_t< decltype(matioCpp::make_variable(std::declval< std::string >(), std::declval< Class >()))> > |
struct | make_variable_output |
make_variable_output is a template utility to check the type that make_variable would output. More... | |
class | File |
struct | dependent_false |
dependent_false is a type-dependent expression that is always false. More... | |
class | Logical |
Utility class to consider logical values. More... | |
class | vector_iterator |
class | Span |
class | Vector |
Vector is a particular type of Variable specialized for 1-D arrays of a generic type T. More... | |
class | MultiDimensionalArray |
MultiDimensionalArray is a particular type of Variable specialized for multidimensional arrays of a generic type T. More... | |
class | StructArrayElement |
struct | is_eigen_matrix |
is_eigen_matrix is a template metafunction to check if T is an Eigen matrix. More... | |
struct | is_vector_compatible |
is_vector_compatible is a utility metafunction to check if the input vector T is compatible with matioCpp More... | |
class | MatvarHandler |
class | SharedMatvar |
class | Struct |
Struct is a particular type of Variable specialized for structs. More... | |
class | StructArray |
StructArray is a particular type of Variable specialized for array of structs. More... | |
class | Variable |
The matioCpp::Variable class is the equivalent of matvar_t in matio. More... | |
class | WeakMatvar |
Typedefs | |
using | size_t_type = uint64_t |
using | String = Vector< char > |
using | String16 = Vector< char16_t > |
using | String32 = Vector< char32_t > |
Enumerations | |
enum class | VariableType { Element , Vector , MultiDimensionalArray , Struct , CellArray , StructArray , Unsupported } |
Define the type of variable. More... | |
enum class | ValueType { INT8 , UINT8 , INT16 , UINT16 , INT32 , UINT32 , SINGLE , DOUBLE , INT64 , UINT64 , UTF8 , UTF16 , UTF32 , STRING , LOGICAL , VARIABLE , UNSUPPORTED } |
The list of types for an element of a certain variable type. More... | |
enum class | FileMode { ReadOnly , ReadAndWrite } |
The available modes with which a file can be opened. More... | |
enum class | FileVersion { Default , MAT4 , MAT5 , MAT7_3 , Undefined } |
The supported file versions. More... | |
enum class | Compression { None , zlib } |
Compression type when writing to a file. More... | |
enum class | DeleteMode { DoNotDelete , ShallowDelete , Delete } |
The delete mode of matvar_t pointers. More... | |
Functions | |
bool | get_matio_types (const VariableType &inputVariableType, const ValueType &inputValueType, matio_classes &outputMatioClasses, matio_types &outputMatioType) |
Get both the matio type and class from the input VariableType and ValueType. More... | |
bool | get_types_from_matvart (const matvar_t *input, VariableType &outputVariableType, ValueType &outputValueType) |
Get the VariableType and the ValueType from a matvar_t pointer. More... | |
bool | get_types_names_from_matvart (const matvar_t *input, std::string &classType, std::string &dataType) |
Get the type names from the input pointer. More... | |
template<typename T > | |
bool | is_convertible_to_primitive_type (matioCpp::ValueType type) |
Utility function to check if certain ValueType can be converted to a primitive type T. More... | |
template<class Vector , typename = typename std::enable_if_t<is_vector_compatible<Vector>::value && !std::is_same<Vector, std::string>::value>> | |
matioCpp::Vector< typename std::remove_cv_t< typename matioCpp::SpanUtils::container_data< Vector >::type > > | make_variable (const std::string &name, const Vector &input) |
Conversion from a generic vector to a matioCpp::Vector. More... | |
matioCpp::String | make_variable (const std::string &name, const std::string &input) |
Conversion from a std::string to a matioCpp::String. More... | |
matioCpp::Vector< matioCpp::Logical > | make_variable (const std::string &name, const std::vector< bool > &input) |
Conversion from a boolean vector to a matioCpp::Vector<matioCpp::Logical> More... | |
template<typename type , typename = typename std::enable_if<std::is_fundamental<type>::value && !std::is_same<type, bool>::value>::type> | |
matioCpp::Element< type > | make_variable (const std::string &name, const type &input) |
Conversion from a fundamental type to the corresponding matioCpp::Element. More... | |
matioCpp::Element< matioCpp::Logical > | make_variable (const std::string &name, bool input) |
Conversion from a boolean to a matioCpp::Element<matioCpp::Logical> More... | |
matioCpp::CellArray | make_variable (const std::string &name, const std::vector< std::string > &input) |
Conversion from a vector of strings to a matioCpp::CellArray containing the input strings. More... | |
template<typename Struct , typename = typename std::enable_if_t<visit_struct::traits::is_visitable<Struct>::value>> | |
matioCpp::Struct | make_variable (const std::string &name, const Struct &input) |
Conversion from a visitable struct to a matioCpp::Struct. More... | |
template<class iterator , typename = typename std::enable_if_t<is_pair_iterator_string<iterator>::value>> | |
matioCpp::Struct | make_struct (const std::string &name, iterator begin, iterator end) |
Create a matioCpp::Struct starting from the begin and end iterators of a map-like container The dereferenced value of the iterator has to be a pair (like with std::maps and std::unordered_map) with the key being a string. More... | |
template<class iterator , typename std::enable_if_t< is_pair_iterator_string< iterator >::value > * = nullptr> | |
matioCpp::CellArray | make_cell_array (const std::string &name, const iterator &begin, const iterator &end) |
Create a matioCpp::CellArray starting from the begin and end iterators of a container. More... | |
template<class iterator , typename std::enable_if_t<!is_pair< decltype(*std::declval< iterator >())>::value , * = nullptr> | |
matioCpp::CellArray | make_cell_array (const std::string &name, const iterator &begin, const iterator &end) |
Create a matioCpp::CellArray starting from the begin and end iterators of a container. More... | |
template<typename... Args> | |
void | unused (Args &&...) |
Utility metafunction to avoid compiler warnings about unused variables. More... | |
template<class ElementType , std::ptrdiff_t FirstExtent, std::ptrdiff_t SecondExtent> | |
MATIOCPP_CONSTEXPR bool | operator== (Span< ElementType, FirstExtent > l, Span< ElementType, SecondExtent > r) |
template<class ElementType , std::ptrdiff_t Extent> | |
MATIOCPP_CONSTEXPR bool | operator!= (Span< ElementType, Extent > l, Span< ElementType, Extent > r) |
template<class ElementType , std::ptrdiff_t Extent> | |
MATIOCPP_CONSTEXPR bool | operator< (Span< ElementType, Extent > l, Span< ElementType, Extent > r) |
template<class ElementType , std::ptrdiff_t Extent> | |
MATIOCPP_CONSTEXPR bool | operator<= (Span< ElementType, Extent > l, Span< ElementType, Extent > r) |
template<class ElementType , std::ptrdiff_t Extent> | |
MATIOCPP_CONSTEXPR bool | operator> (Span< ElementType, Extent > l, Span< ElementType, Extent > r) |
template<class ElementType , std::ptrdiff_t Extent> | |
MATIOCPP_CONSTEXPR bool | operator>= (Span< ElementType, Extent > l, Span< ElementType, Extent > r) |
template<class ElementType > | |
MATIOCPP_CONSTEXPR Span< ElementType > | make_span (ElementType *ptr, typename Span< ElementType >::index_type count) |
template<class ElementType > | |
MATIOCPP_CONSTEXPR Span< ElementType > | make_span (ElementType *firstElem, ElementType *lastElem) |
template<class ElementType , std::size_t N> | |
MATIOCPP_CONSTEXPR Span< ElementType, N > | make_span (ElementType(&arr)[N]) noexcept |
template<class Container , typename = typename std::enable_if<SpanUtils::is_value_defined<Container>::value>::type> | |
MATIOCPP_CONSTEXPR Span< typename Container::value_type > | make_span (Container &cont) |
template<class Container , typename = typename std::enable_if<SpanUtils::is_value_defined<Container>::value>::type> | |
MATIOCPP_CONSTEXPR Span< const typename Container::value_type > | make_span (const Container &cont) |
template<class Ptr > | |
MATIOCPP_CONSTEXPR Span< typename Ptr::element_type > | make_span (Ptr &cont, std::ptrdiff_t count) |
template<class Ptr , typename = typename std::enable_if<!SpanUtils::is_value_defined<Ptr>::value && SpanUtils::is_element_defined<Ptr>::value>::type> | |
MATIOCPP_CONSTEXPR Span< typename Ptr::element_type > | make_span (Ptr &cont) |
template<class Container , typename = typename std::enable_if<!SpanUtils::is_value_defined<Container>::value && !SpanUtils::is_element_defined<Container>::value && SpanUtils::has_data_method<Container>::value>::type> | |
MATIOCPP_CONSTEXPR Span< typename std::remove_pointer< decltype(std::declval< Container >).data())>::type > | make_span (Container &cont) |
template<class Container , typename = typename std::enable_if<!SpanUtils::is_value_defined<Container>::value && !SpanUtils::is_element_defined<Container>::value && SpanUtils::has_data_method<Container>::value>::type> | |
MATIOCPP_CONSTEXPR Span< const typename std::remove_pointer< decltype(std::declval< Container >).data())>::type > | make_span (const Container &cont) |
template<class Span , bool IsConst> | |
MATIOCPP_CONSTEXPR vector_iterator< Span, IsConst > | operator+ (typename vector_iterator< Span, IsConst >::difference_type n, vector_iterator< Span, IsConst > rhs) |
template<class Span , bool IsConst> | |
MATIOCPP_CONSTEXPR vector_iterator< Span, IsConst > | operator- (typename vector_iterator< Span, IsConst >::difference_type n, vector_iterator< Span, IsConst > rhs) |
Variables | |
MATIOCPP_CONSTEXPR const std::ptrdiff_t | dynamic_extent = -1 |
using matioCpp::size_t_type = typedef uint64_t |
Definition at line 53 of file ConversionUtilities.h.
using matioCpp::String = typedef Vector<char> |
Definition at line 194 of file ForwardDeclarations.h.
using matioCpp::String16 = typedef Vector<char16_t> |
Definition at line 196 of file ForwardDeclarations.h.
using matioCpp::String32 = typedef Vector<char32_t> |
Definition at line 198 of file ForwardDeclarations.h.
|
strong |
Compression type when writing to a file.
Enumerator | |
---|---|
None | |
zlib | No compression. Use zlib compression. |
Definition at line 147 of file ForwardDeclarations.h.
|
strong |
The delete mode of matvar_t pointers.
Enumerator | |
---|---|
DoNotDelete | |
ShallowDelete | The handler does not delete the pointer. |
Delete | The handler deletes the pointer but not the data. The handler deletes the pointer. |
Definition at line 156 of file ForwardDeclarations.h.
|
strong |
The available modes with which a file can be opened.
Enumerator | |
---|---|
ReadOnly | |
ReadAndWrite |
Definition at line 126 of file ForwardDeclarations.h.
|
strong |
The supported file versions.
Definition at line 135 of file ForwardDeclarations.h.
|
strong |
The list of types for an element of a certain variable type.
Enumerator | |
---|---|
INT8 | |
UINT8 | |
INT16 | |
UINT16 | |
INT32 | |
UINT32 | |
SINGLE | |
DOUBLE | |
INT64 | |
UINT64 | |
UTF8 | |
UTF16 | |
UTF32 | |
STRING | |
LOGICAL | |
VARIABLE | |
UNSUPPORTED |
Definition at line 102 of file ForwardDeclarations.h.
|
strong |
Define the type of variable.
Enumerator | |
---|---|
Element | |
Vector | |
MultiDimensionalArray | |
Struct | |
CellArray | |
StructArray | |
Unsupported |
Definition at line 88 of file ForwardDeclarations.h.
bool matioCpp::get_matio_types | ( | const VariableType & | inputVariableType, |
const ValueType & | inputValueType, | ||
matio_classes & | outputMatioClasses, | ||
matio_types & | outputMatioType | ||
) |
Get both the matio type and class from the input VariableType and ValueType.
inputVariableType | The input VariableType. |
inputValueType | The input ValueType. |
outputMatioClasses | The corresponding matio class. |
outputMatioType | The corresponding matio type |
Definition at line 10 of file ConversionUtilities.cpp.
References DOUBLE, INT16, INT32, INT64, INT8, LOGICAL, SINGLE, STRING, UINT16, UINT32, UINT64, UINT8, UTF16, UTF32, and UTF8.
Referenced by matioCpp::Variable::initializeComplexVariable(), and matioCpp::Variable::initializeVariable().
bool matioCpp::get_types_from_matvart | ( | const matvar_t * | input, |
matioCpp::VariableType & | outputVariableType, | ||
matioCpp::ValueType & | outputValueType | ||
) |
Get the VariableType and the ValueType from a matvar_t pointer.
input | The matvar_t pointer. |
outputVariableType | The output VariableType. |
outputValueType | The output ValueType. |
Definition at line 97 of file ConversionUtilities.cpp.
References CellArray, DOUBLE, Element, INT16, INT32, INT64, INT8, LOGICAL, MultiDimensionalArray, SINGLE, STRING, Struct, StructArray, UINT16, UINT32, UINT64, UINT8, Unsupported, UNSUPPORTED, UTF16, UTF32, UTF8, VARIABLE, and Vector.
Referenced by matioCpp::MatvarHandler::PointerInfo::changePointer(), matioCpp::Variable::fromMatio(), and matioCpp::MatvarHandler::GetMatvarDuplicate().
bool matioCpp::get_types_names_from_matvart | ( | const matvar_t * | input, |
std::string & | classType, | ||
std::string & | dataType | ||
) |
Get the type names from the input pointer.
input | The input pointer |
classType | The class type |
dataType | The data type |
Definition at line 228 of file ConversionUtilities.cpp.
bool matioCpp::is_convertible_to_primitive_type | ( | matioCpp::ValueType | type | ) |
Utility function to check if certain ValueType can be converted to a primitive type T.
type | The input ValueType to test. |
Definition at line 102 of file ConversionUtilities.h.
References DOUBLE, INT16, INT32, INT64, INT8, LOGICAL, SINGLE, STRING, UINT16, UINT32, UINT64, UINT8, UNSUPPORTED, UTF16, UTF32, UTF8, and VARIABLE.
|
inline |
Create a matioCpp::CellArray starting from the begin and end iterators of a container.
It need the dereferenced value of the iterator to be a pair (like with std::maps and std::unordered_map). The first element is used as name, while the second is the value.
name | The name of the CellArray. |
begin | The iterator to the first element |
end | The iterator to the element after the last. |
Definition at line 55 of file ExogenousConversions.tpp.
References std::distance(), make_variable(), and unused().
|
inline |
Create a matioCpp::CellArray starting from the begin and end iterators of a container.
The name of the imported variable in the CellArray is "imported_element_x", where "x" is the corresponding raw index.
name | The name of the CellArray. |
begin | The iterator to the first element |
end | The iterator to the element after the last. |
Definition at line 75 of file ExogenousConversions.tpp.
References std::distance(), make_variable(), std::to_string(), and unused().
MATIOCPP_CONSTEXPR Span<const typename Container::value_type> matioCpp::make_span | ( | const Container & | cont | ) |
MATIOCPP_CONSTEXPR Span<const typename std::remove_pointer<decltype (std::declval<Container>).data())>::type> matioCpp::make_span | ( | const Container & | cont | ) |
Definition at line 766 of file Span.h.
References matioCpp::Span< ElementType, Extent >::data().
MATIOCPP_CONSTEXPR Span<typename Container::value_type> matioCpp::make_span | ( | Container & | cont | ) |
MATIOCPP_CONSTEXPR Span<typename std::remove_pointer<decltype (std::declval<Container>).data())>::type> matioCpp::make_span | ( | Container & | cont | ) |
Definition at line 758 of file Span.h.
References matioCpp::Span< ElementType, Extent >::data().
MATIOCPP_CONSTEXPR Span<ElementType> matioCpp::make_span | ( | ElementType * | firstElem, |
ElementType * | lastElem | ||
) |
MATIOCPP_CONSTEXPR Span<ElementType> matioCpp::make_span | ( | ElementType * | ptr, |
typename Span< ElementType >::index_type | count | ||
) |
Definition at line 714 of file Span.h.
Referenced by matioCpp::Variable::dimensions(), make_variable(), matioCpp::Vector< T >::operator=(), matioCpp::Element< T >::toSpan(), matioCpp::MultiDimensionalArray< T >::toSpan(), matioCpp::Vector< T >::toSpan(), and matioCpp::Vector< T >::Vector().
|
noexcept |
MATIOCPP_CONSTEXPR Span<typename Ptr::element_type> matioCpp::make_span | ( | Ptr & | cont | ) |
MATIOCPP_CONSTEXPR Span<typename Ptr::element_type> matioCpp::make_span | ( | Ptr & | cont, |
std::ptrdiff_t | count | ||
) |
|
inline |
Create a matioCpp::Struct starting from the begin and end iterators of a map-like container The dereferenced value of the iterator has to be a pair (like with std::maps and std::unordered_map) with the key being a string.
For each key, there is the corresponding field in the Struct.
name | The name of the struct. |
begin | The iterator to the first element |
end | The iterator to the element after the last. |
Definition at line 40 of file ExogenousConversions.tpp.
References make_variable(), matioCpp::Struct::setField(), and unused().
matioCpp::Element< matioCpp::Logical > matioCpp::make_variable | ( | const std::string & | name, |
bool | input | ||
) |
Conversion from a boolean to a matioCpp::Element<matioCpp::Logical>
name | The name of the resulting matioCpp variable. |
input | The input element. |
Definition at line 11 of file ExogenousConversions.cpp.
matioCpp::String matioCpp::make_variable | ( | const std::string & | name, |
const std::string & | input | ||
) |
Conversion from a std::string to a matioCpp::String.
name | The name of the resulting matioCpp variable. |
input | The input string. |
Definition at line 16 of file ExogenousConversions.cpp.
matioCpp::Vector< matioCpp::Logical > matioCpp::make_variable | ( | const std::string & | name, |
const std::vector< bool > & | input | ||
) |
Conversion from a boolean vector to a matioCpp::Vector<matioCpp::Logical>
name | The name of the resulting matioCpp variable. |
input | The input vector. |
Definition at line 21 of file ExogenousConversions.cpp.
matioCpp::CellArray matioCpp::make_variable | ( | const std::string & | name, |
const std::vector< std::string > & | input | ||
) |
Conversion from a vector of strings to a matioCpp::CellArray containing the input strings.
name | The name of the resulting matioCpp variable. |
input | The input vector of strings. |
Definition at line 26 of file ExogenousConversions.cpp.
References make_variable(), matioCpp::CellArray::setElement(), std::vector< T >::size(), and std::to_string().
|
inline |
Conversion from a visitable struct to a matioCpp::Struct.
See https://github.com/garbageslam/visit_struct on how to make a Struct "visitable"
name | The name of the resulting matioCpp variable. |
input | The input struct. |
Definition at line 24 of file ExogenousConversions.tpp.
References make_variable(), matioCpp::Struct::setField(), and unused().
|
inline |
Conversion from a fundamental type to the corresponding matioCpp::Element.
name | The name of the resulting matioCpp variable. |
input | The input element. |
Definition at line 18 of file ExogenousConversions.tpp.
|
inline |
Conversion from a generic vector to a matioCpp::Vector.
name | The name of the resulting matioCpp variable. |
input | The input vector. |
Definition at line 11 of file ExogenousConversions.tpp.
References make_span().
Referenced by make_cell_array(), make_struct(), and make_variable().
MATIOCPP_CONSTEXPR bool matioCpp::operator!= | ( | Span< ElementType, Extent > | l, |
Span< ElementType, Extent > | r | ||
) |
MATIOCPP_CONSTEXPR vector_iterator<Span, IsConst> matioCpp::operator+ | ( | typename vector_iterator< Span, IsConst >::difference_type | n, |
vector_iterator< Span, IsConst > | rhs | ||
) |
Definition at line 178 of file VectorIterator.h.
MATIOCPP_CONSTEXPR vector_iterator<Span, IsConst> matioCpp::operator- | ( | typename vector_iterator< Span, IsConst >::difference_type | n, |
vector_iterator< Span, IsConst > | rhs | ||
) |
Definition at line 186 of file VectorIterator.h.
MATIOCPP_CONSTEXPR bool matioCpp::operator< | ( | Span< ElementType, Extent > | l, |
Span< ElementType, Extent > | r | ||
) |
Definition at line 657 of file Span.h.
References matioCpp::Span< ElementType, Extent >::begin(), matioCpp::Span< ElementType, Extent >::end(), and std::lexicographical_compare().
MATIOCPP_CONSTEXPR bool matioCpp::operator<= | ( | Span< ElementType, Extent > | l, |
Span< ElementType, Extent > | r | ||
) |
MATIOCPP_CONSTEXPR bool matioCpp::operator== | ( | Span< ElementType, FirstExtent > | l, |
Span< ElementType, SecondExtent > | r | ||
) |
Definition at line 643 of file Span.h.
References matioCpp::Span< ElementType, Extent >::begin(), matioCpp::Span< ElementType, Extent >::end(), and std::equal().
MATIOCPP_CONSTEXPR bool matioCpp::operator> | ( | Span< ElementType, Extent > | l, |
Span< ElementType, Extent > | r | ||
) |
MATIOCPP_CONSTEXPR bool matioCpp::operator>= | ( | Span< ElementType, Extent > | l, |
Span< ElementType, Extent > | r | ||
) |
|
inline |
Utility metafunction to avoid compiler warnings about unused variables.
Definition at line 83 of file ForwardDeclarations.h.
Referenced by make_cell_array(), make_struct(), make_variable(), matioCpp::StructArrayElement< isConst >::operator=(), and matioCpp::Variable::operator=().
MATIOCPP_CONSTEXPR const std::ptrdiff_t matioCpp::dynamic_extent = -1 |
Definition at line 172 of file ForwardDeclarations.h.
Referenced by matioCpp::details::extent_type< Ext >::extent_type(), matioCpp::Span< ElementType, Extent >::last(), and matioCpp::Span< ElementType, Extent >::subspan().