Helper class that hands out input streams to a stringstream. More...
#include <StringInputStream.h>
Public Member Functions | |
StringInputStream (std::unique_ptr< std::stringstream > stream) | |
virtual std::shared_ptr< std::istream > | get () const override final |
Gets an input stream to the underlying stream. More... | |
std::unique_ptr< std::stringstream > | release () |
Releases the owned stringstream. More... | |
bool | inUse () const |
Whether or not anything is still using this stream. More... | |
virtual std::optional< std::filesystem::path > | getFilename () const |
Gets the underlying filename, if any. More... | |
Protected Member Functions | |
void | addSharedStream (const std::weak_ptr< std::istream > stream) const |
Internal method to be called by derived classes to add a shared stream to _shared_streams (so that it can be tracked). More... | |
Private Attributes | |
std::unique_ptr< std::stringstream > | _stream |
The underlying stringstream. More... | |
Helper class that hands out input streams to a stringstream.
Definition at line 19 of file StringInputStream.h.
StringInputStream::StringInputStream | ( | std::unique_ptr< std::stringstream > | stream | ) |
Definition at line 14 of file StringInputStream.C.
|
protectedinherited |
Internal method to be called by derived classes to add a shared stream to _shared_streams (so that it can be tracked).
Should be called in the overridden get() by derived classes.
Definition at line 21 of file InputStream.C.
Referenced by FileInputStream::get(), and get().
|
finaloverridevirtual |
Gets an input stream to the underlying stream.
This is returned as a shared_ptr so that this class can tell whether or not another object is still using the stream.
Implements InputStream.
Definition at line 20 of file StringInputStream.C.
|
virtualinherited |
Gets the underlying filename, if any.
Reimplemented in FileInputStream.
Definition at line 44 of file InputStream.C.
Referenced by RestartableDataReader::deserializeValue(), and RestartableDataReader::readHeader().
|
inherited |
Whether or not anything is still using this stream.
This is checked by seeing whether or not the use count of any of the streams handed out by get() is > 1 (with the only use count being the one stored in _shared_streams)
Definition at line 35 of file InputStream.C.
Referenced by release(), and InputStream::~InputStream().
std::unique_ptr< std::stringstream > StringInputStream::release | ( | ) |
Releases the owned stringstream.
Will error if an object still has access to a stream obtained via get().
Leaves the owned stream in an undefined state.
Definition at line 30 of file StringInputStream.C.
|
private |
The underlying stringstream.
Definition at line 37 of file StringInputStream.h.