libpniio
|
base class for data readers More...
#include <data_reader.hpp>
Public Member Functions | |
virtual | ~data_reader () |
destructor More... | |
pni::core::string | filename () const |
get filename More... | |
void | filename (const pni::core::string &fname) |
set filename More... | |
virtual void | close () |
close the file More... | |
virtual void | open () |
open file More... | |
Protected Member Functions | |
std::ifstream & | _get_stream () const |
get stream More... | |
void | _set_binary () |
set binary mode More... | |
data_reader () | |
default constructor More... | |
data_reader (const pni::core::string &fname, bool binary=false) | |
standard constructor More... | |
data_reader (data_reader &&r) | |
move constructor More... | |
data_reader (const data_reader &r)=delete | |
copy constructor is deleted More... | |
data_reader & | operator= (const data_reader &r)=delete |
copy assigment is deleted More... | |
data_reader & | operator= (data_reader &&r) |
move assignment More... | |
Private Member Functions | |
std::unique_ptr< std::ifstream > | _open_stream (const pni::core::string &fname) const |
open the stream More... | |
Private Attributes | |
pni::core::string | _fname |
name of the file More... | |
bool | _is_binary |
flag determining how files will be opened More... | |
std::unique_ptr< std::ifstream > | _istream |
stream from which to read data More... | |
This is the base class for all data readers. Actually this class only manages the name of the file to open for reading. One cannot instantiate an object of this class directly. This is done via the concrete reader classes. Thus all constructors are protected making them available only for derived classes.
|
protected |
|
explicitprotected |
This constructor takes the name of the file from which to reads data as its only argument and opens the file.
FileError | if opening the file fails |
fname | name of the file |
binary | if true stream will be opened in binary mode |
|
protected |
|
protecteddelete |
|
virtual |
|
inlineprotected |
Return a non-const reference to the stream on the file. This method is protected and thus only available to derived classes which can use this method to obtain a reference to the stream.
|
private |
Virtual private method opening the stream. This class provides a default implementation for this method. If a different way of opening a stream is required this method must be overloaded by child classes.
file_error | if opening the file fails |
memory_allocation_error | if allocation of a stream object fails |
fname | file name |
|
inlineprotected |
Set the stream mode to binary. This method is primarily used by default constructors which do not have parameters.
|
virtual |
Reimplemented in pni::io::tiff_reader, and pni::io::cbf_reader.
string pni::io::data_reader::filename | ( | ) | const |
void pni::io::data_reader::filename | ( | const pni::core::string & | fname | ) |
fname | name of the file to read data from |
|
virtual |
Opens the file given by filename.
FileError | in case of errors |
Reimplemented in pni::io::tiff_reader, and pni::io::cbf_reader.
|
protecteddelete |
|
protected |
|
private |
|
private |
|
mutableprivate |