#pragma once
/*----------------
SendBuffer
-----------------*/
class SendBuffer : enable_shared_from_this<SendBuffer>
{
public:
SendBuffer(int32 bufferSize);
~SendBuffer();
BYTE* Buffer() { return _buffer.data(); }
int32 WriteSize() { return _writeSize; }
int32 Capacity() { return static_cast<int32>(_buffer.size()); }
void CopyData(void* data, int32 len);
private:
Vector<BYTE> _buffer;
int32 _writeSize = 0;
};
#include "pch.h"
#include "SendBuffer.h"
/*----------------
SendBuffer
-----------------*/
SendBuffer::SendBuffer(int32 bufferSize)
{
_buffer.resize(bufferSize);
}
SendBuffer::~SendBuffer()
{
}
void SendBuffer::CopyData(void* data, int32 len)
{
ASSERT_CRASH(Capacity() >= len);
::memcpy(_buffer.data(), data, len);
_writeSize = len;
}