matio-cpp
v0.2.5
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. More... | |
File (const std::string &name, matioCpp::FileMode mode=matioCpp::FileMode::ReadAndWrite) | |
Constructor opening the specified file. More... | |
File (const File &other)=delete | |
Deleted copy constructor, to avoid confusion on whether the content has been copied or not. More... | |
File (File &&other) | |
Move constructor. More... | |
~File () | |
Destructor. More... | |
void | operator= (const File &other)=delete |
Deleted copy assignment, to avoid confusion on whether the content has been copied or not. More... | |
void | operator= (File &&other) |
Move assignement. More... | |
void | close () |
Close the file. More... | |
bool | open (const std::string &name, matioCpp::FileMode mode=matioCpp::FileMode::ReadAndWrite) |
Open the specified file. More... | |
std::string | name () const |
The file name. More... | |
std::string | header () const |
The file header. More... | |
matioCpp::FileVersion | version () const |
The MAT file version. More... | |
matioCpp::FileMode | mode () const |
The mode with which the file has been opened. More... | |
std::vector< std::string > | variableNames () const |
Get the list of variables in the file. More... | |
matioCpp::Variable | read (const std::string &name) const |
Read a variable given the name. More... | |
bool | write (const Variable &variable, matioCpp::Compression compression=matioCpp::Compression::None) |
Write a Variable to a file. More... | |
template<class iterator > | |
bool | write (iterator begin, iterator end, matioCpp::Compression compression=matioCpp::Compression::None) |
Write a Variable to a file in a batch. More... | |
bool | isOpen () const |
Check if the file is open. More... | |
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) More... | |
static bool | Delete (const std::string &name) |
Delete the specified file. More... | |
static bool | Exists (const std::string &name) |
Check if file exists and can be opened. More... | |
matioCpp::File::File | ( | const std::string & | name, |
matioCpp::FileMode | mode = matioCpp::FileMode::ReadAndWrite |
||
) |
|
delete |
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 132 of file File.cpp.
References std::string::c_str(), std::endl(), std::string::find_last_of(), isOpen(), matioCpp::MAT4, matioCpp::MAT5, matioCpp::MAT7_3, matioCpp::ReadAndWrite, std::string::size(), std::string::substr(), std::to_string(), and matioCpp::Undefined.
|
static |
Delete the specified file.
name | Name of the file to delete. |
Definition at line 224 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 229 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 245 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 283 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(), and matioCpp::ReadOnly.
Referenced by File().
|
delete |
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 306 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 288 of file File.cpp.
References std::vector< T >::resize().
matioCpp::FileVersion matioCpp::File::version | ( | ) | const |
The MAT file version.
Definition at line 260 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 334 of file File.cpp.
References matioCpp::Variable::dimensions(), matioCpp::DOUBLE, matioCpp::Element, std::endl(), matioCpp::SharedMatvar::get(), matioCpp::SharedMatvar::GetMatvarShallowDuplicate(), matioCpp::INT16, matioCpp::INT32, matioCpp::LOGICAL, matioCpp::MAT4, matioCpp::MultiDimensionalArray, matioCpp::ReadAndWrite, matioCpp::SINGLE, std::string::size(), 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 |
||
) |