![]() |
Libftpp
A modern C++ library
|
RingBuffer class for managing a circular buffer of bytes. It provides methods to push and pop bytes, check buffer status, and retrieve buffer capacity and size. RingBuffer is a FIFO data structure The buffer operates in a circular manner, allowing efficient use of space. More...
#include <ring_buffer.hpp>
Public Member Functions | |
| RingBuffer () | |
| RingBuffer (const size_t &size_buffer) | |
| void | push (const unsigned char &byte) |
| void | push (const std::string &line) |
| void | push (const std::vector< unsigned char > &bytes) |
| void | pushInto (const void *data, const size_t &size) |
| unsigned char | pop () |
| std::vector< unsigned char > | pop (const size_t &size) |
| void | popInto (void *data, const size_t &size) |
| unsigned char | peek () const |
| std::vector< unsigned char > | peek (const size_t &size) const |
| void | clear () |
| bool | isEmpty () const |
| bool | isFull () const |
| size_t | size () const |
| size_t | capacity () const |
| size_t | capacityAvailable () const |
RingBuffer class for managing a circular buffer of bytes. It provides methods to push and pop bytes, check buffer status, and retrieve buffer capacity and size. RingBuffer is a FIFO data structure The buffer operates in a circular manner, allowing efficient use of space.
| std::out_of_range | when trying to push to a full buffer or pop from an empty buffer. |
Definition at line 42 of file ring_buffer.hpp.
| RingBuffer::RingBuffer | ( | ) |
Definition at line 3 of file ring_buffer.cpp.
| RingBuffer::RingBuffer | ( | const size_t & | size_buffer | ) |
Definition at line 4 of file ring_buffer.cpp.
| size_t RingBuffer::capacity | ( | ) | const |
Definition at line 146 of file ring_buffer.cpp.
| size_t RingBuffer::capacityAvailable | ( | ) | const |
Definition at line 151 of file ring_buffer.cpp.
Referenced by pushInto().
| void RingBuffer::clear | ( | ) |
Definition at line 156 of file ring_buffer.cpp.
| bool RingBuffer::isEmpty | ( | ) | const |
Definition at line 131 of file ring_buffer.cpp.
| bool RingBuffer::isFull | ( | ) | const |
Definition at line 136 of file ring_buffer.cpp.
Referenced by push().
| unsigned char RingBuffer::peek | ( | ) | const |
Definition at line 101 of file ring_buffer.cpp.
References isEmpty().
| std::vector< unsigned char > RingBuffer::peek | ( | const size_t & | size | ) | const |
Definition at line 111 of file ring_buffer.cpp.
| unsigned char RingBuffer::pop | ( | ) |
Definition at line 44 of file ring_buffer.cpp.
References isEmpty().
| std::vector< unsigned char > RingBuffer::pop | ( | const size_t & | size | ) |
Definition at line 57 of file ring_buffer.cpp.
References size().
| void RingBuffer::popInto | ( | void * | data, |
| const size_t & | size | ||
| ) |
Definition at line 87 of file ring_buffer.cpp.
References size().
| void RingBuffer::push | ( | const std::string & | line | ) |
Definition at line 9 of file ring_buffer.cpp.
| void RingBuffer::push | ( | const std::vector< unsigned char > & | bytes | ) |
Definition at line 28 of file ring_buffer.cpp.
References isFull().
| void RingBuffer::push | ( | const unsigned char & | byte | ) |
| void RingBuffer::pushInto | ( | const void * | data, |
| const size_t & | size | ||
| ) |
Definition at line 73 of file ring_buffer.cpp.
References capacityAvailable(), and size().
| size_t RingBuffer::size | ( | ) | const |
Definition at line 141 of file ring_buffer.cpp.
Referenced by peek(), pop(), popInto(), and pushInto().