MemoryStreamCopy Class Reference

Buffers the complete contents of a stream in memory. More...

#include <basestrm.h>

Inheritance diagram for MemoryStreamCopy:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 MemoryStreamCopy (tnstream *stream)
 ~MemoryStreamCopy ()
void writedata (const void *buf, int size)
 writes data to the stream
int readdata (void *buf, int size, bool excpt=true)
 Reads data from the stream.
void seek (int newpos)
 Sets the stream pointer to a new location. An exception is thrown if the stream does not support seeking.
int getPosition (void)
int getSize (void)
 returns the size of the stream or -1 if the stream does not have a size
ASCString getLocation ()
 returns the location of the stream.

Detailed Description

Buffers the complete contents of a stream in memory.

May be useful when the original stream doesn't support seeking, but the consumer needs it.

Definition at line 148 of file basestrm.h.


Constructor & Destructor Documentation

MemoryStreamCopy::MemoryStreamCopy ( tnstream stream  ) 

Definition at line 566 of file basestrm.cpp.

References blocksize, tnstream::devicename, tnstream::getDeviceName(), malloc(), tnstream::readdata(), and red.

MemoryStreamCopy::~MemoryStreamCopy (  ) 

Definition at line 600 of file basestrm.cpp.


Member Function Documentation

void MemoryStreamCopy::writedata ( const void *  buf,
int  size 
) [virtual]

writes data to the stream

Parameters:
buf pointer to the buffer
size the number of bytes which are going to be written

Implements tnstream.

Definition at line 607 of file basestrm.cpp.

References tnstream::getDeviceName(), tnstream::reading, and tnstream::writing.

int MemoryStreamCopy::readdata ( void *  buf,
int  size,
bool  excpt = true 
) [virtual]

Reads data from the stream.

Parameters:
buf the buffer which the data is written to
size the number of bytes which should be read
excpt If true the operation will throw an exception if the desired number of bytes cannot be read.
Returns:
the number of bytes which were read.

Implements tnstream.

Definition at line 612 of file basestrm.cpp.

References tnstream::getDeviceName(), and PolygonTriangulationLibrary::tr.

Referenced by stream_read().

void MemoryStreamCopy::seek ( int  newpos  )  [virtual]

Sets the stream pointer to a new location. An exception is thrown if the stream does not support seeking.

Reimplemented from tnstream.

Definition at line 632 of file basestrm.cpp.

References tnstream::getDeviceName().

Referenced by stream_seek().

int MemoryStreamCopy::getPosition ( void   )  [inline]

Definition at line 160 of file basestrm.h.

Referenced by stream_seek().

int MemoryStreamCopy::getSize ( void   )  [inline, virtual]

returns the size of the stream or -1 if the stream does not have a size

Reimplemented from tnstream.

Definition at line 161 of file basestrm.h.

Referenced by stream_seek().

ASCString MemoryStreamCopy::getLocation (  )  [virtual]

returns the location of the stream.

This may be a complete english sentence describing how the stream (usually a file) can be found. Should only be used for informing the user.

Reimplemented from tnstream.

Definition at line 595 of file basestrm.cpp.

References tnstream::devicename.


The documentation for this class was generated from the following files:
Generated on Mon May 21 01:47:03 2012 for Advanced Strategic Command by  doxygen 1.5.1