Starting work on a buffer type.
This commit is contained in:
35
Buffer.h
Normal file
35
Buffer.h
Normal 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
|
||||
Reference in New Issue
Block a user