first pass at basic buffer functionality
This commit is contained in:
19
Buffer.h
19
Buffer.h
@@ -10,20 +10,33 @@
|
||||
|
||||
namespace kge {
|
||||
|
||||
|
||||
class Buffer {
|
||||
public:
|
||||
uint8_t *Contents();
|
||||
Buffer();
|
||||
Buffer(size_t);
|
||||
Buffer(const char *);
|
||||
|
||||
uint8_t *Contents() { return this->contents; }
|
||||
size_t Size() { return this->size; };
|
||||
size_t Capacity() { return this->capacity; }
|
||||
|
||||
bool Append(uint8_t *data, size_t datalen);
|
||||
bool Append(uint8_t c);
|
||||
bool Insert(size_t index, uint8_t *data, size_t datalen);
|
||||
bool Insert(size_t index, uint8_t c);
|
||||
size_t Size();
|
||||
|
||||
// bool Remove(size_t index, size_t length);
|
||||
|
||||
/* memory management */
|
||||
void Resize(size_t newCapacity);
|
||||
size_t Trim();
|
||||
void Clear();
|
||||
void Reclaim();
|
||||
|
||||
private:
|
||||
bool mustGrow(size_t newLength);
|
||||
bool mustGrow(size_t delta);
|
||||
bool shift(size_t offset, size_t delta);
|
||||
|
||||
uint8_t *contents;
|
||||
size_t length;
|
||||
|
||||
Reference in New Issue
Block a user