2024-01-14 21:43:49 +01:00

40 lines
817 B
C++

#ifndef BUFFER_HPP
#define BUFFER_HPP
#include <cstdint>
#include <string>
class Buffer
{
public:
uint8_t *buffer = nullptr;
size_t taken = 0;
size_t size = 0;
std::string file_path;
Buffer(size_t size);
Buffer();
~Buffer();
bool resize(size_t new_size);
int add_end(uint8_t *data, size_t data_size);
int add_middle(uint8_t *data, size_t data_size, size_t index);
// Removes data from buffer without checking if it's in the buffer
void remove_fast(uint8_t *data, size_t data_size);
void remove(size_t index, size_t data_size);
size_t find(uint8_t *data, size_t data_size);
void remove(uint8_t *data, size_t data_size);
void clear() { taken = 0; }
bool save_to_file();
bool save_to_file(std::string file_path);
bool load_from_file();
bool load_from_file(std::string file_path);
};
#endif