GMemStream Class Reference

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

#include <GStream.h>

Inheritance diagram for GMemStream:

GStream 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 connection 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 (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 (void *Buffer, int Size, int Flags=0)
 Write bytes to the stream.
GStreamI * Clone ()
 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(), GetSize(), GBytePipe::New(), 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

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 GStream.

References GMemStream().

int GMemStream::Close (  )  [virtual]

Closes the connection

Returns:
> zero on success

Reimplemented from GStream.

Referenced by Open(), and SetSize().

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 GStream.

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 GStream.

Referenced by GMemStream().

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.

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 GStream.

int GMemStream::Write ( 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.


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

Generated on Wed Dec 1 15:41:03 2010 for Lgi by  doxygen 1.5.7.1