LOOS  v2.3.2
loos::StreamWrapper Class Reference

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

#include <StreamWrapper.hpp>

Inheritance diagram for loos::StreamWrapper:
Collaboration diagram for loos::StreamWrapper:

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) throw (FileOpenError)
 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) throw (FileOpenError)
 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) throw (LOOSError)
 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.

Definition at line 53 of file StreamWrapper.hpp.


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