ug4
|
Generic matrix I/O functionality. More...
#include <matrix_io.h>
Public Types | |
enum | OpenMode { EXISTING = 1 , NEW = 2 } |
Specifies how file names pointing to non-existing files should be handeld. More... | |
Public Member Functions | |
std::string | get_mat_file_name () const |
Retreive associated exchange file path and name. More... | |
MatrixIO () | |
Number of rows as specified in the matrix exchange file. More... | |
MatrixIO (std::string mFile, int openMode=EXISTING) | |
Constructor specifying matrix exchange file path. More... | |
void | set_mat_file_name (std::string mFile, int openMode=EXISTING) |
Sets associated file to another one. More... | |
~MatrixIO () | |
Destructor. More... | |
Private Member Functions | |
void | close_file () |
Closes file stream. More... | |
void | open_file (std::ios_base::openmode mode=std::ios_base::in) |
Opens the associated file in m_matFileStream . More... | |
Private Attributes | |
std::fstream | m_matFileStream |
Internal file stream for reading from and writing into the matrix exchange file. More... | |
MatrixFileType | m_matFileType |
Matrix exchange file type. More... | |
std::string * | m_pMatFileName |
Full path name of the matrix exchange file. More... | |
Generic matrix I/O functionality.
This is the generic class for matrix I/O functionality. For actual matrix I/O operations use one of it's subclasses specifying the specific behaviour for one of the supported matrix exchange file formats.
ug::MatrixIO::MatrixIO | ( | ) |
Number of rows as specified in the matrix exchange file.
Number of columns as specified in the matrix exchange file Number of data lines as specified in the matrix exchange file
Default constructor
ug::MatrixIO::MatrixIO | ( | std::string | mFile, |
int | openMode = EXISTING |
||
) |
Constructor specifying matrix exchange file path.
[in] | mFile | path and name of matrix exchange file. |
[in] | openMode | how to deal with non-existing files (a value of MatrixIO::OpenMode) |
References set_mat_file_name().
ug::MatrixIO::~MatrixIO | ( | ) |
Destructor.
The destructor calls MatrixIO::close_file to make sure, that write operations to the associated exchange file are flushed and terminated correctly.
References close_file(), and m_pMatFileName.
|
private |
std::string ug::MatrixIO::get_mat_file_name | ( | ) | const |
Retreive associated exchange file path and name.
References m_pMatFileName.
|
private |
Opens the associated file in m_matFileStream
.
[in] | mode | Modus of the resulting file stream (a value of std::ios_base::openmode). Defaults to std::ios_base::in. |
std::runtime_error | if m_pMatFileName is empty |
std::runtime_error | if file stream can not be opened (i.e. failbit or badbit are set) |
References m_matFileStream, m_pMatFileName, and UG_ASSERT.
void ug::MatrixIO::set_mat_file_name | ( | std::string | mFile, |
int | openMode = EXISTING |
||
) |
Sets associated file to another one.
[in] | mFile | Full path and name of matrix exchange file. |
[in] | openMode | how to deal with non-existing files |
std::runtime_error | if exchange file is not found and openMode=OpenMode::Existing . |
UGError | if openMode is non of OpenMode |
References EXISTING, ug::FileExists(), m_pMatFileName, NEW, UG_ASSERT, and UG_THROW.
Referenced by MatrixIO().
|
private |
Internal file stream for reading from and writing into the matrix exchange file.
Referenced by close_file(), and open_file().
|
private |
Matrix exchange file type.
|
private |
Full path name of the matrix exchange file.
Referenced by get_mat_file_name(), open_file(), set_mat_file_name(), and ~MatrixIO().