[+] The missing AuByteBuffer::ByteBuffer(const MemoryViewRead &readView, ...) constructor

This commit is contained in:
Reece Wilson 2024-06-02 00:13:56 +01:00
parent 4e7f3ed3dd
commit 3241ebb349
3 changed files with 27 additions and 3 deletions

View File

@ -123,6 +123,8 @@ namespace Aurora::Memory
*/
inline ByteBuffer(const void *in, AuUInt length, bool circular = false, bool expandable = false);
inline ByteBuffer(const MemoryViewRead &readView, bool circular = false, bool expandable = false);
inline ByteBuffer(const AuList<AuUInt8> &vector, bool circular = false, bool expandable = false);
inline ByteBuffer(AuUInt length, bool circular = false, bool expandable = false);

View File

@ -278,7 +278,24 @@ namespace Aurora::Memory
this->writePtr = this->readPtr + this->length;
AuMemcpy(this->base, in, this->length);
}
ByteBuffer::ByteBuffer(const MemoryViewRead &readView, bool circular, bool expandable) :
flagCircular(circular), flagExpandable(expandable), flagReadError(0), flagWriteError(0)
{
this->scaleSize = kBufferInitialPower;
this->base = readView.Size() ? ZAlloc<AuUInt8 *>(readView.Size()) : nullptr;
if (!this->base)
{
Reset();
return;
}
this->length = readView.Size();
this->allocSize = this->length;
this->readPtr = this->base;
this->writePtr = this->readPtr + this->length;
AuMemcpy(this->base, readView.Begin(), this->length);
}
ByteBuffer::ByteBuffer(const AuList<AuUInt8> &vector, bool circular, bool expandable) :
flagCircular(circular), flagExpandable(expandable), flagReadError(0), flagWriteError(0)
{

View File

@ -336,7 +336,12 @@ namespace Aurora::Memory
return reinterpret_cast<U8_t>(this->ptr) + this->length;
}
MemoryView AtOffset(AuUInt uOffset)
AuUInt size() const
{
return this->length;
}
MemoryView AtOffset(AuUInt uOffset) const
{
if (uOffset < this->uLength)
{
@ -350,7 +355,7 @@ namespace Aurora::Memory
}
}
MemoryView Take(AuUInt uLength)
MemoryView Take(AuUInt uLength) const
{
if (uLength <= this->uLength)
{