//----------------------- GET FRAME UPTO ----------------------------- MemoryFrame MemoryFrame::getFrameUpto(const MemoryFrame &upto) { if(!this->isInside(upto.begin())) { throw GeneralException(__FUNCTION__ ": upto frame not inside this one"); } return this->getSubFrame(0, (int)upto.begin() - (int)begin()); }
//----------------------- WRITE -------------------------------------- void MemoryFrame::write(const MemoryFrame &source) { unsigned int bytes = source.size(); if(bytes > size()) bytes = size(); ::memcpy(this->begin(), source.begin(), bytes); this->skip(bytes); }
//----------------------- FROM MEMORY -------------------------------- void Buffer::fromMemory(const MemoryFrame &source) { release(); if(source.isEmpty()) { return; } setSize(source.size()); memcpy(this->bufferBase, source.begin(), this->bufferSize); }
//----------------------- APPEND MEMORY ------------------------------ void Buffer::append(const MemoryFrame &source) { int middle = this->bufferSize; this->setSize(this->bufferSize + source.size()); memcpy(this->getMemory().offset<void>(middle), source.begin(), source.size()); }