This represents a stream to a piece of data, usually a file. More...
#include <datastream.h>
Public Types | |
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... | |
Public Member Functions | |
DataStream (const UInt16 Flags=SF_Read) | |
Class constructor. More... | |
virtual | ~DataStream () |
Class destructor. | |
virtual void | Advance (const StreamOff Count)=0 |
Advances the position in the stream. More... | |
virtual void | Close ()=0 |
Closes the stream to the resource. | |
virtual bool | EoF () const =0 |
Gets whether or not the current position is at the end of the file/stream. More... | |
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 StreamPos | GetStreamPosition (bool Read=true)=0 |
Gets the current position in this 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... | |
virtual size_t | Read (void *Buffer, const size_t &Count)=0 |
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. More... | |
virtual void | SetStreamPosition (StreamPos Position)=0 |
Sets the position of the read and write cursors explicitly. More... | |
virtual void | SetStreamPosition (StreamOff Offset, SeekOrigin Origin)=0 |
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. More... | |
virtual size_t | Write (const void *Buffer, const size_t &Count)=0 |
Writes data from the stream, copying from the provided buffer. More... | |
Protected Attributes | |
UInt16 | SFlags |
The type of access this stream has to the resource. | |
StreamSize | Size |
The size of the stream. | |
This represents a stream to a piece of data, usually a file.
This is a base class that can be overriden to read from a variey of sources including data in memory, and archive files.
Definition at line 214 of file datastream.h.
An enum describing which position should be considered the origin for changing the current position in a stream.
Enumerator | |
---|---|
SO_Beginning |
The beginning of the stream. |
SO_Current |
The current position for read/write operations in the stream. |
SO_End |
The end of the stream. |
Definition at line 233 of file datastream.h.
This enum describes the flags that control certain behaviors of a stream.
It is important to note that not all of these flags are used by all streams.
Definition at line 220 of file datastream.h.
Class constructor.
Flags | The flags to use when initializing the stream. |
Definition at line 84 of file datastream.cpp.
|
pure virtual |
Advances the position in the stream.
Count | The number of bytes to skip/advance in the stream from the current position. |
Implemented in Mezzanine::Resource::MemoryStream, and Mezzanine::Resource::FileStream.
|
pure virtual |
Gets whether or not the current position is at the end of the file/stream.
Implemented in Mezzanine::Resource::MemoryStream, and Mezzanine::Resource::FileStream.
|
virtual |
Gets the contents of the stream as a string.
Definition at line 118 of file datastream.cpp.
|
virtual |
Gets the contents of the current line in the stream.
Trim | Whether or not to trim whitespaces on both sides of the string. |
Definition at line 178 of file datastream.cpp.
|
virtual |
Gets the size of the stream.
Definition at line 97 of file datastream.cpp.
|
pure virtual |
Gets the current position in this stream.
Read | Whether or not to get the Read position. If false this will get the write position instead. |
Implemented in Mezzanine::Resource::MemoryStream, and Mezzanine::Resource::FileStream.
|
virtual |
Gets whether this stream can be read.
Definition at line 102 of file datastream.cpp.
|
virtual |
Gets whether this stream can be written to.
Definition at line 107 of file datastream.cpp.
|
pure 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. |
Implemented in Mezzanine::Resource::MemoryStream, and Mezzanine::Resource::FileStream.
|
virtual |
Reads a single line from a string.
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. |
Reimplemented in Mezzanine::Resource::MemoryStream.
Definition at line 134 of file datastream.cpp.
|
pure virtual |
Sets the position of the read and write cursors explicitly.
Position | The position to be set. |
Implemented in Mezzanine::Resource::MemoryStream, and Mezzanine::Resource::FileStream.
|
pure 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. |
Implemented in Mezzanine::Resource::MemoryStream, and Mezzanine::Resource::FileStream.
|
virtual |
Moves the current position to the start of the next line.
Delim | The character that marks the end of a line. |
Reimplemented in Mezzanine::Resource::MemoryStream.
Definition at line 215 of file datastream.cpp.
|
pure 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. |
Implemented in Mezzanine::Resource::MemoryStream, and Mezzanine::Resource::FileStream.