8 if (v_size == 0)
throw BufferException(
"Zero size requested");
21 _init(v_size, v_padding);
27 _init(v_size, v_padding);
28 if (this->
content && v_content) {
29 ::memcpy(this->
content, v_content, v_size);
36 if (!v_parent)
throw BufferException(
"Cannot make subBuffer for NULL buffer!");
41 bufsize_t copySize = v_size < parentSize ? v_size : parentSize;
42 bufsize_t allocSize = v_size > parentSize ? v_size : parentSize;
44 BYTE *bContent = v_parent->
getContentAt(v_offset, copySize);
45 if (!bContent)
throw BufferException(
"Cannot make Buffer for NULL content!");
47 _init(v_size, v_padding);
48 if (this->
content && bContent) {
49 ::memcpy(this->
content, bContent, v_size);
58 const bufsize_t allocSize = v_size + v_padding;
61 BYTE*
content =
reinterpret_cast<BYTE*
>(::realloc((
void*)this->content, allocSize));
63 throw BufferException(
"Cannot allocate buffer of size: 0x" + QString::number(allocSize, 16));
76 BYTE *newContent =
nullptr;
const bufsize_t BUFSIZE_MAX
virtual bufsize_t getContentSize()=0
virtual BYTE * getContentAt(offset_t offset, bufsize_t size, bool allowExceptions=false)
ByteBuffer(bufsize_t v_size, bufsize_t padding=DEFAULT_PADDING)
BYTE * allocContent(bufsize_t v_size, bufsize_t padding)
virtual bool resize(bufsize_t newSize)