3 #include "IO/Buffer/Buffer.h"
62 if (!this->m_pBuffer) {
63 throw NoBufferException;
75 const char *
buffer()
const override {
return this->m_pBuffer; }
79 char *
rawBuffer()
const override {
return this->m_pBuffer; }
83 [[nodiscard]]
size_t size()
const override {
return this->m_nSize; }
87 [[nodiscard]]
size_t allocatedSize()
const {
return this->m_nAllocatedSize; }
95 if (this->checkBuffer(); i_nIndex > this->m_nSize) {
96 throw IndexOutOfRangeException;
98 return this->m_pBuffer[i_nIndex];
105 this->m_nAllocatedSize = i_oOther.m_nAllocatedSize;
106 this->m_pBuffer =
new char[this->m_nAllocatedSize];
107 this->m_nSize = i_oOther.m_nSize;
108 memcpy(this->m_pBuffer, i_oOther.m_pBuffer, this->m_nSize);
115 this->m_pBuffer = i_oOther.m_pBuffer;
116 this->m_nSize = i_oOther.m_nSize;
117 this->m_nAllocatedSize = i_oOther.m_nAllocatedSize;
118 i_oOther.m_pBuffer =
nullptr;
119 i_oOther.m_nSize = 0;
120 i_oOther.m_nAllocatedSize = 0;
134 size_t m_nAllocatedSize;
A dynamic implementation of the IBuffer interface.
Definition: DynamicBuffer.h:27
void operator=(CDynamicBuffer &&i_oOther) noexcept
Move assignment operator.
Definition: DynamicBuffer.h:114
CDynamicBuffer()
Default constructor.
Definition: DynamicBuffer.cpp:3
char * rawBuffer() const override
Get a mutable pointer to the start of the buffer.
Definition: DynamicBuffer.h:79
size_t allocatedSize() const
Get the total allocated size of the buffer.
Definition: DynamicBuffer.h:87
const char & operator[](const size_t i_nIndex)
Array access operator.
Definition: DynamicBuffer.h:94
void operator=(const CDynamicBuffer &i_oOther)
Copy assignment operator.
Definition: DynamicBuffer.h:104
virtual ~CDynamicBuffer()
Virtual destructor.
Definition: DynamicBuffer.cpp:12
void reallocate(const size_t i_nSize)
Reallocate the buffer to a new size.
Definition: DynamicBuffer.cpp:24
CDynamicBuffer(CDynamicBuffer &&i_oOther) noexcept
Move constructor.
Definition: DynamicBuffer.h:44
size_t size() const override
Get the size of the buffer.
Definition: DynamicBuffer.h:83
CDynamicBuffer(const CDynamicBuffer &i_oOther)
Copy constructor.
Definition: DynamicBuffer.h:38
const char * buffer() const override
Get a constant pointer to the start of the buffer.
Definition: DynamicBuffer.h:75
An interface for working with byte buffers.
Definition: Buffer.h:49
The namespace encapsulating I/O related classes and functions in the Devel framework.