Spinning Topp Logo BlackTopp Studios
inc
Public Member Functions | Protected Attributes | List of all members
Mezzanine::Resource::MemoryStream Class Reference

An I/O stream to a buffer of memory. More...

#include <memorystream.h>

+ Inheritance diagram for Mezzanine::Resource::MemoryStream:
+ Collaboration diagram for Mezzanine::Resource::MemoryStream:

Public Member Functions

 MemoryStream ()
 Blank constructor.
 
 MemoryStream (const Whole BufferSize, const Whole Mode=Resource::SF_Read|Resource::SF_Write)
 Buffer initialization constructor. More...
 
 MemoryStream (const void *Buffer, const Whole BufferSize, const Whole Mode=Resource::SF_Read|Resource::SF_Write)
 Buffer copy constructor. More...
 
 MemoryStream (void *Buffer, const Whole BufferSize, const Boole FreeAfter, const Whole Mode=Resource::SF_Read|Resource::SF_Write)
 Buffer wrapper constructor. More...
 
virtual ~MemoryStream ()
 Class destructor.
 
void CopyBuffer (const void *Buffer, const Whole BufferSize, const Whole Mode=Resource::SF_Read|Resource::SF_Write)
 Copies a pre-existing buffer to this buffer for streaming. More...
 
void CreateBuffer (const Whole Size, const Whole Mode=Resource::SF_Read|Resource::SF_Write)
 Creates a new memory buffer to stream to/from. More...
 
Char8GetBufferEnd () const
 Gets the end of this buffer. More...
 
Char8GetBufferStart () const
 Gets the start of this buffer. More...
 
Boole GetFreeBuffer () const
 Gets if this should delete it's internal buffer when it is destroyed. More...
 
virtual StreamSize GetSize () const
 
void SetBuffer (void *Buffer, const Whole BufferSize, const Boole FreeBuf, const Whole Mode=Resource::SF_Read|Resource::SF_Write)
 Wraps an external buffer for streaming. More...
 
void SetFreeBuffer (const Boole FreeBuf)
 Sets if this should delete it's internal buffer when it is destroyed. More...
 
- Public Member Functions inherited from Mezzanine::Resource::IOStream
 IOStream (std::streambuf *Buf)
 Class constructor. More...
 
virtual ~IOStream ()
 Class destructor.
 
virtual void Advance (const StreamOff Count)
 Advances the position in the stream. More...
 
virtual Boole Bad () const
 Gets whether or not a critical error was detected in a previous operation in the stream. More...
 
virtual void ClearErrors ()
 Clears any stored error state on the stream. More...
 
virtual Boole EoF () const
 Gets whether or not the current position is at the end of the stream. More...
 
virtual Boole Fail () const
 Gets whether or not an otherwise silent and recoverable error was detected in a previous operation in the stream. More...
 
virtual String GetAsString ()
 Gets the contents of the stream as a string. More...
 
virtual String GetLine (Boole Trim=true)
 Gets the contents of the current line in the stream. More...
 
virtual StreamPos GetReadPosition ()
 Gets the current read position in this stream. More...
 
virtual StreamPos GetStreamPosition (const Boole Read=true)
 Gets the current position in this stream. More...
 
virtual StreamPos GetWritePosition ()
 Gets the current write position in this stream. More...
 
virtual Boole IsValid () const
 Gets whether or not this stream is intact and ready for operations. More...
 
virtual size_t Read (void *Buffer, StreamSize Size)
 Reads from the stream and copies that data to a buffer. More...
 
virtual size_t ReadLine (Char8 *Buffer, size_t MaxCount, const String &Delim="\n")
 Reads a single line from a string. More...
 
virtual void SetReadPosition (StreamPos Position)
 Sets the position of the read cursor explicitly. More...
 
virtual void SetReadPosition (StreamOff Offset, SeekOrigin Origin)
 Sets the position of the read cursor. More...
 
virtual void SetStreamPosition (StreamPos Position)
 Sets the position of the read and write cursors explicitly. More...
 
virtual void SetStreamPosition (StreamOff Offset, SeekOrigin Origin)
 Sets the position of the read and write cursors. More...
 
virtual void SetWritePosition (StreamPos Position)
 Sets the position of the write cursor explicitly. More...
 
virtual void SetWritePosition (StreamOff Offset, SeekOrigin Origin)
 Sets the position of the write cursor. More...
 
virtual size_t SkipLine (const String &Delim="\n")
 Moves the current position to the start of the next line. More...
 
virtual size_t Write (const void *Buffer, StreamSize Size)
 Writes data to the stream. More...
 
- Public Member Functions inherited from Mezzanine::Resource::iInStream
 iInStream ()
 Class constructor.
 
virtual ~iInStream ()
 Class destructor.
 
- Public Member Functions inherited from Mezzanine::Resource::iStreamBase
 iStreamBase ()
 Class constructor.
 
