LOOS 4.1.0
The Lightweight Object Oriented Structural analysis library/toolkit
|
Simple wrapper class for caching stream pointers. More...
#include <StreamWrapper.hpp>
Public Member Functions | |
StreamWrapper (std::istream &fs) | |
Sets the internal stream pointer to fs. | |
StreamWrapper (const std::string &s, const std::ios_base::openmode mode=std::ios_base::in|std::ios_base::binary) | |
Opens a new stream with file named 's'. | |
void | setStream (const std::string &s, const std::ios_base::openmode mode=std::ios_base::in|std::ios_base::binary) |
Sets the internal stream to point to a newly opened filed... | |
void | setStream (std::istream &fs) |
Sets the internal stream to the passed fstream. | |
std::istream * | operator() (void) |
Returns the internal istream pointer. | |
bool | isUnset (void) const |
Returns true if the internal stream pointer is unset. | |
Simple wrapper class for caching stream pointers.
This class was written primarily for use with the DCD classes where we want to have a cached stream that we may read from (or write to) at various times in the future. Access to the underlying fstream pointer is through the operator() functor.
The basic idea here is that you pass the class either a string or a char array and that will be opened into a new stream (reading by default). The fstream pointer will be stored and when the wrapper object is destroyed, the stream is released & deleted. If you pass the wrapper an fstream, however, the internal pointer is initialized to point to that stream and when the wrapper object is destroyed, the stream is left alone.