2017-10-21 06:11:49 +01:00
|
|
|
#ifndef ISOBUFFERBUFFER_H
|
|
|
|
#define ISOBUFFERBUFFER_H
|
|
|
|
|
|
|
|
//isobufferbuffer is a buffer designed for getting the last n things added in reverse order, in O(1) time.
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <stdlib.h>
|
2018-11-05 23:15:48 +00:00
|
|
|
#include <string>
|
2017-10-21 06:11:49 +01:00
|
|
|
|
|
|
|
class isoBufferBuffer
|
|
|
|
{
|
|
|
|
public:
|
2018-11-05 23:15:48 +00:00
|
|
|
isoBufferBuffer(uint32_t length);
|
2018-11-05 23:55:45 +00:00
|
|
|
void add(uint8_t newByte);
|
2017-10-21 06:11:49 +01:00
|
|
|
void add(char newChar);
|
2018-11-05 23:15:48 +00:00
|
|
|
void add(std::string newString);
|
|
|
|
char *get(uint32_t length);
|
|
|
|
uint32_t getNumCharsInBuffer();
|
2017-10-21 06:11:49 +01:00
|
|
|
private:
|
2018-11-05 23:15:48 +00:00
|
|
|
uint32_t bufferLength;
|
|
|
|
uint32_t mid;
|
|
|
|
uint32_t ptr;
|
2017-10-21 06:11:49 +01:00
|
|
|
char *buffer;
|
2018-11-05 23:15:48 +00:00
|
|
|
uint32_t numCharsInBuffer = 0;
|
2017-10-21 06:11:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ISOBUFFERBUFFER_H
|