virtual ~iStreamBase ()
 Class destructor.
 
- Public Member Functions inherited from Mezzanine::Resource::iOutStream
 iOutStream ()
 Class constructor.
 
virtual ~iOutStream ()
 Class destructor.
 

Protected Attributes

MemoryStreamBuffer Buffer
 The buffer object being streamed to/from. More...
 

Detailed Description

An I/O stream to a buffer of memory.

Definition at line 222 of file memorystream.h.

Constructor & Destructor Documentation

Mezzanine::Resource::MemoryStream::MemoryStream ( const Whole  BufferSize,
const Whole  Mode = Resource::SF_Read | Resource::SF_Write 
)

Buffer initialization constructor.

Parameters
BufferSizeThe size of the buffer being wrapped.
ModeThe configuration to open the memory buffer with.

Definition at line 318 of file memorystream.cpp.

Mezzanine::Resource::MemoryStream::MemoryStream ( const void *  Buffer,
const Whole  BufferSize,
const Whole  Mode = Resource::SF_Read | Resource::SF_Write 
)

Buffer copy constructor.

Parameters
BufferSizeThe size of the buffer being wrapped.
ModeThe configuration to open the memory buffer with.

Definition at line 322 of file memorystream.cpp.

Mezzanine::Resource::MemoryStream::MemoryStream ( void *  Buffer,
const Whole  BufferSize,
const Boole  FreeAfter,
const Whole  Mode = Resource::SF_Read | Resource::SF_Write 
)

Buffer wrapper constructor.

Parameters
BufferThe buffer to be wrapped.
BufferSizeThe size of the buffer being wrapped.
FreeAfterWhether or not the buffer passed in should be deleted when this stream is destroyed.
ModeThe configuration to open the memory buffer with.

Definition at line 326 of file memorystream.cpp.

Member Function Documentation

void Mezzanine::Resource::MemoryStream::CopyBuffer ( const void *  Buffer,
const Whole  BufferSize,
const Whole  Mode = Resource::SF_Read | Resource::SF_Write 
)

Copies a pre-existing buffer to this buffer for streaming.

Parameters
BufferThe buffer to be copied.
BufferSizeThe size of the buffer to be copied.
ModeAn open mode describing if this buffer will be configured for reading, writing, or both.

Definition at line 342 of file memorystream.cpp.

void Mezzanine::Resource::MemoryStream::CreateBuffer ( const Whole  Size,
const Whole  Mode = Resource::SF_Read | Resource::SF_Write 
)

Creates a new memory buffer to stream to/from.

Remarks
No changes will be made if the Size is set to 0 or less.
Parameters
SizeThe size of the buffer to be allocated.
ModeAn open mode describing if this buffer will be configured for reading, writing, or both.

Definition at line 336 of file memorystream.cpp.

Char8 * Mezzanine::Resource::MemoryStream::GetBufferEnd ( ) const

Gets the end of this buffer.

Returns
Returns a pointer to one passed the last valid element in this buffer.

Definition at line 348 of file memorystream.cpp.

Char8 * Mezzanine::Resource::MemoryStream::GetBufferStart ( ) const

Gets the start of this buffer.

Returns
Returns a pointer to the first valid element in this buffer.

Definition at line 345 of file memorystream.cpp.

Boole Mezzanine::Resource::MemoryStream::GetFreeBuffer ( ) const

Gets if this should delete it's internal buffer when it is destroyed.

Returns
Returns true if the internal buffer will be deleted when this is destroyed.

Definition at line 354 of file memorystream.cpp.

StreamSize Mezzanine::Resource::MemoryStream::GetSize ( ) const
virtual

Implements Mezzanine::Resource::iStreamBase.

Definition at line 360 of file memorystream.cpp.

void Mezzanine::Resource::MemoryStream::SetBuffer ( void *  Buffer,
const Whole  BufferSize,
const Boole  FreeBuf,
const Whole  Mode = Resource::SF_Read | Resource::SF_Write 
)

Wraps an external buffer for streaming.

Parameters
BufferThe buffer to be wrapped.
BufferSizeThe size of the buffer being wrapped.
FreeBufWhether or not the buffer passed in should be deleted when this stream is destroyed.
ModeAn open mode describing if this buffer will be configured for reading, writing, or both.

Definition at line 339 of file memorystream.cpp.

void Mezzanine::Resource::MemoryStream::SetFreeBuffer ( const Boole  FreeBuf)

Sets if this should delete it's internal buffer when it is destroyed.

Parameters
FreeBufWhether or not the buffer passed in should be deleted when this stream is destroyed.

Definition at line 351 of file memorystream.cpp.

Member Data Documentation

MemoryStreamBuffer Mezzanine::Resource::MemoryStream::Buffer
protected

The buffer object being streamed to/from.

Definition at line 227 of file memorystream.h.


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