32#include <jsonifier/Index.hpp>
42 namespace discord_core_internal {
57 using value_type = value_type_new;
58 using pointer = value_type*;
59 using size_type = uint64_t;
72 template<typename value_type2, size_type slice_count> friend class
ring_buffer;
78 if (type == ring_buffer_access_type::read) {
122 jsonifier::vector<std::unwrap_ref_decay_t<value_type>>
arrayValue{};
130 template<
typename value_type_new, u
int64_t slice_count>
class ring_buffer
131 :
public ring_buffer_interface<ring_buffer_interface<std::unwrap_ref_decay_t<value_type_new>, 1024 * 16>, slice_count> {
135 using const_pointer =
const value_type*;
136 using pointer = value_type*;
137 using size_type = uint64_t;
150 template<typename value_type_newer>
void writeData(value_type_newer* data, size_type sizeNew) {
155 size_type writeSize{ sizeNew };
163 jsonifier::string_view_base<std::unwrap_ref_decay_t<value_type>>
readData() {
164 jsonifier::string_view_base<std::unwrap_ref_decay_t<value_type>> returnData{};
A template interface for a ring buffer.
size_type tail
The tail position in the buffer.
void clear()
Clear the buffer by resetting positions.
jsonifier::vector< std::unwrap_ref_decay_t< value_type > > arrayValue
The underlying data array.
ring_buffer_interface()
Constructor. initializes the buffer size.
void modifyReadOrWritePosition(ring_buffer_access_type type, size_type sizeNew)
Modify the read or write position of the buffer.
pointer getCurrentHead()
Get a pointer to the current head position.
size_type head
The head position in the buffer.
pointer getCurrentTail()
Get a pointer to the current tail position.
bool isItEmpty()
Check if the buffer is empty.
size_type getUsedSpace()
Get the used space in the buffer.
bool isItFull()
Check if the buffer is full.
A template implementation of a ring buffer using ring_buffer_interface.
void writeData(value_type_newer *data, size_type sizeNew)
Write data into the buffer.
jsonifier::string_view_base< std::unwrap_ref_decay_t< value_type > > readData()
Read data from the buffer.
ring_buffer() noexcept=default
Default constructor. initializes the buffer size.
ring_buffer_access_type
Enum representing different access types for a ring buffer.
The main namespace for the forward-facing interfaces.