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

Base class for streams that support both read and write operations. More...

#include <datastream.h>

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

Public Member Functions

 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.
 
virtual StreamSize GetSize () const =0
 Gets the size of the stream. More...
 
- Public Member Functions inherited from Mezzanine::Resource::iOutStream
 iOutStream ()
 Class constructor.
 
virtual ~iOutStream ()
 Class destructor.
 

Detailed Description

Base class for streams that support both read and write operations.

Definition at line 263 of file datastream.h.

Constructor & Destructor Documentation

Mezzanine::Resource::IOStream::IOStream ( std::streambuf *  Buf)

Class constructor.

Parameters
BufA pointer to the buffer that will be streamed.

Definition at line 152 of file datastream.cpp.

Member Function Documentation

void Mezzanine::Resource::IOStream::Advance ( const StreamOff  Count)
virtual

Advances the position in the stream.

Parameters
CountThe number of bytes to skip/advance in the stream from the current position.

Definition at line 216 of file datastream.cpp.

Boole Mezzanine::Resource::IOStream::Bad ( ) const
virtual

Gets whether or not a critical error was detected in a previous operation in the stream.

Returns
Returns true if a critical error has occurred and the stream integrity may be invalid, false otherwise.

Implements Mezzanine::Resource::iStreamBase.

Definition at line 165 of file datastream.cpp.

void Mezzanine::Resource::IOStream::ClearErrors ( )
virtual

Clears any stored error state on the stream.

Remarks
This is useful for non-critical errors such as ones that cause "EoF()" or "Fail()" to return true but not "Bad()". Using this to clear critical errors is not advised.

Implements Mezzanine::Resource::iStreamBase.

Definition at line 174 of file datastream.cpp.

Boole Mezzanine::Resource::IOStream::EoF ( ) const
virtual

Gets whether or not the current position is at the end of the stream.

Returns
Returns true if the current position has reached the end of the stream, false otherwise.

Implements Mezzanine::Resource::iStreamBase.

Definition at line 162 of file datastream.cpp.

Boole Mezzanine::Resource::IOStream::Fail ( ) const
virtual

Gets whether or not an otherwise silent and recoverable error was detected in a previous operation in the stream.

Returns
Returns true if a non-critical operation failed (such as seek), false otherwise.

Implements Mezzanine::Resource::iStreamBase.

Definition at line 168 of file datastream.cpp.

String Mezzanine::Resource::IOStream::GetAsString ( )
virtual

Gets the contents of the stream as a string.

Returns
Returns a string with the contents of the stream.

Definition at line 240 of file datastream.cpp.

String Mezzanine::Resource::IOStream::GetLine ( Boole  Trim = true)
virtual

Gets the contents of the current line in the stream.

Parameters
TrimWhether or not to trim whitespaces on both sides of the string.
Returns
Returns a string containing characters from the current position in the stream to the end of the line.

Definition at line 295 of file datastream.cpp.

StreamPos Mezzanine::Resource::IOStream::GetReadPosition ( )
virtual

Gets the current read position in this stream.

Returns
Returns a StreamPos representing the current read position.

Implements Mezzanine::Resource::iInStream.

Definition at line 192 of file datastream.cpp.

StreamPos Mezzanine::Resource::IOStream::GetStreamPosition ( const Boole  Read = true)
virtual

Gets the current position in this stream.

Parameters
ReadWhether or not to get the Read position. If false this will get the write position instead.
Returns
Returns a StreamPos representing the current position specified from the beginning of the stream.

Definition at line 231 of file datastream.cpp.

StreamPos Mezzanine::Resource::IOStream::GetWritePosition ( )
virtual

Gets the current write position in this stream.

Returns
Returns a StreamPos representing the current write position.

Implements Mezzanine::Resource::iOutStream.

Definition at line 210 of file datastream.cpp.

Boole Mezzanine::Resource::IOStream::IsValid ( ) const
virtual

Gets whether or not this stream is intact and ready for operations.

Returns
Returns true if no failures have been detected, false otherwise.

Implements Mezzanine::Resource::iStreamBase.

Definition at line 171 of file datastream.cpp.

size_t Mezzanine::Resource::IOStream::Read ( void *  Buffer,
StreamSize  Size 
)
virtual

Reads from the stream and copies that data to a buffer.

Parameters
BufferThe buffer to be populated with the read data.
SizeThe number of bytes to read from the stream.
Returns
Returns the number of bytes successfully read.

Implements Mezzanine::Resource::iInStream.

Definition at line 180 of file datastream.cpp.

size_t Mezzanine::Resource::IOStream::ReadLine ( Char8 Buffer,
size_t  MaxCount,
const String Delim = "\n" 
)
virtual

Reads a single line from a string.

Parameters
BufferPointer to the buffer to copy to.
MaxCountThe maximum number of bytes to read. Usually you want this to be your buffer size.
DelimThe character that marks the end of a line.
Returns
Returns the number of bytes actually read, not including the Delimiter.

Definition at line 256 of file datastream.cpp.

void Mezzanine::Resource::IOStream::SetReadPosition ( StreamPos  Position)
virtual

Sets the position of the read cursor explicitly.

Parameters
PositionThe position to be set.

Implements Mezzanine::Resource::iInStream.

Definition at line 186 of file datastream.cpp.

void Mezzanine::Resource::IOStream::SetReadPosition ( StreamOff  Offset,
SeekOrigin  Origin 
)
virtual

Sets the position of the read cursor.

Parameters
OffsetThe number of bytes to move the read cursor back(if negative) or forward(if positive).
OriginThe starting point to be considered for the offset.

Implements Mezzanine::Resource::iInStream.

Definition at line 189 of file datastream.cpp.

void Mezzanine::Resource::IOStream::SetStreamPosition ( StreamPos  Position)
virtual

Sets the position of the read and write cursors explicitly.

Parameters
PositionThe position to be set.

Definition at line 219 of file datastream.cpp.

void Mezzanine::Resource::IOStream::SetStreamPosition ( StreamOff  Offset,
SeekOrigin  Origin 
)
virtual

Sets the position of the read and write cursors.

Parameters
OffsetThe number of bytes to move the cursors back(if negative) or forward(if positive).
OriginThe starting point to be considered for the offset.

Definition at line 225 of file datastream.cpp.

void Mezzanine::Resource::IOStream::SetWritePosition ( StreamPos  Position)
virtual

Sets the position of the write cursor explicitly.

Parameters
PositionThe position to be set.

Implements Mezzanine::Resource::iOutStream.

Definition at line 204 of file datastream.cpp.

void Mezzanine::Resource::IOStream::SetWritePosition ( StreamOff  Offset,
SeekOrigin  Origin 
)
virtual

Sets the position of the write cursor.

Parameters
OffsetThe number of bytes to move the write cursor back(if negative) or forward(if positive).
OriginThe starting point to be considered for the offset.

Implements Mezzanine::Resource::iOutStream.

Definition at line 207 of file datastream.cpp.

size_t Mezzanine::Resource::IOStream::SkipLine ( const String Delim = "\n")
virtual

Moves the current position to the start of the next line.

Parameters
DelimThe character that marks the end of a line.
Returns
Returns the number of bytes skipped.

Definition at line 328 of file datastream.cpp.

size_t Mezzanine::Resource::IOStream::Write ( const void *  Buffer,
StreamSize  Size 
)
virtual

Writes data to the stream.

Parameters
BufferThe memory buffer to write to this stream.
SizeThe size of the buffer being passed in.
Returns
Returns the number of bytes successfully written.

Implements Mezzanine::Resource::iOutStream.

Definition at line 198 of file datastream.cpp.


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