mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Initial checkin
This commit is contained in:
parent
c74712dad9
commit
078564ac9e
3242 changed files with 1616395 additions and 0 deletions
45
BeefySysLib/util/ChunkedDataBuffer.h
Normal file
45
BeefySysLib/util/ChunkedDataBuffer.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
#pragma once
|
||||
|
||||
#include "../Common.h"
|
||||
|
||||
NS_BF_BEGIN;
|
||||
|
||||
class DataStream;
|
||||
|
||||
class ChunkedDataBuffer
|
||||
{
|
||||
public:
|
||||
static const int ALLOC_SIZE = 0x1000;
|
||||
|
||||
public:
|
||||
Array<uint8*> mPools;
|
||||
uint8* mWriteCurAlloc;
|
||||
uint8* mWriteCurPtr;
|
||||
uint8* mReadCurAlloc;
|
||||
uint8* mReadCurPtr;
|
||||
uint8* mReadNextAlloc;
|
||||
int mReadPoolIdx;
|
||||
int mSize;
|
||||
static int sBlocksAllocated;
|
||||
|
||||
public:
|
||||
ChunkedDataBuffer();
|
||||
~ChunkedDataBuffer();
|
||||
|
||||
void InitFlatRef(void* ptr, int size);
|
||||
void Clear();
|
||||
int GetSize();
|
||||
void GrowPool();
|
||||
void Write(const void* data, int size);
|
||||
void Write(uint8 byte);
|
||||
int GetReadPos();
|
||||
void SetReadPos(int pos);
|
||||
void NextReadPool();
|
||||
void Read(void* data, int size);
|
||||
void* FastRead(void* data, int size); // Can either return pointer into the stream or read data, depending on if the read crosses a chunk
|
||||
uint8 Read();
|
||||
|
||||
void Read(DataStream& stream, int size);
|
||||
};
|
||||
|
||||
NS_BF_END;
|
Loading…
Add table
Add a link
Reference in a new issue