GMemStream Class Reference

In memory stream for storing sub-streams or memory blocks. More...

#include <GStream.h>

Inheritance diagram for GMemStream:

GStream GStreamI GDom

List of all members.

Public Member Functions

 GMemStream ()
 Builds an empty memory stream.
 GMemStream (GStreamI *Src, int64 Start, int64 Len)
 Builds memory from sub-stream.
 GMemStream (void *Mem, int64 Len, bool Copy=true)
 Builds a memory stream by copying from another memory block.
 GMemStream (int GrowBlockSize)
 Growable array to write to.
bool IsOpen ()
 Returns true is the stream is still open.
int Close ()
int64 GetSize ()
 Gets the size of the stream.
int64 GetPos ()
 Gets the current position of the stream.
int64 SetPos (int64 p)
 Sets the current position of the stream.
int Open (const char *Str, int Int)
 Opens a file and reads it all into memory.
int64 SetSize (int64 Size)
 Changes the size of the memory block, keeping any common bytes.
int Read (void *Buffer, int Size, int Flags=0)
 Read bytes out of the stream.
int Write (const void *Buffer, int Size, int Flags=0)
 Write bytes to the stream.
GStreamIClone ()
 Creates a dynamically allocated copy of the same type of stream. This new stream is not connected to anything.


Detailed Description

In memory stream for storing sub-streams or memory blocks.

Constructor & Destructor Documentation

GMemStream::GMemStream ( GStreamI Src,
int64  Start,
int64  Len 
)

Builds memory from sub-stream.

Parameters:
Src  The source stream
Start  The starting position in the stream, or -1 for the current position. Use -1 for non-seekable streams like sockets
Len  The length of the sub-stream, or -1 to read all the data to the end

References GBytePipe::GetSize(), GStreamI::GetSize(), GetSize(), GBytePipe::New(), GStreamI::Read(), GStreamI::SetPos(), and GBytePipe::Write().

GMemStream::GMemStream ( void *  Mem,
int64  Len,
bool  Copy = true 
)

Builds a memory stream by copying from another memory block.

Parameters:
Mem  The source memory block
Len  The length of the block
Copy  Whether to copy the block or reference memory we don't own


Member Function Documentation

int GMemStream::Close (  )  [virtual]

Closes the connection

Returns:
> zero on success

Reimplemented from GStreamI.

Referenced by Open(), and SetSize().

int64 GMemStream::GetSize (  )  [inline, virtual]

Gets the size of the stream.

Returns:
The size or -1 on error (e.g. the information is not available)

Reimplemented from GStreamI.

Referenced by GMemStream(), and GTempStream::Write().

int64 GMemStream::GetPos (  )  [inline, virtual]

Gets the current position of the stream.

Returns:
Current position or -1 on error (e.g. the position is not known)

Reimplemented from GStreamI.

int64 GMemStream::SetPos ( int64  Pos  )  [inline, virtual]

Sets the current position of the stream.

Returns:
The new current position or -1 on error (e.g. the position can't be set)

Reimplemented from GStreamI.

Referenced by GTempStream::Write().

int GMemStream::Read ( void *  Buffer,
int  Size,
int  Flags = 0 
) [virtual]

Read bytes out of the stream.

Returns:
> 0 on succes, which indicates the number of bytes read

Reimplemented from GStream.

int GMemStream::Write ( const void *  Buffer,
int  Size,
int  Flags = 0 
) [virtual]

Write bytes to the stream.

Returns:
> 0 on succes, which indicates the number of bytes written

Reimplemented from GStream.

Referenced by GTempStream::Write().

GStreamI * GMemStream::Clone (  )  [virtual]

Creates a dynamically allocated copy of the same type of stream. This new stream is not connected to anything.

Returns:
The new stream or NULL on error.

Reimplemented from GStreamI.

References GMemStream().


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

Generated on Wed May 11 07:51:58 2011 for Lgi by  doxygen 1.5.6