|
matio-cpp v0.3.0
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
|
#include <matioCpp/File.h>
Data Structures | |
| class | Impl |
Public Member Functions | |
| File () | |
| Default Constructor. | |
| File (const std::string &name, matioCpp::FileMode mode=matioCpp::FileMode::ReadAndWrite) | |
| Constructor opening the specified file. | |
| File (const File &other)=delete | |
| Deleted copy constructor, to avoid confusion on whether the content has been copied or not. | |
| File (File &&other) | |
| Move constructor. | |
| ~File () | |
| Destructor. | |
| void | operator= (const File &other)=delete |
| Deleted copy assignment, to avoid confusion on whether the content has been copied or not. | |
| void | operator= (File &&other) |
| Move assignement. | |
| void | close () |
| Close the file. | |
| bool | open (const std::string &name, matioCpp::FileMode mode=matioCpp::FileMode::ReadAndWrite) |
| Open the specified file. | |
| std::string | name () const |
| The file name. | |
| std::string | header () const |
| The file header. | |
| matioCpp::FileVersion | version () const |
| The MAT file version. | |
| matioCpp::FileMode | mode () const |
| The mode with which the file has been opened. | |
| std::vector< std::string > | variableNames () const |
| Get the list of variables in the file. | |
| matioCpp::Variable | read (const std::string &name) const |
| Read a variable given the name. | |
| bool | write (const Variable &variable, matioCpp::Compression compression=matioCpp::Compression::None) |
| Write a Variable to a file. | |
| template<class iterator > | |
| bool | write (iterator begin, iterator end, matioCpp::Compression compression=matioCpp::Compression::None) |
| Write a Variable to a file in a batch. | |
| bool | isOpen () const |
| Check if the file is open. | |
Static Public Member Functions | |
| static File | Create (const std::string &name, matioCpp::FileVersion version=matioCpp::FileVersion::Default, const std::string &header="") |
| Create a new file (static) | |
| static bool | Delete (const std::string &name) |
| Delete the specified file. | |
| static bool | Exists (const std::string &name) |
| Check if file exists and can be opened. | |
| matioCpp::File::File | ( | const std::string & | name, |
| matioCpp::FileMode | mode = matioCpp::FileMode::ReadAndWrite |
||
| ) |
Deleted copy constructor, to avoid confusion on whether the content has been copied or not.
| matioCpp::File::File | ( | matioCpp::File && | other | ) |
|
static |
Create a new file (static)
This is the static version of open, with the addition that it is possible to have additional settings.
| name | The name of the file to be openend. |
| version | The MAT file version. |
| header | This is an optional string that is added inside the MAT file. You can view the text in a MAT-file header using the cat command on the file on UNIX. |
Definition at line 139 of file File.cpp.
References std::string::c_str(), std::endl(), std::string::find_last_of(), matioCpp::MAT4, matioCpp::MAT5, matioCpp::MAT7_3, matioCpp::ReadAndWrite, std::string::substr(), std::to_string(), and matioCpp::Undefined.
|
static |
Delete the specified file.
| name | Name of the file to delete. |
Definition at line 231 of file File.cpp.
References std::string::c_str(), and std::remove().
|
static |
Check if file exists and can be opened.
| name | The name of the file to check |
Definition at line 236 of file File.cpp.
References isOpen(), and matioCpp::ReadOnly.
| std::string matioCpp::File::header | ( | ) | const |
The file header.
This is an optional string that is added inside the MAT file. You can view the text in a MAT-file header using the cat command on the file on UNIX.
Definition at line 252 of file File.cpp.
References std::endl().
| bool matioCpp::File::isOpen | ( | ) | const |
| matioCpp::FileMode matioCpp::File::mode | ( | ) | const |
The mode with which the file has been opened.
Definition at line 290 of file File.cpp.
Referenced by File(), and matioCpp::File::Impl::reset().
| std::string matioCpp::File::name | ( | ) | const |
| bool matioCpp::File::open | ( | const std::string & | name, |
| matioCpp::FileMode | mode = matioCpp::FileMode::ReadAndWrite |
||
| ) |
Open the specified file.
| name | The name of the file to open. |
| mode | The mode with which to open the file. By default, both reading and writing are allowed. |
Definition at line 125 of file File.cpp.
References std::string::c_str(), std::endl(), and matioCpp::ReadOnly.
Referenced by File().
Deleted copy assignment, to avoid confusion on whether the content has been copied or not.
| void matioCpp::File::operator= | ( | matioCpp::File && | other | ) |
Move assignement.
| other | The other File from which the internal status has been taken. |
Definition at line 115 of file File.cpp.
References std::move().
| matioCpp::Variable matioCpp::File::read | ( | const std::string & | name | ) | const |
Read a variable given the name.
| name | The name of the variable to be read |
Definition at line 313 of file File.cpp.
References std::string::c_str(), std::endl(), matioCpp::Variable::isValid(), and matioCpp::MAT7_3.
| std::vector< std::string > matioCpp::File::variableNames | ( | ) | const |
Get the list of variables in the file.
Definition at line 295 of file File.cpp.
References matioCpp::MultiDimensionalArray< T >::resize().
| matioCpp::FileVersion matioCpp::File::version | ( | ) | const |
The MAT file version.
Definition at line 267 of file File.cpp.
References matioCpp::MAT4, matioCpp::MAT5, matioCpp::MAT7_3, and matioCpp::Undefined.
| bool matioCpp::File::write | ( | const Variable & | variable, |
| matioCpp::Compression | compression = matioCpp::Compression::None |
||
| ) |
Write a Variable to a file.
| variable | The input variable. |
| compression | The compression type to be used for writing the variable. |
Definition at line 341 of file File.cpp.
References matioCpp::Variable::dimensions(), matioCpp::DOUBLE, matioCpp::Element, std::endl(), matioCpp::SharedMatvar::GetMatvarShallowDuplicate(), matioCpp::INT16, matioCpp::INT32, matioCpp::LOGICAL, matioCpp::MAT4, matioCpp::MultiDimensionalArray, matioCpp::ReadAndWrite, matioCpp::SINGLE, matioCpp::Variable::toMatio(), matioCpp::UINT16, matioCpp::UINT8, matioCpp::Variable::valueType(), matioCpp::Variable::variableType(), matioCpp::Vector, and matioCpp::zlib.
| bool matioCpp::File::write | ( | iterator | begin, |
| iterator | end, | ||
| matioCpp::Compression | compression = matioCpp::Compression::None |
||
| ) |