LOOS 4.1.0
The Lightweight Object Oriented Structural analysis library/toolkit
Loading...
Searching...
No Matches
Public Member Functions | List of all members
loos::StreamWrapper Class Reference

Simple wrapper class for caching stream pointers. More...

#include <StreamWrapper.hpp>

Inheritance diagram for loos::StreamWrapper:
Inheritance graph
[legend]
Collaboration diagram for loos::StreamWrapper:
Collaboration graph
[legend]

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.
 

Detailed Description

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.


The documentation for this class was generated from the following file: