STIR
6.2.0
|
A helper class to read data from a (presumably binary) stream. More...
#include "stir/IO/InputStreamWithRecords.h"
Public Types | |
typedef std::vector< std::streampos >::size_type | SavedPosition |
Public Member Functions | |
InputStreamWithRecords (const shared_ptr< std::istream > &stream_ptr, const std::size_t size_of_record_signature, const std::size_t max_size_of_record, const OptionsT &options) | |
Constructor taking a stream. More... | |
InputStreamWithRecords (const std::string &filename, const std::size_t size_of_record_signature, const std::size_t max_size_of_record, const OptionsT &options, const std::streampos start_of_data=0) | |
Constructor taking a filename. More... | |
virtual Succeeded | get_next_record (RecordT &record) const |
Succeeded | reset () |
go back to starting position | |
SavedPosition | save_get_position () |
save current "get" position in an internal array More... | |
Succeeded | set_get_position (const SavedPosition &) |
set current "get" position to previously saved value | |
std::vector< std::streampos > | get_saved_get_positions () const |
Function that enables the user to store the saved get_positions. More... | |
void | set_saved_get_positions (const std::vector< std::streampos > &) |
Function that sets the saved get_positions. More... | |
std::istream & | get_stream () |
A helper class to read data from a (presumably binary) stream.
This class is really a helper class for reading different records from a stream. It is useful when all types of records have some kind of signature to allow the function to find out what the size of the record is. In that case, all IO handling is completely generic and is implemented in this class.
Current implementation needs a max_size_of_record
to allocate enough memory (on the stack) before reading. This is efficient in many cases, but impractical in others.
RecordT
needs to have the following member functions new
or on the stack.
|
inline |
Constructor taking a stream.
Data will be assumed to start at the current position reported by seekg(). If reset() is used, it will go back to this starting position.
References stir::error().
|
inline |
Constructor taking a filename.
File will be opened in binary mode. Data will be assumed to start at start_of_data.
References stir::error(), stir::open_read_binary(), stir::InputStreamWithRecords< RecordT, OptionsT >::reset(), and stir::warning().
|
inline |
save current "get" position in an internal array
References stir::error().
|
inline |
Function that enables the user to store the saved get_positions.
Together with set_saved_get_positions(), this allows reinstating the saved get_positions when reopening the same stream.
|
inline |
Function that sets the saved get_positions.
Normally, the argument results from a call to get_saved_get_positions() on the same stream.