Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members
Public Member Functions | Protected Attributes
resource::MemoryDataStream Class Reference

Subclass of DataStream for handling data from chunks of memory. More...

#include <DataStream.h>

Inheritance diagram for resource::MemoryDataStream:
resource::DataStream

List of all members.

Public Member Functions

void close ()
bool eof ()
 Returns true if the buffer pointer has reached the end of the buffer.
u8getCurrentPtr ()
 Get a pointer to the current position in the memory block this stream holds.
u8getPtr ()
 Get a pointer to the start of the memory block this stream holds.
 MemoryDataStream (void *mem, u32 size, bool freeOnClose=false)
 MemoryDataStream (DataStream &sourceStream, bool freeOnClose=true)
 MemoryDataStream (u32 size, bool freeOnClose=true)
u32 read (void *buffer, u32 size, u32 count)
u32 read (void *buffer, u32 size)
u32 readLine (c8 *buffer, u32 size, const std::string &delim="\n")
void seek (u32 pos)
 Repositions the internal read pointer to a specified byte.
void skip (s32 offset)
u32 skipLine (const std::string &delim="\n")
 Skip a single line from the stream.
u32 tell () const
 Returns the current byte offset from beginning.
 ~MemoryDataStream ()

Protected Attributes

u8mData
u8mEnd
bool mFreeOnClose
u8mPos

Detailed Description

Subclass of DataStream for handling data from chunks of memory.


Constructor & Destructor Documentation

resource::MemoryDataStream::MemoryDataStream ( void *  mem,
u32  size,
bool  freeOnClose = false 
)

Wrap an existing memory chunk in a stream.

Parameters:
mem,:Pointer to the exising memory
size,:The size of the memory chunk in bytes
freeOnClose,:If true, the memory associated will be destroyed on close.

References mData, mEnd, mFreeOnClose, mPos, resource::DataStream::mSize, and resource::DataStream::size().

resource::MemoryDataStream::MemoryDataStream ( DataStream sourceStream,
bool  freeOnClose = true 
)

Create a stream which pre-buffers the contents of another stream. This constructor can be used to intentionally read in the entire contents of another stream, copying them to the internal buffer and thus making them available in memory as a single unit.

Parameters:
sourceStream,:DataStream which will provide the source of data
freeOnClose,:If true, the memory associated will be destroyed on close.

References mData, mEnd, mFreeOnClose, mPos, resource::DataStream::mSize, resource::DataStream::read(), and resource::DataStream::size().

resource::MemoryDataStream::MemoryDataStream ( u32  size,
bool  freeOnClose = true 
)

Create a stream with a brand new empty memory chunk.

Parameters:
size,:The size of the memory chunk to create in bytes
freeOnClose,:If true, the memory associated will be destroyed on close.

References mData, mEnd, mFreeOnClose, mPos, resource::DataStream::mSize, and resource::DataStream::size().

resource::MemoryDataStream::~MemoryDataStream ( )

References mData.


Member Function Documentation

void resource::MemoryDataStream::close ( void  )

References mData, and mFreeOnClose.

bool resource::MemoryDataStream::eof ( ) [virtual]

Returns true if the buffer pointer has reached the end of the buffer.

Implements resource::DataStream.

References mEnd, and mPos.

u8 * resource::MemoryDataStream::getCurrentPtr ( )

Get a pointer to the current position in the memory block this stream holds.

References mPos.

u8 * resource::MemoryDataStream::getPtr ( )

Get a pointer to the start of the memory block this stream holds.

References mData.

u32 resource::MemoryDataStream::read ( void *  buffer,
u32  size,
u32  count 
) [virtual]

Implements resource::DataStream.

References mEnd, and mPos.

u32 resource::MemoryDataStream::read ( void *  buffer,
u32  size 
) [virtual]

Reads the data stream into a buffer.

Parameters:
buffer,:Pointer to buffer to read into
size,:Number of bytes to read
Returns:
The number of bytes actually read.

Implements resource::DataStream.

References mEnd, mPos, and resource::DataStream::size().

u32 resource::MemoryDataStream::readLine ( c8 buffer,
u32  size,
const std::string &  delim = "\n" 
) [virtual]

Reads a line from the data stream into a buffer.

Parameters:
buffer,:Pointer to buffer to read into
size,:Max number of bytes to read
delim,:The delimiter to stop at
Returns:
The number of bytes actually read.

Reimplemented from resource::DataStream.

References mEnd, and mPos.

void resource::MemoryDataStream::seek ( u32  pos) [virtual]

Repositions the internal read pointer to a specified byte.

Implements resource::DataStream.

References mData, mEnd, and mPos.

void resource::MemoryDataStream::skip ( s32  offset) [virtual]

Moves the internal read pointer backwards or forwards by the number of bytes specified. The sign of the parameter determines the direction of the skip.

Implements resource::DataStream.

References mData, mEnd, and mPos.

u32 resource::MemoryDataStream::skipLine ( const std::string &  delim = "\n") [virtual]

Skip a single line from the stream.

Reimplemented from resource::DataStream.

References mEnd, and mPos.

u32 resource::MemoryDataStream::tell ( ) const [virtual]

Returns the current byte offset from beginning.

Implements resource::DataStream.

References mData, and mPos.


Member Data Documentation

Referenced by close(), and MemoryDataStream().


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

The KG Game Engine
The KG Game Engine Documentation © 2006-2011 by Kat'Oun. Generated on Sat Jul 2 2011 00:50:09 by Doxygen (1.7.4)