OS  v1.7.5
Documentation
Loading...
Searching...
No Matches
qOS::byteBuffer Class Reference

A Byte-sized buffer object. More...

#include <bytebuffer.hpp>

Public Member Functions

 byteBuffer (volatile byte_t *pBuffer, const size_t bLength)
 Initialize the Byte-sized buffer instance.
 
template<size_t numberOfBytes>
 byteBuffer (volatile byte_t(&area)[numberOfBytes]) noexcept
 
bool setup (volatile byte_t *pBuffer, const size_t bLength) noexcept
 Initialize the Byte-sized buffer.
 
template<size_t numberOfBytes>
bool setup (volatile byte_t(&area)[numberOfBytes]) noexcept
 
bool put (const byte_t bData) noexcept
 Adds an element of data to the Byte-sized buffer.
 
bool read (void *dst, const size_t n) noexcept
 Gets n data from the Byte-sized buffer and removes them.
 
bool get (byte_t *dst) noexcept
 Gets one data-byte from the front of the Byte-sized buffer, and removes it.
 
byte_t peek (void) const noexcept
 Looks for one byte from the head of the Byte-sized buffer without removing it.
 
bool isEmpty (void) const noexcept
 Query the empty status of the Byte-sized buffer.
 
bool isFull (void) const noexcept
 Query the full status of the Byte-sized buffer.
 
size_t count (void) const noexcept
 Query the number of elements in the Byte-sized buffer.
 

Detailed Description

A Byte-sized buffer object.

Constructor & Destructor Documentation

◆ byteBuffer() [1/2]

qOS::byteBuffer::byteBuffer ( volatile byte_t * pBuffer,
const size_t bLength )
inline

Initialize the Byte-sized buffer instance.

Parameters
[in]pBufferBlock of memory or array of data
[in]bLengthThe size of the buffer(Must be a power of two)

◆ byteBuffer() [2/2]

template<size_t numberOfBytes>
qOS::byteBuffer::byteBuffer ( volatile byte_t(&) area[numberOfBytes])
inlinenoexcept

Member Function Documentation

◆ count()

size_t qOS::byteBuffer::count ( void ) const
noexcept

Query the number of elements in the Byte-sized buffer.

Returns
Number of elements in the byte-sized Buffer.

◆ get()

bool qOS::byteBuffer::get ( byte_t * dst)
noexcept

Gets one data-byte from the front of the Byte-sized buffer, and removes it.

Parameters
[out]dstthe location where the data-byte will be written
Returns
true on success, otherwise returns false

◆ isEmpty()

bool qOS::byteBuffer::isEmpty ( void ) const
noexcept

Query the empty status of the Byte-sized buffer.

Returns
true if the Byte-sized buffer is empty, false if it is not.

◆ isFull()

bool qOS::byteBuffer::isFull ( void ) const
noexcept

Query the full status of the Byte-sized buffer.

Returns
true if the Byte-sized buffer is empty, false if it is not.

◆ peek()

byte_t qOS::byteBuffer::peek ( void ) const
noexcept

Looks for one byte from the head of the Byte-sized buffer without removing it.

Returns
byte of data, or zero if nothing in the list

◆ put()

bool qOS::byteBuffer::put ( const byte_t bData)
noexcept

Adds an element of data to the Byte-sized buffer.

Parameters
[in]bDataThe data to be added
Returns
true on success, otherwise returns false.

◆ read()

bool qOS::byteBuffer::read ( void * dst,
const size_t n )
noexcept

Gets n data from the Byte-sized buffer and removes them.

Parameters
[out]dstthe location where the data-byte will be written
[in]nThe number of bytes to read
Returns
true on success, otherwise returns false

◆ setup() [1/2]

bool qOS::byteBuffer::setup ( volatile byte_t * pBuffer,
const size_t bLength )
noexcept

Initialize the Byte-sized buffer.

Parameters
[in]pBufferBlock of memory or array of data
[in]bLengthThe size of the buffer(Must be a power of two)
Returns
true on success, otherwise returns false.

◆ setup() [2/2]

template<size_t numberOfBytes>
bool qOS::byteBuffer::setup ( volatile byte_t(&) area[numberOfBytes])
inlinenoexcept