This represents a stream to a buffer in memory. More...
#include <memorystream.h>
Public Member Functions | |
MemoryStream (const size_t &BufferSize, bool FreeOnClose=true, bool ReadOnly=false) | |
Buffer creation constructor. More... | |
MemoryStream (void *Buffer, const size_t &BufferSize, bool FreeOnClose=false, bool ReadOnly=false) | |
Pre-made buffer constructor. More... | |
virtual | ~MemoryStream () |
Class destructor. | |
virtual void | Advance (const StreamOff Count) |
Advances the position in the stream. More... | |
virtual void | Close () |
Closes the stream to the resource. More... | |
virtual bool | EoF () const |
Gets whether or not the current position is at the end of the file/stream. More... | |
UInt8 * | GetBufferEnd () const |
Gets a pointer to the end of the memory buffer used by this stream. More... | |
UInt8 * | GetBufferPosition () const |
Gets a pointer to the current position in the memory buffer used by this stream. More... | |
UInt8 * | GetBufferStart () const |
Gets a pointer to the start of the memory buffer used by this stream. More... | |
virtual StreamPos | GetStreamPosition (bool Read=true) |
Gets the current position in this stream. (bool Read = true) More... | |
virtual size_t | Read (void *Buffer, const size_t &Count) |
Reads data from the stream, copying to a buffer. More... | |
virtual size_t | ReadLine (Char8 *Buffer, size_t MaxCount, const String &Delim="\n") |
Reads a single line from a string. (Char8* Buffer, size_t MaxCount, const String& Delim = "\n") More... | |
void | SetFreeOnClose (bool FreeOnClose) |
Sets whether or not you want this stream to free the memory buffer when it closes. 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 size_t | SkipLine (const String &Delim="\n") |
Moves the current position to the start of the next line. (const String& Delim = "\n") More... | |
virtual size_t | Write (const void *Buffer, const size_t &Count) |
Writes data from the stream, copying from the provided buffer. More... | |
Public Member Functions inherited from Mezzanine::Resource::DataStream | |
DataStream (const UInt16 Flags=SF_Read) | |
Class constructor. More... | |
virtual | ~DataStream () |
Class destructor. | |
virtual String | GetAsString () |
Gets the contents of the stream as a string. More... | |
virtual String | GetLine (bool Trim=true) |
Gets the contents of the current line in the stream. More... | |
virtual StreamSize | GetSize () const |
Gets the size of the stream. More... | |
virtual bool | IsReadable () const |
Gets whether this stream can be read. More... | |
virtual bool | IsWriteable () const |
Gets whether this stream can be written to. More... | |
Protected Attributes | |
UInt8 * | BufferEnd |
UInt8 * | BufferPos |
UInt8 * | BufferStart |
bool | FreeBuffer |
Protected Attributes inherited from Mezzanine::Resource::DataStream | |
UInt16 | SFlags |
The type of access this stream has to the resource. | |
StreamSize | Size |
The size of the stream. | |
Additional Inherited Members | |
Public Types inherited from Mezzanine::Resource::DataStream | |
enum | SeekOrigin { SO_Beginning = std::ios_base::beg, SO_Current = std::ios_base::cur, SO_End = std::ios_base::end } |
An enum describing which position should be considered the origin for changing the current position in a stream. More... | |
enum | StreamFlags { SF_None = 0, SF_Read = 1, SF_Write = 2, SF_Append = 4, SF_AtEnd = 8, SF_Binary = 16, SF_Truncate = 32 } |
This enum describes the flags that control certain behaviors of a stream. More... | |
This represents a stream to a buffer in memory.
Definition at line 59 of file memorystream.h.
Mezzanine::Resource::MemoryStream::MemoryStream | ( | const size_t & | BufferSize, |
bool | FreeOnClose = true , |
||
bool | ReadOnly = false |
||
) |
Buffer creation constructor.
BufferSize | The size of the buffer to be created. |
FreeOnClose | If true this will delete the memory buffer when the stream is closed. |
ReadOnly | If true, writing operations on this stream will be prohibited. |
Definition at line 57 of file memorystream.cpp.
Mezzanine::Resource::MemoryStream::MemoryStream | ( | void * | Buffer, |
const size_t & | BufferSize, | ||
bool | FreeOnClose = false , |
||
bool | ReadOnly = false |
||
) |
Pre-made buffer constructor.
Buffer | The premade buffer to stream from. |
BufferSize | The size of the buffer to stream to/from. |
FreeOnClose | If true this will delete the memory buffer when the stream is closed. |
ReadOnly | If true, writing operations on this stream will be prohibited. |
Definition at line 70 of file memorystream.cpp.
|
virtual |
Advances the position in the stream.
Count | The number of bytes to skip/advance in the stream from the current position. |
Implements Mezzanine::Resource::DataStream.
Definition at line 146 of file memorystream.cpp.
|
virtual |
Closes the stream to the resource.
Implements Mezzanine::Resource::DataStream.
Definition at line 201 of file memorystream.cpp.
|
virtual |
Gets whether or not the current position is at the end of the file/stream.
Implements Mezzanine::Resource::DataStream.
Definition at line 196 of file memorystream.cpp.
UInt8 * Mezzanine::Resource::MemoryStream::GetBufferEnd | ( | ) | const |
Gets a pointer to the end of the memory buffer used by this stream.
Definition at line 100 of file memorystream.cpp.
UInt8 * Mezzanine::Resource::MemoryStream::GetBufferPosition | ( | ) | const |
Gets a pointer to the current position in the memory buffer used by this stream.
Definition at line 95 of file memorystream.cpp.
UInt8 * Mezzanine::Resource::MemoryStream::GetBufferStart | ( | ) | const |
Gets a pointer to the start of the memory buffer used by this stream.
Definition at line 90 of file memorystream.cpp.
|
virtual |
Gets the current position in this stream. (bool Read = true)
Read | Whether or not to get the Read position. If false this will get the write position instead. |
(bool Read = true)
Implements Mezzanine::Resource::DataStream.
Definition at line 191 of file memorystream.cpp.
|
virtual |
Reads data from the stream, copying to a buffer.
Buffer | The buffer to place data from the stream. |
Count | The number of bytes to read from the stream. |
Implements Mezzanine::Resource::DataStream.
Definition at line 113 of file memorystream.cpp.
|
virtual |
Reads a single line from a string. (Char8* Buffer, size_t MaxCount, const String& Delim = "\n")
Buffer | Pointer to the buffer to copy to. |
MaxCount | The maximum number of bytes to read. Usually you want this to be your buffer size. |
Delim | The character that marks the end of a line. |
(Char8* Buffer, size_t MaxCount, const String& Delim = "\n")
Reimplemented from Mezzanine::Resource::DataStream.
Definition at line 215 of file memorystream.cpp.
void Mezzanine::Resource::MemoryStream::SetFreeOnClose | ( | bool | FreeOnClose) |
Sets whether or not you want this stream to free the memory buffer when it closes.
True | if you want this stream to free the buffer when it closes, false if you want it preserved. |
Definition at line 105 of file memorystream.cpp.
|
virtual |
Sets the position of the read and write cursors explicitly.
Position | The position to be set. |
Implements Mezzanine::Resource::DataStream.
Definition at line 155 of file memorystream.cpp.
|
virtual |
Sets the position of the read and write cursors.
Offset | The number of bytes to move the cursors back(if negative) or forward(if positive). |
Origin | The starting point to be considered for the offset. |
Implements Mezzanine::Resource::DataStream.
Definition at line 163 of file memorystream.cpp.
|
virtual |
Moves the current position to the start of the next line. (const String& Delim = "\n")
Delim | The character that marks the end of a line. |
(const String& Delim = "\n")
Reimplemented from Mezzanine::Resource::DataStream.
Definition at line 242 of file memorystream.cpp.
|
virtual |
Writes data from the stream, copying from the provided buffer.
Buffer | The buffer of data to be written. |
Count | The number of bytes to write from the buffer to the stream. |
Implements Mezzanine::Resource::DataStream.
Definition at line 129 of file memorystream.cpp.