Starting work on a buffer type.

This commit is contained in:
2023-10-09 03:19:09 -07:00
parent 72e3bf77a7
commit d1f84be120
4 changed files with 157 additions and 10 deletions

35
Buffer.h Normal file
View File

@@ -0,0 +1,35 @@
//
// Created by kyle on 2023-10-09.
//
#ifndef KGE_BUFFER_H
#define KGE_BUFFER_H
#include <cstdint>
namespace kge {
class Buffer {
public:
uint8_t *Contents();
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();
void Resize(size_t newCapacity);
size_t Trim();
void Clear();
void Reclaim();
private:
bool mustGrow(size_t newLength);
uint8_t *contents;
size_t length;
size_t capacity;
};
} // kge
#endif //KGE_BUFFER_H