matio-cpp  v0.2.5
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
File.h
Go to the documentation of this file.
1 #ifndef MATIOCPP_FILE_H
2 #define MATIOCPP_FILE_H
3 
4 /*
5  * Copyright (C) 2020 Fondazione Istituto Italiano di Tecnologia
6  *
7  * This software may be modified and distributed under the terms of the
8  * BSD-2-Clause license (https://opensource.org/licenses/BSD-2-Clause).
9  */
10 
11 
13 #include <matioCpp/Variable.h>
14 
16 {
17  class Impl;
18 
19  std::unique_ptr<Impl> m_pimpl;
28  template<class input>
29  inline const input &getVariable(const input& it);
30 
37  template<class key, class input>
38  inline const input &getVariable(const std::pair<key, input>& it);
39 
40 public:
41 
45  File();
46 
54 
58  File(const File& other) = delete;
59 
64  File(File&& other);
65 
69  ~File();
70 
74  void operator=(const File& other) = delete;
75 
80  void operator=(File&& other);
81 
85  void close();
86 
94 
104  static File Create(const std::string& name,
106  const std::string& header = "");
107 
113  static bool Delete(const std::string& name);
114 
120  static bool Exists(const std::string& name);
121 
126  std::string name() const;
127 
136  std::string header() const;
137 
143 
149  matioCpp::FileMode mode() const;
150 
156 
163  matioCpp::Variable read(const std::string& name) const;
164 
172  bool write(const Variable &variable, matioCpp::Compression compression = matioCpp::Compression::None);
173 
181  template <class iterator>
182  bool write(iterator begin, iterator end, matioCpp::Compression compression = matioCpp::Compression::None);
183 
188  bool isOpen() const;
189 
190 };
191 
192 #include "impl/File.tpp"
193 
194 #endif // MATIOCPP_FILE_H
matioCpp::FileVersion version() const
The MAT file version.
Definition: File.cpp:260
void close()
Close the file.
Definition: File.cpp:120
static bool Exists(const std::string &name)
Check if file exists and can be opened.
Definition: File.cpp:229
matioCpp::FileMode mode() const
The mode with which the file has been opened.
Definition: File.cpp:283
bool isOpen() const
Check if the file is open.
Definition: File.cpp:402
void operator=(const File &other)=delete
Deleted copy assignment, to avoid confusion on whether the content has been copied or not.
bool open(const std::string &name, matioCpp::FileMode mode=matioCpp::FileMode::ReadAndWrite)
Open the specified file.
Definition: File.cpp:125
std::string header() const
The file header.
Definition: File.cpp:245
~File()
Destructor.
Definition: File.cpp:110
std::vector< std::string > variableNames() const
Get the list of variables in the file.
Definition: File.cpp:288
File()
Default Constructor.
Definition: File.cpp:93
static bool Delete(const std::string &name)
Delete the specified file.
Definition: File.cpp:224
std::string name() const
The file name.
Definition: File.cpp:235
matioCpp::Variable read(const std::string &name) const
Read a variable given the name.
Definition: File.cpp:306
static File Create(const std::string &name, matioCpp::FileVersion version=matioCpp::FileVersion::Default, const std::string &header="")
Create a new file (static)
Definition: File.cpp:132
bool write(const Variable &variable, matioCpp::Compression compression=matioCpp::Compression::None)
Write a Variable to a file.
Definition: File.cpp:334
File(const File &other)=delete
Deleted copy constructor, to avoid confusion on whether the content has been copied or not.
The matioCpp::Variable class is the equivalent of matvar_t in matio.
Definition: Variable.h:23
FileVersion
The supported file versions.
FileMode
The available modes with which a file can be opened.
Compression
Compression type when writing to a file.