CyberEngineMkIII
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Types | Public Member Functions | List of all members
CYB::API::Stream Class Referenceabstract

The interface for streaming reads and writes. More...

#include <Stream.hpp>

Inheritance diagram for CYB::API::Stream:
Inheritance graph
[legend]

Public Types

enum  Mode : byte { Mode::READ = 1, Mode::WRITE, Mode::READ_WRITE }
 The available operations for the Stream. Bitset. More...
 
enum  SeekLocation { SeekLocation::BEGIN, SeekLocation::CURSOR, SeekLocation::END }
 The location to begin a seek operation at. More...
 

Public Member Functions

virtual void Capabilities (Mode &AMode, bool &ASeek) const noexcept=0
 Get the capabilities of the stream. More...
 
virtual unsigned long long CursorPosition (void) const =0
 Get the current position of the read/write cursor in the Stream. Equivalent of Seek(0, SeekLocation::CURSOR) More...
 
virtual unsigned long long Seek (const long long AOffset, const SeekLocation ALocation) const =0
 Set the cursor position in the Stream. More...
 
virtual unsigned long long Read (void *const ABuffer, const unsigned long long AMaxAmount) const =0
 Read data from a Stream at the current cursor position and advance the cursor by that amount. More...
 
virtual unsigned long long Write (const void *const ABuffer, const unsigned long long AAmount)=0
 Write data to the Stream at the current cursor position and advance the cursor by that amount. More...
 

Detailed Description

The interface for streaming reads and writes.

Definition at line 7 of file Stream.hpp.

Member Enumeration Documentation

The available operations for the Stream. Bitset.

Enumerator
READ 

Read only mode.

WRITE 

Write only mode.

READ_WRITE 

Read write mode.

Definition at line 10 of file Stream.hpp.

10  : byte {
11  READ = 1,
12  WRITE,
13  READ_WRITE,
14  };
unsigned char byte
It's a byte, 8 bits, etc...
Definition: Types.hpp:4

The location to begin a seek operation at.

Enumerator
BEGIN 

Seek from the beginning of the Stream.

CURSOR 

Seek from the cursor position.

END 

Seek from the end of the Stream.

Definition at line 16 of file Stream.hpp.

16  {
17  BEGIN,
18  CURSOR,
19  END,
20  };

Member Function Documentation

virtual void CYB::API::Stream::Capabilities ( Mode AMode,
bool &  ASeek 
) const
pure virtualnoexcept

Get the capabilities of the stream.

Parameters
[out]AModeReturns the Mode of the Stream
[out]ASeekReturns true if the stream is seekable, false otherwise
Thread Safety
This function requires no thread safety
virtual unsigned long long CYB::API::Stream::CursorPosition ( void  ) const
pure virtual

Get the current position of the read/write cursor in the Stream. Equivalent of Seek(0, SeekLocation::CURSOR)

Returns
The current position of the cursor in the Stream
Thread Safety
This function requires synchronization at the object level
Exceptions
CYB::Exception::ViolationError code: CYB::Exception::Violation::INVALID_OPERATION. Thrown if the Stream cannot be seeked

Implemented in CYB::API::SafeStream, CYB::Platform::System::File, and CYB::API::File.

virtual unsigned long long CYB::API::Stream::Read ( void *const  ABuffer,
const unsigned long long  AMaxAmount 
) const
pure virtual

Read data from a Stream at the current cursor position and advance the cursor by that amount.

Parameters
[out]ABufferThe location to store the read data
AMaxAmountThe maximum number of bytes to be read
Returns
The number of bytes read. If zero is returned and the cursor position is not SeekLocation::END an error has occurred. If the return value does not equal AMaxAmount, assume the underlying medium is currently out of readable data
Thread Safety
This function requires synchronization at the object level
Exceptions
CYB::Exception::ViolationError code: CYB::Exception::Violation::INVALID_OPERATION. Thrown if the Stream mode is Mode::WRITE

Implemented in CYB::API::SafeStream, and CYB::Platform::System::File.

virtual unsigned long long CYB::API::Stream::Seek ( const long long  AOffset,
const SeekLocation  ALocation 
) const
pure virtual

Set the cursor position in the Stream.

Parameters
AOffsetThe offset from ALocation to set the cursor to
ALocationThe initial location to begin the offset
Returns
The current cursor position
Thread Safety
This function requires synchronization at the object level
Exceptions
CYB::Exception::SystemDataError code: CYB::Exception::SystemData::STREAM_NOT_READABLE. Thrown if an error occurs during the seek
CYB::Exception::ViolationError code: CYB::Exception::Violation::INVALID_ENUM. Thrown if ALocation is invalid
CYB::Exception::ViolationError code: CYB::Exception::Violation::INVALID_OPERATION. Thrown if the Stream cannot be seeked

Implemented in CYB::API::SafeStream, and CYB::Platform::System::File.

virtual unsigned long long CYB::API::Stream::Write ( const void *const  ABuffer,
const unsigned long long  AAmount 
)
pure virtual

Write data to the Stream at the current cursor position and advance the cursor by that amount.

Parameters
ABufferThe location to get the data to write
AAmountThe number of bytes to be written
Returns
The number of bytes written. If zero is returned, an error has occurred. If the return value does not equal AMaxAmount, assume the underlying medium is currently out of space
Thread Safety
This function requires synchronization at the object level
Exceptions
CYB::Exception::ViolationError code: CYB::Exception::Violation::INVALID_OPERATION. Thrown if the Stream mode is Mode::READ

Implemented in CYB::API::SafeStream, and CYB::Platform::System::File.


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