AudioDataLib
A C++ library of classes supporting a variety of audio-data tasks.
Loading...
Searching...
No Matches
AudioDataLib::ByteStream Class Referenceabstract

This is the base class for all types of byte streams used in the library. More...

#include <ByteStream.h>

Inheritance diagram for AudioDataLib::ByteStream:
AudioDataLib::AudioStream AudioDataLib::FileStream AudioDataLib::MemoryStream AudioDataLib::ReadOnlyBufferStream AudioDataLib::WriteOnlyBufferStream AudioDataLib::ThreadSafeAudioStream AudioDataLib::FileInputStream AudioDataLib::FileOutputStream

Public Member Functions

 ByteStream ()
 
virtual ~ByteStream ()
 
virtual uint64_t WriteBytesToStream (const uint8_t *buffer, uint64_t bufferSize)=0
 
virtual uint64_t ReadBytesFromStream (uint8_t *buffer, uint64_t bufferSize)=0
 
virtual uint64_t PeekBytesFromStream (uint8_t *buffer, uint64_t bufferSize)
 
virtual uint64_t GetSize () const =0
 
virtual bool CanRead ()=0
 
virtual bool CanWrite ()=0
 
template<typename T >
bool ReadType (T *value)
 
template<typename T >
bool WriteType (const T *value)
 

Detailed Description

This is the base class for all types of byte streams used in the library.

Some derivatives are read-only, write-only, or read-write. Consequently, not all interface methods are supported by all derivatives.

Constructor & Destructor Documentation

◆ ByteStream()

ByteStream::ByteStream ( )

◆ ~ByteStream()

ByteStream::~ByteStream ( )
virtual

Member Function Documentation

◆ CanRead()

virtual bool AudioDataLib::ByteStream::CanRead ( )
pure virtual

◆ CanWrite()

virtual bool AudioDataLib::ByteStream::CanWrite ( )
pure virtual

◆ GetSize()

virtual uint64_t AudioDataLib::ByteStream::GetSize ( ) const
pure virtual

◆ PeekBytesFromStream()

uint64_t ByteStream::PeekBytesFromStream ( uint8_t * buffer,
uint64_t bufferSize )
virtual

Read from this stream into the given buffer, but unlike ReadBytesFromStream, do not modify the stream. That is, a subsequent read from the stream will read from the same location.

Parameters
[out]bufferThis is a pointer to an array where bytes read from the stream will be written.
[in]bufferSizeThis is the size in bytes of the given array.
Returns
The number of bytes actually read from the stream and written to the given buffer is returned.

Reimplemented in AudioDataLib::ReadOnlyBufferStream.

◆ ReadBytesFromStream()

virtual uint64_t AudioDataLib::ByteStream::ReadBytesFromStream ( uint8_t * buffer,
uint64_t bufferSize )
pure virtual

Read from this stream into the given buffer.

Parameters
[out]bufferThis is a pointer to an array where bytes read from the stream will be written.
[in]bufferSizeThis is the size in bytes of the given array.
Returns
The number of bytes actually read from the stream and written to the given buffer is returned.

Implemented in AudioDataLib::FileInputStream, AudioDataLib::FileOutputStream, AudioDataLib::ReadOnlyBufferStream, AudioDataLib::WriteOnlyBufferStream, AudioDataLib::AudioStream, AudioDataLib::ThreadSafeAudioStream, and AudioDataLib::MemoryStream.

◆ ReadType()

template<typename T >
bool AudioDataLib::ByteStream::ReadType ( T * value)
inline

Read an amount of data from the stream equal to the size of the given type. Byte-swapping may be a consideration here. Note that a failed read could still be a partial read. In other words, the stream can get modified even if the read fails.

◆ WriteBytesToStream()

virtual uint64_t AudioDataLib::ByteStream::WriteBytesToStream ( const uint8_t * buffer,
uint64_t bufferSize )
pure virtual

Write the given buffer to this stream.

Parameters
[in]bufferThis is a pointer to the array of bytes to write to the stream.
[in]bufferSizeThis is the size of the given array in bytes.
Returns
The number of bytes actually written to the stream is returned.

Implemented in AudioDataLib::FileInputStream, AudioDataLib::FileOutputStream, AudioDataLib::ReadOnlyBufferStream, AudioDataLib::WriteOnlyBufferStream, AudioDataLib::AudioStream, AudioDataLib::ThreadSafeAudioStream, and AudioDataLib::MemoryStream.

◆ WriteType()

template<typename T >
bool AudioDataLib::ByteStream::WriteType ( const T * value)
inline

Write an amount of data to the stream equal to the size of the given type. Byte-swapping may be a consideration here. Note that a failed write could still be a partial write. In other words, the stream can get modified even if the write fails.


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